CORGI
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
entity.h
Go to the documentation of this file.
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef CORGI_ENTITY_H_
16 #define CORGI_ENTITY_H_
17 
18 #include "corgi/entity_common.h"
19 
20 namespace corgi {
21 
22 /// @file
23 /// @addtogroup corgi_entity
24 /// @{
25 ///
26 /// @class Entity
27 ///
28 /// @brief The basic Entity class for CORGI. It contains an array
29 /// of index values, which are used by Components for tracking their data
30 /// associated with an Entity. It also contains a boolean for tracking if
31 /// this Entity has been marked for deletion.
32 class Entity {
33  public:
34  /// @brief Constructor for creating an Entity.
35  Entity() : entity_id_(kInvalidEntityId), marked_for_deletion_(false) {}
36 
37  /// @brief An accessor function to check if this Entity has been
38  /// marked for deletion.
39  ///
40  /// @return Returns a bool indicating whether or not this Entity
41  /// is marked for deletion.
42  bool marked_for_deletion() const { return marked_for_deletion_; }
43 
44  /// @brief A mutator function to set an Entity as marked for deletion.
45  ///
46  /// @param[in] marked_for_deletion A bool corresponding to whether the Entity
47  /// should be marked for deletion or not.
49  marked_for_deletion_ = marked_for_deletion;
50  }
51 
52 
53  /// @brief Returns the unique entity id that represents this entity. Should
54  /// generally only be used by internal CORGI functions. Users of the library
55  /// should usually refer to entities as EntityRefs.
56  EntityIdType entity_id() const { return entity_id_; }
57 
58  /// @brief Sets an entity's unique ID.
59  ///
60  /// Normally only used internally by the entitymanager for bookkeeping.
62 
63  private:
64  EntityIdType entity_id_;
65  bool marked_for_deletion_;
66 };
67 /// @}
68 
69 } // corgi
70 
71 #endif // CORGI_ENTITY_H_
void set_entity_id(EntityIdType entity_id)
Sets an entity's unique ID.
Definition: entity.h:61
uint16_t EntityIdType
A EntityIdType is a value used to uniquely represent an entity in various internal structures...
Definition: entity_common.h:77
EntityIdType entity_id() const
Returns the unique entity id that represents this entity. Should generally only be used by internal C...
Definition: entity.h:56
The basic Entity class for CORGI. It contains an array of index values, which are used by Components ...
Definition: entity.h:32
static const EntityIdType kInvalidEntityId
A sentinel value to represent an invalid entity.
Definition: entity_common.h:86
Entity()
Constructor for creating an Entity.
Definition: entity.h:35
bool marked_for_deletion() const
An accessor function to check if this Entity has been marked for deletion.
Definition: entity.h:42
void set_marked_for_deletion(bool marked_for_deletion)
A mutator function to set an Entity as marked for deletion.
Definition: entity.h:48