|
Urbi SDK Remote for C++
2.7.5
|
00001 /* 00002 * Copyright (C) 2007-2010, 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 #include <urbi/uobject.hh> 00014 00016 namespace urbi 00017 { 00018 /*-------------. 00019 | UObjectHub. | 00020 `-------------*/ 00021 00023 UObjectHub::UObjectHub(const std::string& s, impl::UContextImpl* ctx) 00024 : UContext(ctx) 00025 , name(s) 00026 { 00027 ctx_->registerHub(this); 00028 } 00029 00030 int 00031 UObjectHub::updateGlobal() 00032 { 00033 for (UObjectList::iterator i = members.begin(); i != members.end(); ++i) 00034 (*i)->update(); 00035 update(); 00036 return 0; 00037 } 00038 00039 void 00040 UObjectHub::addMember(UObject* obj) 00041 { 00042 members.push_back(obj); 00043 } 00044 00045 void 00046 UObjectHub::delMember(UObject* obj) 00047 { 00048 members.remove (obj); 00049 } 00050 00051 UObjectList* 00052 UObjectHub::getSubClass(const std::string& subclass) 00053 { 00054 UObjectList* res = new UObjectList(); 00055 for (UObjectList::iterator i = members.begin(); i != members.end(); ++i) 00056 if ((*i)->classname == subclass) 00057 res->push_back(*i); 00058 00059 return res; 00060 } 00061 00062 void 00063 UObjectHub::USetUpdate(ufloat period) 00064 { 00065 ctx_->setHubUpdate(this, period); 00066 } 00067 UObjectHub::~UObjectHub() 00068 { 00069 ctx_->removeHub(this); 00070 } 00071 } // namespace urbi