|
Urbi SDK Remote for C++
2.7.5
|
00001 /* 00002 * Copyright (C) 2007, 2008, 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 00012 #ifndef URBI_STARTER_HH 00013 # define URBI_STARTER_HH 00014 00015 # include <libport/preproc.hh> 00016 00017 # include <string> 00018 00019 # include <urbi/export.hh> 00020 # include <urbi/fwd.hh> 00021 00022 #include <urbi/ucontext.hh> 00023 #include <urbi/uobject.hh> 00024 #include <urbi/version-check.hh> 00025 00027 # define UStartRename(Type, Name) \ 00028 ::urbi::URBIStarter<Type> \ 00029 Name ## ____URBI_object(#Name); \ 00030 URBI_CHECK_SDK_VERSION_BARE(#Name) 00031 00033 # define UStartWithID(Type) \ 00034 ::urbi::URBIStarter<Type> \ 00035 Type ## ____URBI_object(#Type, true); \ 00036 URBI_CHECK_SDK_VERSION_BARE(#Type) 00037 00039 # define UStart(Type) \ 00040 UStartRename(Type, Type) 00041 00043 # define UStartHub(Type) \ 00044 ::urbi::URBIStarterHub<Type> \ 00045 Type ## ____URBI_object(#Type); \ 00046 URBI_CHECK_SDK_VERSION_BARE(#Type) 00047 00048 namespace urbi 00049 { 00050 00051 /*-----------. 00052 | UStarter. | 00053 `-----------*/ 00054 00055 /*** UObject factory class. 00056 */ 00057 class URBI_SDK_API baseURBIStarter 00058 { 00059 public: 00060 baseURBIStarter(const std::string& name, bool local = false); 00061 virtual ~baseURBIStarter(); 00063 virtual UObject* instanciate(impl::UContextImpl* ctx, 00064 const std::string& n = std::string()) = 0; 00065 00066 std::string name; 00068 bool local; 00069 00071 typedef std::list<baseURBIStarter*> list_type; 00072 static list_type& list(); 00073 }; 00074 00075 00077 00081 template <class T> 00082 class URBIStarter 00083 : public baseURBIStarter 00084 { 00085 public: 00086 URBIStarter(const std::string& name, bool local = false); 00087 00088 virtual ~URBIStarter(); 00089 00090 virtual UObject* instanciate(impl::UContextImpl* ctx, 00091 const std::string& n=std::string()); 00092 00093 }; 00094 00095 00096 00097 /*--------------. 00098 | UStarterHub. | 00099 `--------------*/ 00100 00103 class URBI_SDK_API baseURBIStarterHub 00104 { 00105 public: 00106 baseURBIStarterHub(const std::string& name); 00107 virtual ~baseURBIStarterHub(); 00108 00110 virtual UObjectHub* instanciate(impl::UContextImpl* ctx, 00111 const std::string& n=std::string()) = 0; 00112 std::string name; 00113 00115 typedef std::list<baseURBIStarterHub*> list_type; 00116 static list_type& list(); 00117 00118 }; 00119 00120 00121 00123 00127 template <class T> 00128 class URBIStarterHub 00129 : public baseURBIStarterHub 00130 { 00131 public: 00132 URBIStarterHub(const std::string& name); 00133 virtual UObjectHub* instanciate(impl::UContextImpl* ctx, 00134 const std::string& n=std::string()); 00135 virtual ~URBIStarterHub(); 00136 00137 }; 00138 00139 } // end namespace urbi 00140 00141 # include <urbi/ustarter.hxx> 00142 00143 #endif // ! URBI_STARTER_HH