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 int GetInt64DefValue() const;
79 uint GetUInt64DefValue() const;
81 float GetFloatDefValue() const;
83 const Util::String& GetStringDefValue() const;
87 const Math::mat4& GetMat4DefValue() const;
89 const Util::Blob& GetBlobDefValue() const;
91 const Util::Guid& GetGuidDefValue() const;
93 const Util::Variant& GetDefaultValue() const;
94
97
98protected:
100};
101
102//------------------------------------------------------------------------------
105inline
107 defPtr(0)
108{
109 // empty
110}
111
112//------------------------------------------------------------------------------
115inline
117 defPtr(rhs.defPtr)
118{
119 // empty
120}
121
122//------------------------------------------------------------------------------
125inline
127 defPtr(&def)
128{
129 // empty
130}
131
132//------------------------------------------------------------------------------
135inline
137 defPtr(ptr)
138{
139 // empty
140}
141
142//------------------------------------------------------------------------------
145inline
147{
149 if (0 == this->defPtr)
150 {
151 n_error("AttrId::AttrId(): invalid attribute name '%s'\n", name.AsCharPtr());
152 }
153}
154//------------------------------------------------------------------------------
157inline
159{
161 n_assert(0 != this->defPtr);
162}
163
164//------------------------------------------------------------------------------
167inline bool
172
173//------------------------------------------------------------------------------
176inline bool
181
182//------------------------------------------------------------------------------
185inline
186bool
188{
189 return (0 != this->defPtr);
190}
191
192//------------------------------------------------------------------------------
195inline
196uint
198{
199 n_assert(this->IsValid());
200 return this->defPtr->GetSizeOfType();
201
202}
203
204//------------------------------------------------------------------------------
207inline
208bool
209AttrId::operator==(const AttrId& rhs) const
210{
211 n_assert(this->IsValid() && rhs.IsValid());
212 return (this->defPtr == rhs.defPtr);
213}
214
215//------------------------------------------------------------------------------
218inline
219bool
220AttrId::operator!=(const AttrId& rhs) const
221{
222 n_assert(this->IsValid() && rhs.IsValid());
223 return (this->defPtr != rhs.defPtr);
224}
225
226//------------------------------------------------------------------------------
229inline
230bool
231AttrId::operator>(const AttrId& rhs) const
232{
233 n_assert(this->IsValid() && rhs.IsValid());
234 return (this->defPtr > rhs.defPtr);
235}
236
237//------------------------------------------------------------------------------
240inline
241bool
242AttrId::operator>=(const AttrId& rhs) const
243{
244 n_assert(this->IsValid() && rhs.IsValid());
245 return (this->defPtr >= rhs.defPtr);
246}
247
248//------------------------------------------------------------------------------
251inline
252bool
253AttrId::operator<(const AttrId& rhs) const
254{
255 n_assert(this->IsValid() && rhs.IsValid());
256 return (this->defPtr < rhs.defPtr);
257}
258
259//------------------------------------------------------------------------------
262inline
263bool
264AttrId::operator<=(const AttrId& rhs) const
265{
266 n_assert(this->IsValid() && rhs.IsValid());
267 return (this->defPtr <= rhs.defPtr);
268}
269
270//------------------------------------------------------------------------------
273inline
274const Util::String&
276{
277 n_assert(this->IsValid());
278 return this->defPtr->GetName();
279}
280
281//------------------------------------------------------------------------------
284inline
285const Util::String&
287{
288 n_assert(this->IsValid());
289 return this->defPtr->GetTypeName();
290}
291
292//------------------------------------------------------------------------------
295inline
296const Util::FourCC&
298{
299 n_assert(this->IsValid());
300 return this->defPtr->GetFourCC();
301}
302
303//------------------------------------------------------------------------------
306inline
309{
310 n_assert(this->IsValid());
311 return this->defPtr->GetAccessMode();
312}
313
314//------------------------------------------------------------------------------
317inline
320{
321 n_assert(this->IsValid());
322 return this->defPtr->GetValueType();
323}
324//------------------------------------------------------------------------------
327inline
328bool
330{
331 n_assert(0 != this->defPtr);
332 return this->defPtr->IsDynamic();
333}
334
335//------------------------------------------------------------------------------
338inline
339bool
341{
342 n_assert(0 != this->defPtr);
343 return this->defPtr->GetDefaultValue().GetBool();
344}
345
346//------------------------------------------------------------------------------
349inline
350int
352{
353 n_assert(0 != this->defPtr);
354 return this->defPtr->GetDefaultValue().GetInt();
355}
356
357//------------------------------------------------------------------------------
360inline
361uint
363{
364 n_assert(0 != this->defPtr);
365 return this->defPtr->GetDefaultValue().GetUInt();
366}
367
368//------------------------------------------------------------------------------
371inline
372int
374{
375 n_assert(0 != this->defPtr);
376 return this->defPtr->GetDefaultValue().GetInt64();
377}
378
379//------------------------------------------------------------------------------
382inline
383uint
385{
386 n_assert(0 != this->defPtr);
387 return this->defPtr->GetDefaultValue().GetUInt64();
388}
389
390//------------------------------------------------------------------------------
393inline
394float
396{
397 n_assert(0 != this->defPtr);
398 return this->defPtr->GetDefaultValue().GetFloat();
399}
400
401//------------------------------------------------------------------------------
404inline
405const Util::String&
407{
408 n_assert(0 != this->defPtr);
409 return this->defPtr->GetDefaultValue().GetString();
410}
411
412//------------------------------------------------------------------------------
415inline
418{
419 n_assert(0 != this->defPtr);
420 return this->defPtr->GetDefaultValue().GetVec4();
421}
422
423//------------------------------------------------------------------------------
426inline
427const Math::mat4&
429{
430 n_assert(0 != this->defPtr);
431 return this->defPtr->GetDefaultValue().GetMat4();
432}
433
434//------------------------------------------------------------------------------
437inline
438const Util::Blob&
440{
441 n_assert(0 != this->defPtr);
442 return this->defPtr->GetDefaultValue().GetBlob();
443}
444
445//------------------------------------------------------------------------------
448inline
449const Util::Guid&
451{
452 n_assert(0 != this->defPtr);
453 return this->defPtr->GetDefaultValue().GetGuid();
454}
455
456//------------------------------------------------------------------------------
459inline
460const Util::Variant&
462{
463 n_assert(0 != this->defPtr);
464 return this->defPtr->GetDefaultValue();
465}
466
467} // namespace Attr
468//------------------------------------------------------------------------------
int GetIntDefValue() const
get int default value
Definition attrid.h:351
AccessMode GetAccessMode() const
get access type
Definition attrid.h:308
const Util::Guid & GetGuidDefValue() const
get guid default value
Definition attrid.h:450
const Util::Blob & GetBlobDefValue() const
get blob default value
Definition attrid.h:439
const Util::FourCC & GetFourCC() const
get fourcc code
Definition attrid.h:297
bool operator>(const AttrId &rhs) const
greater operator
Definition attrid.h:231
static bool IsValidName(const Util::String &n)
return true if the provided attribute id name is valid
Definition attrid.h:168
AttrId()
default constructor
Definition attrid.h:106
uint GetUIntDefValue() const
get uint default value
Definition attrid.h:362
bool operator>=(const AttrId &rhs) const
greater-or-equal operator
Definition attrid.h:242
const Util::String & GetTypeName() const
get attribute type name
Definition attrid.h:286
bool operator<(const AttrId &rhs) const
lesser operator
Definition attrid.h:253
bool operator<=(const AttrId &rhs) const
lesser-or-equal operator
Definition attrid.h:264
float GetFloatDefValue() const
get floar default value
Definition attrid.h:395
bool operator==(const AttrId &rhs) const
equality operator
Definition attrid.h:209
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:275
bool IsDynamic() const
return true if this attribute was dynamically registered
Definition attrid.h:329
ValueType GetValueType() const
get value type
Definition attrid.h:319
const AttributeDefinitionBase * defPtr
Definition attrid.h:99
int GetInt64DefValue() const
get int default value
Definition attrid.h:373
bool IsValid() const
return true if the attribute id object is valid
Definition attrid.h:187
const Util::Variant & GetDefaultValue() const
get default value variant
Definition attrid.h:461
uint GetSizeOfType() const
return the byte size of the type
Definition attrid.h:197
uint GetUInt64DefValue() const
get uint default value
Definition attrid.h:384
bool GetBoolDefValue() const
get bool default value
Definition attrid.h:340
const Math::mat4 & GetMat4DefValue() const
get mat4 default value
Definition attrid.h:428
const Util::String & GetStringDefValue() const
get string default value
Definition attrid.h:406
bool operator!=(const AttrId &rhs) const
inequality operator
Definition attrid.h:220
static bool IsValidFourCC(const Util::FourCC &fcc)
return true if the provided attribute id fourcc is valid
Definition attrid.h:177
Math::vec4 GetVec4DefValue() const
get float4 default value
Definition attrid.h:417
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
static const AttributeDefinitionBase * FindByFourCC(const Util::FourCC &fcc)
find by FourCC
Definition attributedefinitionbase.h:184
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
An "any type" variable.
Definition variant.h:32
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.cs:8
const char * AsCharPtr() const
return contents as character pointer
Definition string.h:558
unsigned int uint
Definition types.h:33