Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

GElementID.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003-2004 by Raphael Langerhorst                        *
00003  *   raphael-langerhorst@gmx.at                                            *
00004  *                                                                         *
00005  *   Permission is hereby granted, free of charge, to any person obtaining *
00006  *   a copy of this software and associated documentation files (the       *
00007  *   "Software"), to deal in the Software without restriction, including   *
00008  *   without limitation the rights to use, copy, modify, merge, publish,   *
00009  *   distribute, sublicense, and/or sell copies of the Software, and to    *
00010  *   permit persons to whom the Software is furnished to do so, subject to *
00011  *   the following conditions:                                             *
00012  *                                                                         *
00013  *   The above copyright notice and this permission notice shall be        *
00014  *   included in all copies or substantial portions of the Software.       *
00015  *                                                                         *
00016  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
00017  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
00018  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
00019  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
00020  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
00021  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
00022  *   OTHER DEALINGS IN THE SOFTWARE.                                       *
00023  ***************************************************************************/
00024 
00025 #ifndef GELEMENTIDH
00026 #define GELEMENTIDH
00027 
00028 //needed prototype for friend declarations
00029 template<class T>
00030 class QValueListNode;
00031 
00032 namespace GCS
00033 {
00034 
00035 //will be defined in the implementation
00036 class IDRange;
00037 
00046 class GElementID
00047 {  
00048   private:
00049     
00054     static IDRange FreeIDs;
00055     
00056   public:
00057     
00058     static GElementID getNextFreeID();
00059     
00060     static void initFreeIDs(unsigned long low, unsigned long high);
00061     
00062   private:
00063   
00067     unsigned long ID;
00068 
00069   private:
00078     GElementID()
00079     : ID(0)
00080     {}
00081     
00082   public:
00083   
00087     GElementID(unsigned long ID) : ID(ID) {}
00088 
00092     GElementID(const GElementID& original) : ID(original.ID) {}
00093 
00097     unsigned long getID() const
00098     {
00099       return this->ID;
00100     }
00101 
00106     bool operator==(const GElementID& id) const
00107     {
00108       if (id.ID == this->ID)
00109         return true;
00110       return false;
00111     }
00112     
00117     bool operator!=(const GElementID& id) const
00118     {
00119       if (id.ID != this->ID)
00120         return true;
00121       return false;
00122     }
00123     
00124     //this is a workaround because QValueListNode needs
00125     //a default constructor;
00126     //
00127     //this constructor is declared private in GElementID
00128     //and made only available to this class
00129     //
00130     //note: QValueListNode is used by QValueList
00131     
00137     friend class QValueListNode<GElementID>;
00138 };
00139 
00140 }
00141 
00142 #endif

Generated on Thu Oct 21 21:18:03 2004 for G System by doxygen 1.3.6