Program Listing for File ModelData.h

Return to documentation for file (include/flamegpu/model/ModelData.h)

#ifndef INCLUDE_FLAMEGPU_MODEL_MODELDATA_H_
#define INCLUDE_FLAMEGPU_MODEL_MODELDATA_H_

#include <unordered_map>
#include <list>
#include <memory>
#include <typeindex>
#include <vector>
#include <string>

#include "flamegpu/defines.h"
#include "flamegpu/runtime/HostAPI_macros.h"
#include "flamegpu/runtime/messaging/MessageBruteForce.h"

namespace flamegpu {

class HostFunctionCallback;
class HostConditionCallback;
class DependencyGraph;
struct EnvironmentData;
struct AgentData;
struct LayerData;
struct SubModelData;

struct ModelData : std::enable_shared_from_this<ModelData>{
    virtual ~ModelData() = default;
    static const char *DEFAULT_STATE;  // "default"
    friend class ModelDescription;
    typedef std::unordered_map<std::string, std::shared_ptr<AgentData>> AgentMap;
    typedef std::unordered_map<std::string, std::shared_ptr<MessageBruteForce::Data>> MessageMap;
    typedef std::unordered_map<std::string, std::shared_ptr<SubModelData>> SubModelMap;
    typedef std::list<std::shared_ptr<LayerData>> LayerList;
    typedef std::vector<FLAMEGPU_INIT_FUNCTION_POINTER> InitFunctionVector;
    typedef std::vector<FLAMEGPU_STEP_FUNCTION_POINTER> StepFunctionVector;
    typedef std::vector<HostFunctionCallback*> HostFunctionCallbackVector;
    typedef std::vector<HostConditionCallback*> HostConditionCallbackVector;
    typedef std::vector<FLAMEGPU_EXIT_FUNCTION_POINTER> ExitFunctionVector;
    typedef std::vector<FLAMEGPU_EXIT_CONDITION_POINTER> ExitConditionVector;

    AgentMap agents;
    MessageMap messages;
    SubModelMap submodels;
    LayerList layers;
    InitFunctionVector initFunctions;
    HostFunctionCallbackVector initFunctionCallbacks;
    StepFunctionVector stepFunctions;
    HostFunctionCallbackVector stepFunctionCallbacks;
    ExitFunctionVector exitFunctions;
    HostFunctionCallbackVector exitFunctionCallbacks;
    ExitConditionVector exitConditions;
    HostConditionCallbackVector exitConditionCallbacks;
    std::shared_ptr<EnvironmentData> environment;
    std::string name;
    std::shared_ptr<DependencyGraph> dependencyGraph;
    std::shared_ptr<ModelData> clone() const;
    bool operator==(const ModelData& rhs) const;
    bool operator!=(const ModelData& rhs) const;

    flamegpu::size_type getMaxLayerWidth() const;

 protected:
    friend SubModelData;  // Uses private copy constructor
    explicit ModelData(const ModelData &other);
    explicit ModelData(const std::string &model_name);

 private:
    bool hasSubModelRecursive(const std::shared_ptr<const ModelData> &submodel_data) const;
};

}  // namespace flamegpu

#endif  // INCLUDE_FLAMEGPU_MODEL_MODELDATA_H_