|
Urbi SDK Remote for C++
2.7.5
|
00001 /* 00002 * Copyright (C) 2009, 2010, 2011, Gostai S.A.S. 00003 * 00004 * This software is provided "as is" without warranty of any kind, 00005 * either expressed or implied, including but not limited to the 00006 * implied warranties of fitness for a particular purpose. 00007 * 00008 * See the LICENSE file for more information. 00009 */ 00010 00011 #include <libport/hash.hh> 00012 #include <urbi/fwd.hh> 00013 #include <urbi/ucontext-impl.hh> 00014 00015 namespace urbi 00016 { 00017 00018 /*-------------. 00019 | UAutoValue. | 00020 `-------------*/ 00021 00022 inline 00023 UAutoValue::UAutoValue() 00024 : UValue() 00025 {} 00026 00027 template<typename T> 00028 inline 00029 UAutoValue::UAutoValue(T v) 00030 { 00031 *this, v; 00032 } 00033 00034 inline 00035 UAutoValue::UAutoValue(const UValue& v) 00036 { 00037 set(v, false); 00038 } 00039 00040 /*-----------. 00041 | UContext. | 00042 `-----------*/ 00043 00044 inline 00045 UContext::UContext(impl::UContextImpl* impl) 00046 : ctx_(impl ? impl : getCurrentContext()) 00047 { 00048 } 00049 00050 inline 00051 boost::asio::io_service& 00052 UContext::getIoService() 00053 { 00054 return ctx_->getIoService(); 00055 } 00056 00057 inline UObjectHub* 00058 getUObjectHub(const std::string& n) 00059 { 00060 return getCurrentContext()->getUObjectHub(n); 00061 } 00062 00063 inline UObjectHub* 00064 UContext::getUObjectHub(const std::string& n) 00065 { 00066 return ctx_->getUObjectHub(n); 00067 } 00068 00069 inline UObject* getUObject(const std::string& n) 00070 { 00071 return getCurrentContext()->getUObject(n); 00072 } 00073 00074 inline UObject* UContext:: 00075 getUObject(const std::string& n) 00076 { 00077 return ctx_->getUObject(n); 00078 } 00079 00082 inline void 00083 uobject_unarmorAndSend(const char* str) 00084 { 00085 return getCurrentContext()->uobject_unarmorAndSend(str); 00086 } 00087 00088 inline void 00089 UContext::uobject_unarmorAndSend(const char* str) 00090 { 00091 return ctx_->uobject_unarmorAndSend(str); 00092 } 00093 00094 inline void 00095 send(const char* str) 00096 { 00097 getCurrentContext()->send(str); 00098 } 00099 00101 inline void 00102 UContext::send(const char* str) 00103 { 00104 ctx_->send(str); 00105 } 00106 00107 inline void 00108 send(const std::string& str) 00109 { 00110 getCurrentContext()->send(str.c_str(), str.length()); 00111 } 00112 00113 inline void 00114 UContext::send(const std::string& s) 00115 { 00116 ctx_->send(s.c_str(), s.length()); 00117 } 00118 00120 inline void 00121 send(const void* buf, size_t size) 00122 { 00123 getCurrentContext()->send(buf, size); 00124 } 00125 00126 inline void 00127 UContext::send(const void* buf, size_t size) 00128 { 00129 ctx_->send(buf, size); 00130 } 00131 00132 inline void 00133 UContext::call(const std::string& object, 00134 const std::string& method, 00135 UAutoValue v1, 00136 UAutoValue v2, 00137 UAutoValue v3, 00138 UAutoValue v4, 00139 UAutoValue v5, 00140 UAutoValue v6) 00141 { 00142 ctx_->call(object, method, v1, v2, v3, v4, v5, v6); 00143 } 00144 00145 URBI_SDK_API UObjectMode running_mode(); 00146 inline UObjectMode 00147 getRunningMode() 00148 { 00149 if (impl::UContextImpl* ctx = getCurrentContext()) 00150 return ctx->getRunningMode(); 00151 else 00152 // Hack to get a valid mode if one of the uobjects is loaded 00153 return running_mode(); 00154 } 00155 00157 inline UObjectMode 00158 UContext::getRunningMode() const 00159 { 00160 return ctx_->getRunningMode(); 00161 } 00162 00163 inline bool 00164 isPluginMode() 00165 { 00166 return getRunningMode() == MODE_PLUGIN; 00167 } 00168 00170 inline bool 00171 UContext::isPluginMode() const 00172 { 00173 return getRunningMode() == MODE_PLUGIN; 00174 } 00175 00176 inline bool 00177 isRemoteMode() 00178 { 00179 return getRunningMode() == MODE_REMOTE; 00180 } 00182 inline bool 00183 UContext::isRemoteMode() const 00184 { 00185 return getRunningMode() == MODE_REMOTE; 00186 } 00187 00189 inline void 00190 UContext::yield() const 00191 { 00192 return ctx_->yield(); 00193 } 00194 00196 inline void 00197 UContext::yield_until(libport::utime_t deadline) const 00198 { 00199 return ctx_->yield_until(deadline); 00200 } 00201 00202 inline void 00203 UContext::yield_for(libport::utime_t delay) const 00204 { 00205 return ctx_->yield_for(delay); 00206 } 00207 00211 inline void 00212 UContext::yield_until_things_changed() const 00213 { 00214 return ctx_->yield_until_things_changed(); 00215 } 00216 00220 inline void 00221 UContext::side_effect_free_set(bool s) 00222 { 00223 return ctx_->side_effect_free_set(s); 00224 } 00225 00227 inline bool 00228 UContext::side_effect_free_get() const 00229 { 00230 return ctx_->side_effect_free_get(); 00231 } 00232 00233 inline std::pair<int, int> 00234 UContext::kernelVersion() 00235 { 00236 return ctx_->kernelVersion(); 00237 } 00238 }