![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2007 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: DtProxy.h,v $ $Revision: 1.31 $ $State: Exp $ 00007 ******************************************************************************/ 00008 00011 00012 #ifndef DtProxy_H_ 00013 #define DtProxy_H_ 00014 00015 #include <vrvUtil/vrvUtil.h> 00016 #include <vlutil/vlSmartPointers.h> 00017 #include <vlutil/vlExceptions.h> 00018 00019 #include <map> 00020 00021 namespace makVrv 00022 { 00023 class DtMessage; 00024 00041 class DT_DLL_VRVUTIL DtProxy 00042 { 00043 public: 00044 00046 DtProxy(); 00047 00049 virtual void makeInvalid(); 00050 00054 inline bool isValid() const 00055 { 00056 return myValidFlag; 00057 } 00058 00063 inline void validate() const 00064 { 00065 if(!isValid()) 00066 { 00067 DtTHROW_NEW(DtCorruptedState, "Interface is invalid."); 00068 } 00069 } 00070 00071 protected: 00072 00073 bool myValidFlag; 00074 }; 00075 00076 typedef DtBoost::weak_ptr<DtProxy> DtProxyWP; 00077 typedef DtBoost::shared_ptr<DtProxy> DtProxySP; 00078 00082 template <typename K, typename V> 00083 DtBoost::shared_ptr<V> DtFindProxyByName(std::map<K, DtBoost::weak_ptr<V> >& map, const std::string& name) 00084 { 00085 typedef DtBoost::weak_ptr<V> VWP; 00086 typedef DtBoost::shared_ptr<V> VSP; 00087 00088 typename std::map<K, DtBoost::weak_ptr<V> >::iterator iter = map.find(name); 00089 if(iter != map.end()) 00090 { 00091 VSP proctor = iter->second.lock(); 00092 if(proctor) 00093 { 00094 return proctor; 00095 } 00096 } 00097 return VSP(); 00098 } 00099 00100 } 00101 00102 #endif