INET Framework for OMNeT++/OMNEST
inet::serializer::SerializerRegistrationList Class Reference

#include <SerializerBase.h>

Inheritance diagram for inet::serializer::SerializerRegistrationList:

Public Member Functions

 SerializerRegistrationList (const char *name)
 
virtual ~SerializerRegistrationList ()
 
virtual void clear ()
 
virtual void add (const char *name, int protocolGroup, int protocolId, SerializerBase *obj)
 Adds an object to the container. More...
 
virtual SerializerBaselookup (int protocolGroup, int protocolId) const
 Returns the object with exactly the given group ID and protocol ID. More...
 
virtual SerializerBaselookup (const char *name) const
 Returns the object with exactly the given name. More...
 

Static Public Attributes

static DefaultSerializer defaultSerializer
 
static ByteArraySerializer byteArraySerializer
 

Protected Types

typedef std::pair< int, int > Key
 
typedef std::map< Key, SerializerBase * > KeyToSerializerMap
 
typedef std::map< std::string, SerializerBase * > StringToSerializerMap
 

Protected Attributes

KeyToSerializerMap keyToSerializerMap
 
StringToSerializerMap stringToSerializerMap
 

Member Typedef Documentation

typedef std::pair<int, int> inet::serializer::SerializerRegistrationList::Key
protected

Constructor & Destructor Documentation

inet::serializer::SerializerRegistrationList::SerializerRegistrationList ( const char *  name)
inline
123 : cNamedObject(name, false) {}
inet::serializer::SerializerRegistrationList::~SerializerRegistrationList ( )
virtual
161 {
162  if (!stringToSerializerMap.empty())
163  throw cRuntimeError("SerializerRegistrationList not empty, should call the SerializerRegistrationList::clear() function");
164 }
StringToSerializerMap stringToSerializerMap
Definition: SerializerBase.h:120

Member Function Documentation

void inet::serializer::SerializerRegistrationList::add ( const char *  name,
int  protocolGroup,
int  protocolId,
SerializerBase obj 
)
virtual

Adds an object to the container.

176 {
177  Key key(protocolGroup, protocolId);
178 
179  take(obj);
180  if (protocolGroup != UNKNOWN)
181  keyToSerializerMap.insert(std::pair<Key,SerializerBase*>(key, obj));
182  if (!name)
183  throw cRuntimeError("missing 'name' of registered serializer");
184  stringToSerializerMap.insert(std::pair<std::string,SerializerBase*>(name, obj));
185 }
Definition: SerializerBase.h:36
std::pair< int, int > Key
Definition: SerializerBase.h:116
StringToSerializerMap stringToSerializerMap
Definition: SerializerBase.h:120
KeyToSerializerMap keyToSerializerMap
Definition: SerializerBase.h:119
void inet::serializer::SerializerRegistrationList::clear ( )
virtual
167 {
168  for (auto elem : stringToSerializerMap) {
169  dropAndDelete(elem.second);
170  }
171  stringToSerializerMap.clear();
172  keyToSerializerMap.clear();
173 }
StringToSerializerMap stringToSerializerMap
Definition: SerializerBase.h:120
KeyToSerializerMap keyToSerializerMap
Definition: SerializerBase.h:119
SerializerBase * inet::serializer::SerializerRegistrationList::lookup ( int  protocolGroup,
int  protocolId 
) const
virtual

Returns the object with exactly the given group ID and protocol ID.

Returns NULL if not found.

Referenced by inet::serializer::SerializerBase::lookupDeserializer(), and inet::serializer::SerializerBase::lookupSerializer().

188 {
189  auto it = keyToSerializerMap.find(Key(protocolGroup, protocolId));
190  return it==keyToSerializerMap.end() ? nullptr : it->second;
191 }
std::pair< int, int > Key
Definition: SerializerBase.h:116
KeyToSerializerMap keyToSerializerMap
Definition: SerializerBase.h:119
SerializerBase * inet::serializer::SerializerRegistrationList::lookup ( const char *  name) const
virtual

Returns the object with exactly the given name.

Returns NULL if not found.

194 {
195  auto it = stringToSerializerMap.find(name);
196  return it==stringToSerializerMap.end() ? nullptr : it->second;
197 }
StringToSerializerMap stringToSerializerMap
Definition: SerializerBase.h:120

Member Data Documentation

DefaultSerializer inet::serializer::SerializerRegistrationList::defaultSerializer
static
KeyToSerializerMap inet::serializer::SerializerRegistrationList::keyToSerializerMap
protected
StringToSerializerMap inet::serializer::SerializerRegistrationList::stringToSerializerMap
protected

The documentation for this class was generated from the following files: