2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADAFramework.
6
Licensed under the MIT Open Source License,
7
for details please see LICENSE file or the website
8
http://www.opensource.org/licenses/mit-license.php
11
#ifndef __COLLADAFW_UNIQUEID_H__
12
#define __COLLADAFW_UNIQUEID_H__
14
#include "COLLADAFWPrerequisites.h"
15
#include "COLLADAFWTypes.h"
16
#include "COLLADAFWArray.h"
21
/** Class that uniquely identifies each object in the model. It consists of a ClassId that uniquely identifies
22
the class an object is instantiated from and of an ObjectId that uniquely identifies the object in the set
23
of all objects of the same Type.*/
27
/** An invalid UniqueId.*/
28
static const UniqueId INVALID;
31
/** The class id of the class the object is instantiated from.*/
34
/** The object id that uniquely identifies the object in the set of all objects of the same Type.*/
37
/** The id of the COLLADA file that contains the object.*/
41
/** Default constructor. Creates a UniqueId with ClassId COLALDA_TYPES::No_TYPE, which is an invalid ClassId.
42
Therefore the UniqueId is considered to be invalid.*/
43
UniqueId() : mClassId(COLLADA_TYPE::NO_TYPE), mObjectId(0), mFileId(0){}
45
/** Constructor. Creates UniqueId with ClassId @a classId an ObjectId @a objectId.*/
46
UniqueId(ClassId classId, ObjectId objectId, FileId fileId) : mClassId(classId), mObjectId(objectId), mFileId(fileId){}
48
/** Constructor. Creates UniqueId from string @a ascii. This text representation is used in formula
49
to reference parameters.*/
50
UniqueId(const String& ascii);
54
/** Returns the class id of the class the object is instantiated from.*/
55
ClassId getClassId() const { return mClassId; }
57
/** Returns the object id that uniquely identifies the object in the set of all objects of the same Type.*/
58
ObjectId getObjectId() const { return mObjectId; }
60
/** Returns the id of the COLLADA file that contains the object.*/
61
FileId getFileId() const { return mFileId; }
63
/** Returns true if the unique id is valid, false otherwise.*/
64
bool isValid() const { return mClassId != COLLADA_TYPE::NO_TYPE; }
66
/** Creates an ascii representation of the unique id.*/
67
String toAscii() const;
69
/** Parses the ascii representation and sets this values according to @a ascii.
70
To ensure parsing always succeeds, only parse string created by toAscii().
71
@return True on success, false if parsing failed.*/
72
bool fromAscii( const String& ascii);
74
bool operator<(const UniqueId& rhs) const;
75
bool operator>(const UniqueId& rhs) const;
76
bool operator==(const UniqueId& uid) const;
77
bool operator!=(const UniqueId& uid) const;
79
operator size_t()const;
82
/** Parses the ascii representation and sets this values according to @a ascii.
83
To ensure parsing always succeeds, only parse string created by toAscii().
84
@return True on success, false if parsing failed.*/
85
bool fromAscii_intern( const String& ascii);
90
typedef Array<UniqueId> UniqueIdArray;
92
} // namespace COLLADAFW
94
#endif // __COLLADAFW_UNIQUEID_H__