forked from ecell/epdp
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathModel.hpp
More file actions
83 lines (63 loc) · 2.94 KB
/
Model.hpp
File metadata and controls
83 lines (63 loc) · 2.94 KB
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
#ifndef MODEL_HPP
#define MODEL_HPP
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/range/iterator_range.hpp>
#include <map>
#include "SerialIDGenerator.hpp"
#include "SpeciesTypeID.hpp"
#include "SpeciesType.hpp"
#include "utils/get_mapper_mf.hpp"
#include "utils/pair.hpp"
class NetworkRules;
class Model: private boost::noncopyable
{
public:
typedef SpeciesType species_type_type;
typedef species_type_type::identifier_type species_id_type;
private:
typedef SerialIDGenerator<species_id_type> species_type_id_generator_type;
typedef std::map<species_id_type, boost::shared_ptr<species_type_type> > species_type_map_type;
typedef select_second<species_type_map_type::value_type> species_second_selector_type;
typedef get_mapper_mf<std::string, std::string>::type string_map_type;
public:
typedef boost::transform_iterator<species_second_selector_type,
species_type_map_type::const_iterator> species_type_iterator;
typedef boost::iterator_range<species_type_iterator> species_type_range;
typedef NetworkRules network_rules_type;
typedef string_map_type::const_iterator string_map_iterator;
typedef boost::iterator_range<string_map_iterator> attributes_range;
public:
// The model class is more or less an implementation of the network rules
// The network rules define the possible reactions between species.
// Constructor
Model();
virtual ~Model();
NetworkRules& network_rules() const
{
return *network_rules_;
}
// Add a species to the model
void add_species_type(boost::shared_ptr<species_type_type> const& species);
// Get a species by the species 'id'
boost::shared_ptr<species_type_type> get_species_type_by_id(species_id_type const& id) const;
// Get all the species in the model
species_type_range get_species_types() const;
std::string const& operator[](std::string const& name) const;
std::string& operator[](std::string const& name);
// Not sure. Get attribute by name?
// Get all the attributes
attributes_range attributes() const
{
return attributes_range(attrs_.begin(), attrs_.end());
}
//////// Member variables (why are they public?)
public:
species_type_id_generator_type species_type_id_generator_; // The id generator which makes sure that all species have a unique id
species_type_map_type species_type_map_; // mapping: species_type_id->species_type
boost::scoped_ptr<NetworkRules> network_rules_; // The network rules in the model
string_map_type attrs_; // All the attributes
};
#endif /* MODEL_HPP */