HOPS
HOPS class reference
MHO_ClassIdentity.hh
Go to the documentation of this file.
1 #ifndef MHO_ClassIdentity_HH__
2 #define MHO_ClassIdentity_HH__
3 
5 #include "MHO_Message.hh"
7 #include "MHO_Types.hh"
8 #include "MHO_UUID.hh"
9 #include <string>
10 
11 namespace hops
12 {
13 
22 typedef uint32_t MHO_ClassVersion;
23 
28 {
29 
36  template< typename XClassType > static std::string ClassName() { return MHO_ClassName< XClassType >(); };
37 
45  template< typename XClassType > static std::string ClassName(const XClassType&)
46  {
47  return MHO_ClassName< XClassType >();
48  };
49 
57  template< typename XClassType > static MHO_UUID GetUUIDFromClass()
58  {
59  std::string name = ClassName< XClassType >();
60  return GetUUIDFromClassName(ClassName< XClassType >());
61  }
62 
70  template< typename XClassType > static MHO_UUID GetUUIDFromClass(const XClassType&)
71  {
72  std::string name = ClassName< XClassType >();
73  return GetUUIDFromClassName(ClassName< XClassType >());
74  }
75 
82  static MHO_UUID GetUUIDFromClassName(std::string name)
83  {
85  gen.Initialize();
86  gen << name;
87  gen.Finalize();
88  MHO_UUID type_uuid = gen.GetDigestAsUUID();
89  return type_uuid;
90  }
91 
99  template< typename XClassType > static void ClassVersionErrorMsg(const XClassType& obj, MHO_ClassVersion version)
100  {
101  msg_error("file", "Failed to stream object data for: " << MHO_ClassIdentity::ClassName(obj)
102  << ", version: " << version << " is not recognized." << eom);
103  };
104 };
105 
106 } // namespace hops
107 
108 #endif
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:244
Class MHO_MD5HashGenerator declares the concrete class which does the work for file streams.
Definition: MHO_MD5HashGenerator.hh:135
void Finalize()
Finalizes the MD5 hash calculation and stores the result in fDigest.
Definition: MHO_MD5HashGenerator.hh:156
MHO_UUID GetDigestAsUUID()
Getter for digest as uuid.
Definition: MHO_MD5HashGenerator.hh:182
void Initialize()
Recursive function to initialize a game state.
Definition: MHO_MD5HashGenerator.hh:144
Class MHO_UUID - a class for a 16 byte UUID (for object and type identification)
Definition: MHO_UUID.hh:27
const char version[]
Definition: difx2mark4.c:37
Definition: MHO_ChannelLabeler.hh:17
uint32_t MHO_ClassVersion
Definition: MHO_ClassIdentity.hh:22
Class MHO_ClassIdentity.
Definition: MHO_ClassIdentity.hh:28
static MHO_UUID GetUUIDFromClass()
Returns the class name as a string.
Definition: MHO_ClassIdentity.hh:57
static std::string ClassName(const XClassType &)
Returns the class name as a string.
Definition: MHO_ClassIdentity.hh:45
static MHO_UUID GetUUIDFromClassName(std::string name)
Generates a UUID from the class name.
Definition: MHO_ClassIdentity.hh:82
static MHO_UUID GetUUIDFromClass(const XClassType &)
Returns the UUID associated with a class type.
Definition: MHO_ClassIdentity.hh:70
static void ClassVersionErrorMsg(const XClassType &obj, MHO_ClassVersion version)
Generates an error message for when an unknown or unsupported class version is encountered.
Definition: MHO_ClassIdentity.hh:99
static std::string ClassName()
Returns the class name as a string.
Definition: MHO_ClassIdentity.hh:36