-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathParticleModel.cpp
More file actions
51 lines (42 loc) · 1.48 KB
/
ParticleModel.cpp
File metadata and controls
51 lines (42 loc) · 1.48 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
#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 "ParticleModel.hpp"
ParticleModel::ParticleModel()
{
}
ParticleModel::~ParticleModel()
{
}
void ParticleModel::add_structure_type(boost::shared_ptr<structure_type_type> const& structure)
{
std::pair<structure_type_map_type::iterator, bool> r(
structure_type_map_.insert(std::make_pair(structure->id(), structure)));
if (!r.second)
{
throw already_exists(
(boost::format("structure id \"%s\" is already used by %s") %
structure->id() %
boost::lexical_cast<std::string>(*(*(r.first)).second)).str());
}
structure->bind_to_model(this, structure->id());
}
boost::shared_ptr<ParticleModel::structure_type_type> ParticleModel::get_structure_type_by_id(structure_id_type const& id) const
{
structure_type_map_type::const_iterator i(structure_type_map_.find(id));
if (structure_type_map_.end() == i)
{
throw not_found(boost::lexical_cast<std::string>(id));
}
return (*i).second;
}
ParticleModel::structure_type_range ParticleModel::get_structure_types() const
{
return structure_type_range(
structure_type_iterator(structure_type_map_.begin(), structure_second_selector_type()),
structure_type_iterator(structure_type_map_.end(), structure_second_selector_type()));
}