Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EntityId.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright Saab AB, 2008-2013 (http://safir.sourceforge.net)
4 *
5 * Created by: Lars Hagström / stlrha
6 *
7 *******************************************************************************
8 *
9 * This file is part of Safir SDK Core.
10 *
11 * Safir SDK Core is free software: you can redistribute it and/or modify
12 * it under the terms of version 3 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * Safir SDK Core is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22 *
23 ******************************************************************************/
24 
25 #ifndef __DOTS_ENTITY_ID_H__
26 #define __DOTS_ENTITY_ID_H__
27 
30 
31 namespace Safir
32 {
33 namespace Dob
34 {
35 namespace Typesystem
36 {
41  class EntityId
42  {
43  public:
47  EntityId(): m_typeId(0),m_instanceId() {}
48 
57  const Dob::Typesystem::InstanceId instanceId)
58  : m_typeId(typeId),m_instanceId(instanceId) {}
59 
60 
69  void RemoveString() {m_instanceId.RemoveString();}
70 
71 
77  const Dob::Typesystem::InstanceId & GetInstanceId() const {return m_instanceId;}
78 
84  void SetInstanceId(const Dob::Typesystem::InstanceId & instanceId) {m_instanceId = instanceId;}
85 
91  Dob::Typesystem::TypeId GetTypeId() const {return m_typeId;}
92 
98  void SetTypeId(const Dob::Typesystem::TypeId typeId) {m_typeId = typeId;}
99 
106  bool operator ==(const EntityId & other) const
107  {
108  return m_typeId == other.m_typeId && m_instanceId == other.m_instanceId;
109  }
110 
117  bool operator !=(const EntityId & other) const
118  {
119  return !(*this==other);
120  }
121 
129  bool operator < (const EntityId & other) const
130  {
131  if (m_typeId == other.m_typeId)
132  {
133  return m_instanceId < other.m_instanceId;
134  }
135  else
136  {
137  return m_typeId < other.m_typeId;
138  }
139  }
140 
156  DOTS_CPP_API const std::wstring ToString() const;
157 
167  DOTS_CPP_API const std::wstring ToStringNumeric() const;
168  private:
169 
170  Dob::Typesystem::TypeId m_typeId;
171  Dob::Typesystem::InstanceId m_instanceId;
172  };
173 
174  static inline std::wostream & operator << (std::wostream & out, const EntityId & entityId)
175  {return out << entityId.ToString();}
176 }
177 }
178 }
179 #endif
180 
Class containing the identity of an entity.
Definition: EntityId.h:41
DOTS_CPP_API const std::wstring ToStringNumeric() const
Convert an entity id to a string that has only numeric parts.
void SetInstanceId(const Dob::Typesystem::InstanceId &instanceId)
Set the instance number of the EntityId.
Definition: EntityId.h:84
Class containing the identity of an instance.
Definition: InstanceId.h:47
DOTS_CPP_API const std::wstring ToString() const
Convert an entity id to a string.
void RemoveString()
Remove the included string from the instance id.
Definition: InstanceId.h:116
DotsC_TypeId TypeId
A unique type identifier.
Definition: Defs.h:219
const Dob::Typesystem::InstanceId & GetInstanceId() const
Get the Instance number out of the EntityId.
Definition: EntityId.h:77
EntityId()
Default constructor.
Definition: EntityId.h:47
Dob::Typesystem::TypeId GetTypeId() const
Get the type id out of the EntityId.
Definition: EntityId.h:91
bool operator==(const EntityId &other) const
Equality operator.
Definition: EntityId.h:106
void SetTypeId(const Dob::Typesystem::TypeId typeId)
Set the type id of the EntityId.
Definition: EntityId.h:98
bool operator<(const EntityId &other) const
Less-than operator.
Definition: EntityId.h:129
bool operator!=(const EntityId &other) const
Inequality operator.
Definition: EntityId.h:117
EntityId(const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::InstanceId instanceId)
Constructor with type id and instance arguments.
Definition: EntityId.h:56
static std::wostream & operator<<(std::wostream &out, const ChannelId &channelId)
Definition: ChannelId.h:223
void RemoveString()
Remove the included string from the instance id of the entity id.
Definition: EntityId.h:69
#define DOTS_CPP_API
Definition: Defs.h:33