24.2. Data Objects

A data object is a C++ object, implemented by the class Massiv::Core::DataObject, which provides an interface needed to handle the data. A programmer needs to know a name of the data object he wants to use. To obtain the data object, call DataManager::get_data_object() method. The DataObject object has an attribute data, which is inherited from the class std::ifstream and can be use to read the relevant data from a stream using the stadard C++ interface.

The following example shows how to get texture data (represented by an image file).

DataManager &   data_manager    = Global::data_manager();
DataObject *    warrior_texture = data_manager.get_data_object( "warrior_texture" );
warrior_texture->open();
  // read data from attribute warrior_texture->data
  // using the data member
warrior_texture->close();

The point is that the programmer doesn't need to know what data will be contained in the data object. All he must know is just the data object name.