Urbi SDK Remote for C++  2.7.5
ucontext.hh
Go to the documentation of this file.
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 #ifndef URBI_UCONTEXT_HH
00012 # define URBI_UCONTEXT_HH
00013 
00014 # include <libport/fwd.hh>
00015 # include <libport/utime.hh>
00016 
00017 # include <urbi/uvalue.hh>
00018 
00019 namespace urbi
00020 {
00022   enum UObjectMode
00023   {
00024     MODE_PLUGIN = 1,
00025     MODE_REMOTE
00026   };
00027 
00029   class UAutoValue: public UValue
00030   {
00031   public:
00032     UAutoValue();
00033     template<typename T>
00034     UAutoValue(T v);
00035     UAutoValue(const UValue& v);
00036   };
00037 
00041   class URBI_SDK_API UContext
00042   {
00043   public:
00044     UContext(impl::UContextImpl* ctx=0);
00045     UObjectHub* getUObjectHub(const std::string& n);
00046     UObject* getUObject(const std::string& n);
00049     void uobject_unarmorAndSend(const char* str);
00050 
00052     void send(const char* str);
00053     void send(const std::string&s);
00055     void send(const void* buf, size_t size);
00056     void call(const std::string& object,
00057               const std::string& method,
00058               UAutoValue v1 = UAutoValue(),
00059               UAutoValue v2 = UAutoValue(),
00060               UAutoValue v3 = UAutoValue(),
00061               UAutoValue v4 = UAutoValue(),
00062               UAutoValue v5 = UAutoValue(),
00063               UAutoValue v6 = UAutoValue());
00064 
00066     boost::asio::io_service& getIoService();
00067 
00069     UObjectMode getRunningMode() const;
00070 
00072     bool isPluginMode() const;
00074     bool isRemoteMode() const;
00075 
00078     void yield() const;
00079 
00081     void yield_until(libport::utime_t deadline) const;
00082 
00084     void yield_for(libport::utime_t delay) const;
00085 
00089     void yield_until_things_changed() const;
00090 
00094     void side_effect_free_set(bool s);
00095 
00097     bool side_effect_free_get() const;
00098 
00100     std::pair<int, int> kernelVersion();
00101     impl::UContextImpl* ctx_;
00102   };
00103 
00105   URBI_SDK_API impl::UContextImpl* getCurrentContext();
00106   URBI_SDK_API void setCurrentContext(impl::UContextImpl*);
00107 
00108   ATTRIBUTE_DEPRECATED
00109   ATTRIBUTE_PRINTF(1, 2)
00110   URBI_SDK_API void echo(const char* format, ...);
00111 }
00112 
00113 # include "urbi/ucontext.hxx"
00114 #endif