template class DataPack

Overview

Base datapack class. More…

#include <datapack.h>

template <class DATA_TYPE>
class DataPack: public DataPackInterface {
public:
    // construction

    DataPack(
        const std::string& name,
        const std::string& engineName,
        DATA_TYPE* data_
    );

    DataPack(const std::string& name, const std::string& engineName);
    DataPack(const DataPack&);
    DataPack(DataPack&& obj);

    // methods

    DataPack& operator = (const DataPack&);
    DataPack& operator = (DataPack&&);
    const DATA_TYPE& getData() const;
    PyObject* toPythonString();
    virtual DataPackInterface* clone() const;
    static std::string getType();

    static DataPackIdentifier createID(
        const std::string& name,
        const std::string& engineName
    );

    static void create_python(const std::string& name);
};

// direct descendants

template <class DATA_TYPE>
class RawData;

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<T> shared_ptr;
    typedef std::shared_ptr<const T> const_shared_ptr;
    typedef std::unique_ptr<T> unique_ptr;
    typedef std::unique_ptr<const T> const_unique_ptr;

    // methods

    DataPackInterface& operator = (const DataPackInterface&);
    DataPackInterface& operator = (DataPackInterface&&);
    const std::string& name() const;
    void setName(const std::string& name);
    const std::string& type() const;
    void setType(const std::string& type);
    const std::string& engineName() const;
    void setEngineName(const std::string& engineName);
    const DataPackIdentifier& id() const;
    void setID(const DataPackIdentifier& id);
    virtual DataPackInterface* clone() const;
    bool isEmpty() const;
    bool isUpdated() const;
    void resetIsUpdated() const;

Detailed Documentation

Base datapack class.

The class must be specialized by providing a template argument. The argument defines what data class will be stored in the datapack objects.

Methods

const DATA_TYPE& getData() const

Returns reference to data stored in the object.

The function returns a read-only reference to the data stored by the object. This is the main accessor function of the DataPack object.

Returns:

Read-only reference to the data stored by the object

PyObject* toPythonString()

Returns a python string representation of this object content.

Returns:

Python string

virtual DataPackInterface* clone() const

Virtual clone method to support polymorphic copy.

static std::string getType()

Returns type of the datapack class.

The function returns type of the datapack class as string. The return value is not human readable. It’s an implementation-defined name of the DATA_TYPE used by the datapack.

static DataPackIdentifier createID(
    const std::string& name,
    const std::string& engineName
)

Creates a DataPackIdentifier object with type matching the DATA_TYPE used by the DataPack class.

Parameters:

name

Name of the datapack

name

Name of the engine to which the datapack belongs

Returns:

A DataPackIdentifier object, with DataPackIdentifier::Name and DataPackIdentifier::EngineName provided as arguments, and with DataPackIdentifier::Type deduced from DATA_TYPE template argument of the DataPack class.