Nebula
Loading...
Searching...
No Matches
attrid.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
14#include "attributedefinition.h"
15
16//------------------------------------------------------------------------------
17namespace Attr
18{
19class AttrId
20{
21public:
23 AttrId();
25 AttrId(const AttrId& rhs);
31 AttrId(const Util::String& name);
33 AttrId(const Util::FourCC& fcc);
34
36 static bool IsValidName(const Util::String& n);
38 static bool IsValidFourCC(const Util::FourCC& fcc);
39
41 bool operator==(const AttrId& rhs) const;
43 bool operator!=(const AttrId& rhs) const;
45 bool operator>(const AttrId& rhs) const;
47 bool operator>=(const AttrId& rhs) const;
49 bool operator<(const AttrId& rhs) const;
51 bool operator<=(const AttrId& rhs) const;
52
54 const Util::String& GetName() const;
56 const Util::String& GetTypeName() const;
58 const Util::FourCC& GetFourCC() const;
62 ValueType GetValueType() const;
64 bool IsDynamic() const;
66 bool IsValid() const;
68 uint GetSizeOfType() const;
69
71 bool GetBoolDefValue() const;
73 int GetIntDefValue() const;
75 uint GetUIntDefValue() const;
77 float GetFloatDefValue() const;
79 const Util::String& GetStringDefValue() const;
83 const Math::mat4& GetMat4DefValue() const;
85 const Util::Blob& GetBlobDefValue() const;
87 const Util::Guid& GetGuidDefValue() const;
89 const Util::Variant& GetDefaultValue() const;
90
93
94protected:
96};
97
98//------------------------------------------------------------------------------
101inline
103 defPtr(0)
104{
105 // empty
106}
107
108//------------------------------------------------------------------------------
111inline
113 defPtr(rhs.defPtr)
114{
115 // empty
116}
117
118//------------------------------------------------------------------------------
121inline
123 defPtr(&def)
124{
125 // empty
126}
127
128//------------------------------------------------------------------------------
131inline
133 defPtr(ptr)
134{
135 // empty
136}
137
138//------------------------------------------------------------------------------
141inline
143{
145 if (0 == this->defPtr)
146 {
147 n_error("AttrId::AttrId(): invalid attribute name '%s'\n", name.AsCharPtr());
148 }
149}
150//------------------------------------------------------------------------------
153inline
155{
157 n_assert(0 != this->defPtr);
158}
159
160//------------------------------------------------------------------------------
163inline bool
168
169//------------------------------------------------------------------------------
172inline bool
177
178//------------------------------------------------------------------------------
181inline
182bool
184{
185 return (0 != this->defPtr);
186}
187
188//------------------------------------------------------------------------------
191inline
192uint
194{
195 n_assert(this->IsValid());
196 return this->defPtr->GetSizeOfType();
197
198}
199
200//------------------------------------------------------------------------------
203inline
204bool
205AttrId::operator==(const AttrId& rhs) const
206{
207 n_assert(this->IsValid() && rhs.IsValid());
208 return (this->defPtr == rhs.defPtr);
209}
210
211//------------------------------------------------------------------------------
214inline
215bool
216AttrId::operator!=(const AttrId& rhs) const
217{
218 n_assert(this->IsValid() && rhs.IsValid());
219 return (this->defPtr != rhs.defPtr);
220}
221
222//------------------------------------------------------------------------------
225inline
226bool
227AttrId::operator>(const AttrId& rhs) const
228{
229 n_assert(this->IsValid() && rhs.IsValid());
230 return (this->defPtr > rhs.defPtr);
231}
232
233//------------------------------------------------------------------------------
236inline
237bool
238AttrId::operator>=(const AttrId& rhs) const
239{
240 n_assert(this->IsValid() && rhs.IsValid());
241 return (this->defPtr >= rhs.defPtr);
242}
243
244//------------------------------------------------------------------------------
247inline
248bool
249AttrId::operator<(const AttrId& rhs) const
250{
251 n_assert(this->IsValid() && rhs.IsValid());
252 return (this->defPtr < rhs.defPtr);
253}
254
255//------------------------------------------------------------------------------
258inline
259bool
260AttrId::operator<=(const AttrId& rhs) const
261{
262 n_assert(this->IsValid() && rhs.IsValid());
263 return (this->defPtr <= rhs.defPtr);
264}
265
266//------------------------------------------------------------------------------
269inline
270const Util::String&
272{
273 n_assert(this->IsValid());
274 return this->defPtr->GetName();
275}
276
277//------------------------------------------------------------------------------
280inline
281const Util::String&
283{
284 n_assert(this->IsValid());
285 return this->defPtr->GetTypeName();
286}
287
288//------------------------------------------------------------------------------
291inline
292const Util::FourCC&
294{
295 n_assert(this->IsValid());
296 return this->defPtr->GetFourCC();
297}
298
299//------------------------------------------------------------------------------
302inline
305{
306 n_assert(this->IsValid());
307 return this->defPtr->GetAccessMode();
308}
309
310//------------------------------------------------------------------------------
313inline
316{
317 n_assert(this->IsValid());
318 return this->defPtr->GetValueType();
319}
320//------------------------------------------------------------------------------
323inline
324bool
326{
327 n_assert(0 != this->defPtr);
328 return this->defPtr->IsDynamic();
329}
330
331//------------------------------------------------------------------------------
334inline
335bool
337{
338 n_assert(0 != this->defPtr);
339 return this->defPtr->GetDefaultValue().GetBool();
340}
341
342//------------------------------------------------------------------------------
345inline
346int
348{
349 n_assert(0 != this->defPtr);
350 return this->defPtr->GetDefaultValue().GetInt();
351}
352
353//------------------------------------------------------------------------------
356inline
357uint
359{
360 n_assert(0 != this->defPtr);
361 return this->defPtr->GetDefaultValue().GetUInt();
362}
363
364//------------------------------------------------------------------------------
367inline
368float
370{
371 n_assert(0 != this->defPtr);
372 return this->defPtr->GetDefaultValue().GetFloat();
373}
374
375//------------------------------------------------------------------------------
378inline
379const Util::String&
381{
382 n_assert(0 != this->defPtr);
383 return this->defPtr->GetDefaultValue().GetString();
384}
385
386//------------------------------------------------------------------------------
389inline
392{
393 n_assert(0 != this->defPtr);
394 return this->defPtr->GetDefaultValue().GetVec4();
395}
396
397//------------------------------------------------------------------------------
400inline
401const Math::mat4&
403{
404 n_assert(0 != this->defPtr);
405 return this->defPtr->GetDefaultValue().GetMat4();
406}
407
408//------------------------------------------------------------------------------
411inline
412const Util::Blob&
414{
415 n_assert(0 != this->defPtr);
416 return this->defPtr->GetDefaultValue().GetBlob();
417}
418
419//------------------------------------------------------------------------------
422inline
423const Util::Guid&
425{
426 n_assert(0 != this->defPtr);
427 return this->defPtr->GetDefaultValue().GetGuid();
428}
429
430//------------------------------------------------------------------------------
433inline
434const Util::Variant&
436{
437 n_assert(0 != this->defPtr);
438 return this->defPtr->GetDefaultValue();
439}
440
441} // namespace Attr
442//------------------------------------------------------------------------------
An attribute ID is used to carry attribute types (no values) around.
Definition attrid.h:20
int GetIntDefValue() const
get int default value
Definition attrid.h:347
AccessMode GetAccessMode() const
get access type
Definition attrid.h:304
const Util::Guid & GetGuidDefValue() const
get guid default value
Definition attrid.h:424
const Util::Blob & GetBlobDefValue() const
get blob default value
Definition attrid.h:413
const Util::FourCC & GetFourCC() const
get fourcc code
Definition attrid.h:293
bool operator>(const AttrId &rhs) const
greater operator
Definition attrid.h:227
static bool IsValidName(const Util::String &n)
return true if the provided attribute id name is valid
Definition attrid.h:164
AttrId()
default constructor
Definition attrid.h:102
uint GetUIntDefValue() const
get uint default value
Definition attrid.h:358
bool operator>=(const AttrId &rhs) const
greater-or-equal operator
Definition attrid.h:238
const Util::String & GetTypeName() const
get attribute type name
Definition attrid.h:282
bool operator<(const AttrId &rhs) const
lesser operator
Definition attrid.h:249
bool operator<=(const AttrId &rhs) const
lesser-or-equal operator
Definition attrid.h:260
float GetFloatDefValue() const
get floar default value
Definition attrid.h:369
bool operator==(const AttrId &rhs) const
equality operator
Definition attrid.h:205
static Util::FixedArray< AttrId > GetAllAttrIds()
return all attribute id's (slow!)
Definition attrid.cc:17
const Util::String & GetName() const
get attribute name
Definition attrid.h:271
bool IsDynamic() const
return true if this attribute was dynamically registered
Definition attrid.h:325
ValueType GetValueType() const
get value type
Definition attrid.h:315
const AttributeDefinitionBase * defPtr
Definition attrid.h:95
bool IsValid() const
return true if the attribute id object is valid
Definition attrid.h:183
const Util::Variant & GetDefaultValue() const
get default value variant
Definition attrid.h:435
uint GetSizeOfType() const
return the byte size of the type
Definition attrid.h:193
bool GetBoolDefValue() const
get bool default value
Definition attrid.h:336
const Math::mat4 & GetMat4DefValue() const
get mat4 default value
Definition attrid.h:402
const Util::String & GetStringDefValue() const
get string default value
Definition attrid.h:380
bool operator!=(const AttrId &rhs) const
inequality operator
Definition attrid.h:216
static bool IsValidFourCC(const Util::FourCC &fcc)
return true if the provided attribute id fourcc is valid
Definition attrid.h:173
Math::vec4 GetVec4DefValue() const
get float4 default value
Definition attrid.h:391
Implements a universal attribute definition, consisting of an attribute name, attribute fourcc code,...
Definition attributedefinitionbase.h:30
static const AttributeDefinitionBase * FindByName(const Util::String &n)
find by name
Definition attributedefinitionbase.h:166
const uint GetSizeOfType() const
get size of type in bytes
Definition attributedefinitionbase.h:242
const Util::String & GetTypeName() const
get type name
Definition attributedefinitionbase.h:222
AccessMode GetAccessMode() const
get access type
Definition attributedefinitionbase.h:296
bool IsDynamic() const
return true if this is a dynamic attribute
Definition attributedefinitionbase.h:306
const Util::Variant & GetDefaultValue() const
get default value
Definition attributedefinitionbase.h:232
static const AttributeDefinitionBase * FindByFourCC(const Util::FourCC &fcc)
find by FourCC
Definition attributedefinitionbase.h:184
const Util::String & GetName() const
get attribute name
Definition attributedefinitionbase.h:202
ValueType GetValueType() const
get value type
Definition attributedefinitionbase.h:286
const Util::FourCC & GetFourCC() const
get fourcc code
Definition attributedefinitionbase.h:212
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
Implements a fixed size one-dimensional array.
Definition fixedarray.h:20
A four-character-code is a quasi-human-readable 32-bit-id.
Definition fourcc.h:19
Implements a GUID.
An "any type" variable.
Definition variant.h:31
const Math::mat4 & GetMat4() const
get mat4 content
Definition variant.h:2642
Math::vec4 GetVec4() const
get vec4 content
Definition variant.h:2604
int GetInt() const
get integer content
Definition variant.h:2422
const Util::String & GetString() const
get string content
Definition variant.h:2548
uint GetUInt() const
get unsigned integer content
Definition variant.h:2432
bool GetBool() const
get bool content
Definition variant.h:2529
const Util::Guid & GetGuid() const
get guid content
Definition variant.h:2680
float GetFloat() const
get float content
Definition variant.h:2491
const Util::Blob & GetBlob() const
get blob
Definition variant.h:2699
void __cdecl n_error(const char *msg,...)
This function is called when a serious situation is encountered which requires abortion of the applic...
Definition debug.cc:138
#define n_assert(exp)
Definition debug.h:50
Definition accessmode.h:13
ValueType
Definition valuetype.h:20
AccessMode
Definition accessmode.h:15
A 4x4 single point precision float matrix.
Definition mat4.h:49
A 4D vector.
Definition vec4.h:24
Nebula's universal string class.
Definition string.h:50
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:542
unsigned int uint
Definition types.h:31