Urbi SDK Remote for C++  2.7.5
customuvar.hh
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010, 2012, 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 
00013 #ifndef URBI_CUSTOMUVAR_HH
00014 # define URBI_CUSTOMUVAR_HH
00015 
00016 # include <urbi/uobject.hh>
00017 # include <urbi/uvar.hh>
00018 
00019 namespace urbi
00020 {
00042   template<typename T> class CustomUVar: public UVar
00043   {
00044   public:
00045     CustomUVar();
00046     CustomUVar(const std::string&, impl::UContextImpl* = 0);
00047     CustomUVar(const std::string&, const std::string&, impl::UContextImpl* = 0);
00048     CustomUVar(UObject&, const std::string&, impl::UContextImpl* = 0);
00049     T& data();
00050 
00051     template<typename D> void operator=(D v);
00055     static T& data(UVar&);
00056     static void updateCache(UVar& v);
00057   private:
00058     T data_;
00059   };
00060 }
00061 
00063 #define UBindCacheVar(Obj, V, T)                                        \
00064   UBindVar(Obj, V);                                                     \
00065   ::urbi::createUCallback(*this, &V,                                    \
00066                           "var", &::urbi::CustomUVar<T>::updateCache,   \
00067                           V.get_name(), ctx_);
00068 
00069 # include <urbi/customuvar.hxx>
00070 
00071 #endif