📄 warobjectgroup.h
字号:
/** * This is an optional object that can * store information about a group of therads., * * The therads must be created with a reference to this * object. * * Once used, the object must not be deleted until all * the threads are destroyed! */#ifndef WAR_OBJECT_GROUP_H#define WAR_OBJECT_GROUP_H/* SYSTEM INCLUDES */#ifndef WAR_LIST_INCLUDED# define WAR_LIST_INCLUDED# include <list>#endif/* PROJECT INCLUDES */#ifndef WAR_AUTO_LOCK_H# include "WarAutoLock.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */class WarObjectGroupRef;#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarObjectGroup {public: typedef std::list<WarObjectGroupRef *> object_list_t; // LIFECYCLE /** * Default constructor. */ WarObjectGroup(void) { } /** * Destructor. */ ~WarObjectGroup(void) { } // OPERATORS // OPERATIONS // ACCESS // INQUIRY /// Get number of attached objects size_t GetSize() { WarAutoLock MyLock(mLock); return mObjects.size(); } /// bool IsEmpty() { WarAutoLock MyLock(mLock); return mObjects.empty(); } protected:private: friend class WarObjectGroupRef; void AttachObject(WarObjectGroupRef *pObject) throw(WarException) { WarAutoLock MyLock(mLock); mObjects.push_back(pObject); } void DetachObject(WarObjectGroupRef *pObject) throw(WarException) { WarAutoLock MyLock(mLock); mObjects.erase(Lookup(pObject)); } private: object_list_t::iterator WarObjectGroup::Lookup(WarObjectGroupRef *pObject) throw(WarException) { object_list_t::iterator P = mObjects.begin(); for( ; P != mObjects.end() ; P++) { if ((*P) == pObject) return P; } WarThrow(WarError(WAR_ERR_OBJECT_NOT_FOUND), NULL); return P; // Compiler food } object_list_t mObjects; WarCriticalSection mLock;};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* _WAR_OBJECT_GROUP_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -