Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Attributes
omni::TypeIdMemory< INTERFACE > Class Template Reference

Helper class to store objects with a certain type id in QBuffer Used in GUI for storing previously selected mapping or canvas types. More...

#include <TypeIdMemory.h>

Collaboration diagram for omni::TypeIdMemory< INTERFACE >:
Collaboration graph
[legend]

Public Types

typedef INTERFACE interface_type
 Our interface type. More...
 

Public Member Functions

void clear ()
 Clear memory. More...
 
void store (interface_type const *_t)
 Store object with interface in memory. More...
 
void restore (interface_type *_t) const
 Restore object with interface in memory, if exists. More...
 

Private Attributes

std::map< Id, QByteArray > memory_
 

Detailed Description

template<typename INTERFACE>
class omni::TypeIdMemory< INTERFACE >

Helper class to store objects with a certain type id in QBuffer Used in GUI for storing previously selected mapping or canvas types.

Member Typedef Documentation

template<typename INTERFACE>
typedef INTERFACE omni::TypeIdMemory< INTERFACE >::interface_type

Our interface type.

Member Function Documentation

template<typename INTERFACE>
void omni::TypeIdMemory< INTERFACE >::clear ( )
inline

Clear memory.

39  {
40  memory_.clear();
41  }
std::map< Id, QByteArray > memory_
Definition: TypeIdMemory.h:68
template<typename INTERFACE>
void omni::TypeIdMemory< INTERFACE >::restore ( interface_type _t) const
inline

Restore object with interface in memory, if exists.

No exception is thrown

Deserialize from QByteArray

56  {
57  auto _id = _t->getTypeId();
58 
59  /// No exception is thrown
60  if (memory_.count(_id) == 0) return;
61 
62  /// Deserialize from QByteArray
63  QDataStream _s(memory_.at(_id));
64  _t->fromStream(_s);
65  }
std::map< Id, QByteArray > memory_
Definition: TypeIdMemory.h:68
template<typename INTERFACE>
void omni::TypeIdMemory< INTERFACE >::store ( interface_type const *  _t)
inline

Store object with interface in memory.

Serialize to QByteArray

44  {
45  auto _id = _t->getTypeId();
46 
47  QBuffer _buf;
48  /// Serialize to QByteArray
49  _buf.open(QIODevice::WriteOnly);
50  QDataStream _s(&_buf);
51  _t->toStream(_s);
52  memory_[_id] = _buf.data();
53  }
std::map< Id, QByteArray > memory_
Definition: TypeIdMemory.h:68

Field Documentation

template<typename INTERFACE>
std::map<Id, QByteArray> omni::TypeIdMemory< INTERFACE >::memory_
private

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