/
Model.hxx
102 lines (82 loc) · 3.81 KB
/
Model.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2014-2014 - Scilab Enterprises - Clement DAVID
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
*
*/
#ifndef MODEL_HXX_
#define MODEL_HXX_
#include <vector>
#include <unordered_map>
#include <string>
#include "utilities.hxx"
#include "model/BaseObject.hxx"
#include "dynlib_scicos.h"
namespace org_scilab_modules_scicos
{
class SCICOS_IMPEXP Model
{
public:
Model();
~Model();
/*
* Controller wrapped methods
*/
ScicosID createObject(kind_t k);
unsigned referenceObject(const ScicosID uid);
unsigned& referenceCount(ScicosID uid);
void deleteObject(ScicosID uid);
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, double& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, int& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, bool& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::string& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, ScicosID& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector<double>& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector<int>& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector<bool>& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector< std::string >& v) const;
bool getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector<ScicosID>& v) const;
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, double v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, int v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, bool v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, ScicosID v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::string v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector<double>& v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector<int>& v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector<bool>& v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector< std::string >& v);
update_status_t setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector<ScicosID>& v);
/*
* Model custom methods
*/
kind_t getKind(ScicosID uid) const;
std::vector<ScicosID> getAll(kind_t k) const;
model::BaseObject* getObject(ScicosID uid) const;
template<typename T>
T* getObject(ScicosID uid) const
{
return static_cast<T*>(getObject(uid));
};
model::Datatype* flyweight(const model::Datatype& d);
void erase(model::Datatype* d);
private:
ScicosID lastId;
bool has_looped;
struct ModelObject
{
ModelObject(model::BaseObject* o) : m_o(o), m_refCounter(0) {}
model::BaseObject* m_o;
unsigned m_refCounter;
};
typedef std::unordered_map<ScicosID, ModelObject > objects_map_t;
objects_map_t allObjects;
typedef std::vector<model::Datatype*> datatypes_set_t;
datatypes_set_t datatypes;
};
} /* namespace org_scilab_modules_scicos */
#endif /* MODEL_HXX_ */