~ubuntu-branches/ubuntu/wily/opencollada/wily-proposed

« back to all changes in this revision

Viewing changes to COLLADAFramework/include/COLLADAFWUniqueId.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2008-2009 NetAllied Systems GmbH
 
3
 
 
4
This file is part of COLLADAFramework.
 
5
 
 
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
 
9
*/
 
10
 
 
11
#ifndef __COLLADAFW_UNIQUEID_H__
 
12
#define __COLLADAFW_UNIQUEID_H__
 
13
 
 
14
#include "COLLADAFWPrerequisites.h"
 
15
#include "COLLADAFWTypes.h"
 
16
#include "COLLADAFWArray.h"
 
17
 
 
18
 
 
19
namespace COLLADAFW
 
20
{
 
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.*/
 
24
        class UniqueId  
 
25
        {
 
26
        public:
 
27
                /** An invalid UniqueId.*/
 
28
                static const UniqueId INVALID;
 
29
 
 
30
        private:
 
31
                /** The class id of the class the object is instantiated from.*/
 
32
                ClassId mClassId;
 
33
 
 
34
                /** The object id that uniquely identifies the object in the set of all objects of the same Type.*/
 
35
                ObjectId mObjectId;
 
36
 
 
37
                /** The id of the COLLADA file that contains the object.*/
 
38
                FileId mFileId;
 
39
 
 
40
        public:
 
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){}
 
44
 
 
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){}
 
47
 
 
48
                /** Constructor. Creates UniqueId from string @a ascii. This text representation is used in formula 
 
49
                to reference parameters.*/
 
50
                UniqueId(const String& ascii);
 
51
 
 
52
                ~UniqueId();
 
53
 
 
54
                /** Returns the class id of the class the object is instantiated from.*/
 
55
                ClassId getClassId() const { return mClassId; }
 
56
 
 
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; }
 
59
 
 
60
                /** Returns the id of the COLLADA file that contains the object.*/
 
61
                FileId getFileId() const { return mFileId; }
 
62
 
 
63
                /** Returns true if the unique id is valid, false otherwise.*/
 
64
                bool isValid() const { return mClassId != COLLADA_TYPE::NO_TYPE; }
 
65
 
 
66
                /** Creates an ascii representation of the unique id.*/
 
67
                String toAscii() const;
 
68
 
 
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);
 
73
 
 
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;
 
78
 
 
79
                operator size_t()const;
 
80
 
 
81
        private:
 
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);
 
86
 
 
87
 
 
88
        };
 
89
 
 
90
        typedef Array<UniqueId> UniqueIdArray;
 
91
 
 
92
} // namespace COLLADAFW
 
93
 
 
94
#endif // __COLLADAFW_UNIQUEID_H__