00001 /*************************************************************************** 00002 LOW_objectIDFactory.h - description 00003 ------------------- 00004 begin : Sun Oct 26 2003 00005 copyright : (C) 2003 by Harald Roelle 00006 email : roelle@informatik.uni-muenchen.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef LOW_OBJECTIDFACTORY_H 00019 #define LOW_OBJECTIDFACTORY_H 00020 00021 00022 #include "LOW_types.h" 00023 #include "LOW_objectSynchronizer.h" 00024 00025 00026 /** Factory class for individual object IDs. 00027 00028 This class is thread-safe. 00029 00030 @author Harald Roelle 00031 */ 00032 class LOW_objectIDFactory { 00033 00034 //======================================================================================= 00035 public: 00036 00037 //===================================================================================== 00038 // 00039 // type definitions 00040 // 00041 00042 typedef uint32_t objectID_t; /**< object ID type */ 00043 00044 00045 //===================================================================================== 00046 // 00047 // static methods 00048 // 00049 00050 /** Get a new unique object ID. 00051 To be precise, the ID is pseudo unique as a simple counter increment is used. 00052 @return A new unique object ID. 00053 */ 00054 static objectID_t getNewObjectID(); 00055 00056 00057 00058 //======================================================================================= 00059 protected: 00060 00061 //===================================================================================== 00062 // 00063 // static attributes 00064 // 00065 00066 __LOW_SYNCHRONIZE_DEFINE_PROTECTED_LOCK__ 00067 00068 00069 00070 //======================================================================================= 00071 private: 00072 00073 //===================================================================================== 00074 // 00075 // constructors 00076 // 00077 00078 /** Default constructor. 00079 It is private to prevent creating objects from this class as 00080 this is a static factory. 00081 */ 00082 LOW_objectIDFactory(); 00083 00084 /** Destructor. 00085 It is private to prevent creating objects from this class as 00086 this is a static factory. 00087 */ 00088 ~LOW_objectIDFactory(); 00089 00090 00091 //===================================================================================== 00092 // 00093 // static attributes 00094 // 00095 00096 /** Counter to get unique object IDs, incremented on instance creation to get individual IDs. */ 00097 static objectID_t objIDCounter; 00098 }; 00099 00100 #endif