00001 // This is gel/vsol/vsol_flags_id.h 00002 #ifndef vsol_flags_id_h_ 00003 #define vsol_flags_id_h_ 00004 //----------------------------------------------------------------------------- 00005 //: 00006 // \file 00007 // \brief Base class for vsol_spatial_object 00008 // Includes members related to id, tag and flags of a vsol_spatial_object 00009 // 00010 // \author 00011 // H.Can Aras 00012 // 00013 //----------------------------------------------------------------------------- 00014 00015 #ifndef vsol_spatial_object_flags_ 00016 #define vsol_spatial_object_flags_ 00017 00018 // system flags 00019 const unsigned int VSOL_UNIONBIT = 0x80000000; 00020 const unsigned int VSOL_SYSTEM_FLAG1 = 0x01000000; 00021 // user flags 00022 const unsigned int VSOL_FLAG1 = 0x40000000; 00023 const unsigned int VSOL_FLAG2 = 0x20000000; 00024 const unsigned int VSOL_FLAG3 = 0x1000000; 00025 const unsigned int VSOL_FLAG4 = 0x08000000; 00026 const unsigned int VSOL_FLAG5 = 0x04000000; 00027 const unsigned int VSOL_FLAG6 = 0x02000000; 00028 00029 // mask for last three bytes of tag field 00030 const unsigned int VSOL_DEXID_BITS = 0x00FFFFFF; 00031 const unsigned int VSOL_FLAG_BITS = 0xFF000000; 00032 00033 #endif // vsol_spatial_object_flags_ 00034 00035 class vsol_flags_id 00036 { 00037 protected: 00038 // Data Members-------------------------------------------------------------- 00039 unsigned int tag_; 00040 int id_; 00041 static int tagcount_;// global count of all spatial objects. 00042 00043 public: 00044 // Constructors/Destructor--------------------------------------------------- 00045 virtual ~vsol_flags_id(); 00046 00047 protected: 00048 vsol_flags_id(); 00049 00050 // Data Access--------------------------------------------------------------- 00051 public: 00052 //: get id of object 00053 int get_id() const { return id_; } 00054 //: set id of object 00055 void set_id(int i) { id_ = i; } 00056 00057 // Tag, Flag, and ID methods 00058 00059 inline void set_user_flag(unsigned int flag); 00060 inline bool get_user_flag(unsigned int flag); 00061 inline void unset_user_flag(unsigned int flag); 00062 inline void set_tagged_union_flag(); 00063 inline bool get_tagged_union_flag(); 00064 inline void unset_tagged_union_flag(); 00065 inline int get_tag_id(); 00066 inline void set_tag_id(int id); 00067 }; 00068 00069 // inline member functions 00070 00071 //: set a flag for a spatial object; flag can be VSOL_FLAG[1-6] 00072 inline void vsol_flags_id::set_user_flag(unsigned int flag) 00073 { 00074 tag_ = (tag_ | flag); 00075 } 00076 00077 //: check if a flag is set for a spatial object; flag can be VSOL_FLAG[1-6] 00078 inline bool vsol_flags_id::get_user_flag(unsigned int flag) 00079 { 00080 return (tag_ & flag) != 0; 00081 } 00082 00083 //: un-set a flag for a spatial object; flag can be VSOL_FLAG[1-6] 00084 inline void vsol_flags_id::unset_user_flag(unsigned int flag) 00085 { 00086 tag_ = ( tag_ & (~flag) ); 00087 } 00088 00089 //: set the flag used by TAGGED_UNION. 00090 inline void vsol_flags_id::set_tagged_union_flag() 00091 { 00092 set_user_flag(VSOL_UNIONBIT); 00093 } 00094 00095 //: check if the flag used by TAGGED_UNION is set. 00096 inline bool vsol_flags_id::get_tagged_union_flag() 00097 { 00098 return get_user_flag(VSOL_UNIONBIT); 00099 } 00100 00101 //: un-set the flag used by TAGGED_UNION. 00102 inline void vsol_flags_id::unset_tagged_union_flag() 00103 { 00104 unset_user_flag(VSOL_UNIONBIT); 00105 } 00106 00107 inline int vsol_flags_id::get_tag_id() 00108 { 00109 return tag_ & VSOL_DEXID_BITS; 00110 } 00111 00112 inline void vsol_flags_id::set_tag_id(int id) 00113 { 00114 // ( set the new id bits) or (save just the flag bits from the tag_) 00115 tag_ = ( (id & VSOL_DEXID_BITS) | ( tag_ & VSOL_FLAG_BITS )); 00116 } 00117 00118 #endif // vsol_flags_id_h_