-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathModel.cpp
More file actions
59 lines (48 loc) · 1.53 KB
/
Model.cpp
File metadata and controls
59 lines (48 loc) · 1.53 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
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#include <algorithm>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/lexical_cast.hpp>
#include "utils/fun_wrappers.hpp"
#include "SpeciesType.hpp"
#include "NetworkRules.hpp"
#include "BasicNetworkRulesImpl.hpp"
#include "Model.hpp"
Model::Model(): network_rules_(new BasicNetworkRulesImpl())
{
}
Model::~Model()
{
}
void Model::add_species_type(boost::shared_ptr<species_type_type> const& species)
{
species->bind_to_model(this, species_type_id_generator_());
species_type_map_.insert(std::make_pair(species->id(), species));
}
boost::shared_ptr<Model::species_type_type> Model::get_species_type_by_id(species_id_type const& id) const
{
species_type_map_type::const_iterator i(species_type_map_.find(id));
if (species_type_map_.end() == i)
{
throw not_found(boost::lexical_cast<std::string>(id));
}
return (*i).second;
}
Model::species_type_range Model::get_species_types() const
{
return species_type_range(
species_type_iterator(species_type_map_.begin(), species_second_selector_type()),
species_type_iterator(species_type_map_.end(), species_second_selector_type()));
}
std::string const& Model::operator[](std::string const& name) const
{
string_map_type::const_iterator i(attrs_.find(name));
if (i == attrs_.end())
throw not_found((boost::format("key %s not found") % name).str());
return (*i).second;
}
std::string& Model::operator[](std::string const& name)
{
return attrs_[name];
}