newspeoplefor developersdocumentationdownloads

attributeid.h

Go to the documentation of this file.
00001 #ifndef ATTR_ATTRIBUTE_ID_H
00002 #define ATTR_ATTRIBUTE_ID_H
00003 //------------------------------------------------------------------------------
00038 #include "attr/_attridtyped.h"
00039 #include "attr/attributeclasses.h"
00040 
00041 namespace Attr
00042 {
00044     enum Type
00045     {
00046         Void    = nVariant::Void,
00047         Int     = nVariant::Int,
00048         Float   = nVariant::Float,
00049         Bool    = nVariant::Bool,
00050         Vector3 = nVariant::Vector3,
00051         Vector4 = nVariant::Vector4,
00052         String  = nVariant::String,
00053         Matrix44= nVariant::Matrix44,
00054         None
00055     };
00056 
00057 class AttributeID
00058 {
00059 public:
00060     AttributeID();
00061     AttributeID(const AttributeID&);
00062     AttributeID(const _attrid*);
00063     AttributeID(const nString& name); // must exist!
00064     virtual ~AttributeID();
00065 
00067     void operator=(const AttributeID& rhs);
00069     friend bool operator==(const AttributeID& lhs, const AttributeID& rhs);
00071     friend bool operator!=(const AttributeID& lhs, const AttributeID& rhs);
00073     bool IsValid() const;
00074 
00075 
00077     const nString& GetName() const;
00079     Type GetType() const;
00081     bool IsStorable() const;
00083     bool IsWritable() const;
00084 
00085 
00087     static AttributeID FindAttributeID(const nString& name);
00088 
00089 protected:
00090     const _attrid* attridPtr;
00091 };
00092 
00093 //------------------------------------------------------------------------------
00096 inline
00097 bool operator==(const AttributeID& lhs, const AttributeID& rhs)
00098 {
00099     return lhs.attridPtr == rhs.attridPtr;
00100 }
00101 
00102 //------------------------------------------------------------------------------
00105 inline
00106 bool operator!=(const AttributeID& lhs, const AttributeID& rhs)
00107 {
00108     return lhs.attridPtr != rhs.attridPtr;
00109 }
00110 
00111 //------------------------------------------------------------------------------
00114 inline
00115 bool 
00116 AttributeID::IsValid() const
00117 {
00118     return 0 != this->attridPtr;
00119 }
00120 
00121 //------------------------------------------------------------------------------
00124 inline
00125 void
00126 AttributeID::operator=(const AttributeID& rhs)
00127 {
00128     this->attridPtr = rhs.attridPtr;
00129 }
00130 
00131 //------------------------------------------------------------------------------
00134 inline
00135 AttributeID::~AttributeID()
00136 {
00137 }
00138 
00139 //------------------------------------------------------------------------------
00142 inline
00143 AttributeID::AttributeID() : 
00144     attridPtr(0)
00145 {
00146 }
00147 
00148 //------------------------------------------------------------------------------
00151 inline
00152 AttributeID::AttributeID(const _attrid* aip) :
00153     attridPtr(aip)
00154 {
00155 }
00156 
00157 //------------------------------------------------------------------------------
00160 inline
00161 AttributeID::AttributeID(const AttributeID& aId)
00162 {
00163     this->attridPtr = aId.attridPtr;
00164 }
00165 
00166 //------------------------------------------------------------------------------
00169 inline
00170 AttributeID::AttributeID(const nString& name)
00171 {
00172     const AttributeID& existingID = AttributeID::FindAttributeID(name);
00173     
00174     if ( !existingID.IsValid() )
00175     {
00176         n_error("Error: Attribute ID of name \"%s\" not found!", name.Get());
00177     }
00178 
00179     this->attridPtr = existingID.attridPtr;
00180 }
00181 
00182 //------------------------------------------------------------------------------
00185 inline
00186 const nString&
00187 AttributeID::GetName() const
00188 {
00189     return this->attridPtr->GetName();
00190 }
00191 
00192 //------------------------------------------------------------------------------
00195 inline
00196 Type 
00197 AttributeID::GetType() const
00198 {
00199     return (Type) this->attridPtr->GetType();
00200 }
00201 
00202 //------------------------------------------------------------------------------
00205 inline
00206 bool 
00207 AttributeID::IsStorable() const
00208 {
00209     return this->attridPtr->IsStorable();
00210 }
00211 
00212 //------------------------------------------------------------------------------
00215 inline
00216 bool 
00217 AttributeID::IsWritable() const
00218 {
00219     return this->attridPtr->IsWritable();
00220 }
00221 
00222 } // namespace Attr
00223 
00224 //typedef const _attrid* AttributeID;
00225 
00226 //------------------------------------------------------------------------------
00227 #endif

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.