|
Urbi SDK Remote for C++
2.7.3
|
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 : UValue(v) 00031 {} 00032 00033 inline 00034 UAutoValue::UAutoValue(const UValue& v) 00035 { 00036 set(v, false); 00037 } 00038 00039 /*-----------. 00040 | UContext. | 00041 `-----------*/ 00042 00043 inline 00044 UContext::UContext(impl::UContextImpl* impl) 00045 : ctx_(impl ? impl : getCurrentContext()) 00046 { 00047 } 00048 00049 inline 00050 boost::asio::io_service& 00051 UContext::getIoService() 00052 { 00053 return ctx_->getIoService(); 00054 } 00055 00056 inline UObjectHub* 00057 getUObjectHub(const std::string& n) 00058 { 00059 return getCurrentContext()->getUObjectHub(n); 00060 } 00061 00062 inline UObjectHub* 00063 UContext::getUObjectHub(const std::string& n) 00064 { 00065 return ctx_->getUObjectHub(n); 00066 } 00067 00068 inline UObject* getUObject(const std::string& n) 00069 { 00070 return getCurrentContext()->getUObject(n); 00071 } 00072 00073 inline UObject* UContext:: 00074 getUObject(const std::string& n) 00075 { 00076 return ctx_->getUObject(n); 00077 } 00078 00081 inline void 00082 uobject_unarmorAndSend(const char* str) 00083 { 00084 return getCurrentContext()->uobject_unarmorAndSend(str); 00085 } 00086 00087 inline void 00088 UContext::uobject_unarmorAndSend(const char* str) 00089 { 00090 return ctx_->uobject_unarmorAndSend(str); 00091 } 00092 00093 inline void 00094 send(const char* str) 00095 { 00096 getCurrentContext()->send(str); 00097 } 00098 00100 inline void 00101 UContext::send(const char* str) 00102 { 00103 ctx_->send(str); 00104 } 00105 00106 inline void 00107 send(const std::string& str) 00108 { 00109 getCurrentContext()->send(str.c_str(), str.length()); 00110 } 00111 00112 inline void 00113 UContext::send(const std::string& s) 00114 { 00115 ctx_->send(s.c_str(), s.length()); 00116 } 00117 00119 inline void 00120 send(const void* buf, size_t size) 00121 { 00122 getCurrentContext()->send(buf, size); 00123 } 00124 00125 inline void 00126 UContext::send(const void* buf, size_t size) 00127 { 00128 ctx_->send(buf, size); 00129 } 00130 00131 inline void 00132 UContext::call(const std::string& object, 00133 const std::string& method, 00134 UAutoValue v1, 00135 UAutoValue v2, 00136 UAutoValue v3, 00137 UAutoValue v4, 00138 UAutoValue v5, 00139 UAutoValue v6) 00140 { 00141 ctx_->call(object, method, v1, v2, v3, v4, v5, v6); 00142 } 00143 00144 URBI_SDK_API UObjectMode running_mode(); 00145 inline UObjectMode 00146 getRunningMode() 00147 { 00148 if (impl::UContextImpl* ctx = getCurrentContext()) 00149 return ctx->getRunningMode(); 00150 else 00151 // Hack to get a valid mode if one of the uobjects is loaded 00152 return running_mode(); 00153 } 00154 00156 inline UObjectMode 00157 UContext::getRunningMode() const 00158 { 00159 return ctx_->getRunningMode(); 00160 } 00161 00162 inline bool 00163 isPluginMode() 00164 { 00165 return getRunningMode() == MODE_PLUGIN; 00166 } 00167 00169 inline bool 00170 UContext::isPluginMode() const 00171 { 00172 return getRunningMode() == MODE_PLUGIN; 00173 } 00174 00175 inline bool 00176 isRemoteMode() 00177 { 00178 return getRunningMode() == MODE_REMOTE; 00179 } 00181 inline bool 00182 UContext::isRemoteMode() const 00183 { 00184 return getRunningMode() == MODE_REMOTE; 00185 } 00186 00188 inline void 00189 UContext::yield() const 00190 { 00191 return ctx_->yield(); 00192 } 00193 00195 inline void 00196 UContext::yield_until(libport::utime_t deadline) const 00197 { 00198 return ctx_->yield_until(deadline); 00199 } 00200 00201 inline void 00202 UContext::yield_for(libport::utime_t delay) const 00203 { 00204 return ctx_->yield_for(delay); 00205 } 00206 00210 inline void 00211 UContext::yield_until_things_changed() const 00212 { 00213 return ctx_->yield_until_things_changed(); 00214 } 00215 00219 inline void 00220 UContext::side_effect_free_set(bool s) 00221 { 00222 return ctx_->side_effect_free_set(s); 00223 } 00224 00226 inline bool 00227 UContext::side_effect_free_get() const 00228 { 00229 return ctx_->side_effect_free_get(); 00230 } 00231 00232 inline std::pair<int, int> 00233 UContext::kernelVersion() 00234 { 00235 return ctx_->kernelVersion(); 00236 } 00237 }