Skip to content
Hans Kirchner edited this page Dec 9, 2015 · 10 revisions

The DataManager manages data channel initialization and modules trying to access them.

Modules don't access the DataManager directly, instead call the corresponding methods defined in lms::Module.

Accessing data channels

For accessing data channels the following methods are available:

template<typename T>
ReadDataChannel<T> readChannel(const std::string &name);

template<typename T>
WriteDataChannel<T> writeChannel(const std::string &name);
  • Both access methods return a data channel wrapper type with overloaded operator * and operator -> for easy transitioning from the old system when usual T* were returned.
  • ReadDataChannel allows only const methods and read-only access on all attributes.
  • The requested type can be a supertype of the actual object lying in inside the data channel. The internal object will be casted accordingly.
  • Data channel classes should have a default constructor and should be non-abstract if they are not used as a supertype.
  • If the data channel's type is not known at compile-time,lms::Any can be used for the template parameter T.
  • The access methods are usually called in initialize() but can be used in cycle() as well.

Channel mapping

Channel mapping allows for better reusing of existing modules. Instead of changing the module's source code and recompiling it, channels can be renamed to another channel in the config files. This can be done with <channelMapping> inside the <module> tag:

<module>
  <name>image_loader</name>
  <channelMapping from="IMAGE" to="GREY_IMAGE" />
</module>

If the module requests the data channel IMAGE it will get GREY_IMAGE instead. This mapping is transparent. That means the module's source can stay as-is and the module cannot find out if a request was redirected.

Serialize data channels

Serialization of data channels requires two steps:

  1. Access channel with type lms::Any.
  2. Serialize or deserialize the channel in to a stream.
// Serialization
ReadDataChannel<lms::Any> ch = readChannel<lms::Any>("CHANNEL");

ch.serialize(outFile);

// Deserialization
WriteDataChannel<lms::Any> ch = writeChannel<lms::Any>("CHANNEL");

ch.deserialize(inFile);
  • Only data channels implementing the lms::Serializable interface can be serialized.