CombiningParticlePotentialParsing
Line | |
---|
1 | /*
|
---|
2 | * RegistrySerializer.hpp
|
---|
3 | *
|
---|
4 | * Created on: 09.05.2013
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef REGISTRYSERIALIZER_HPP_
|
---|
9 | #define REGISTRYSERIALIZER_HPP_
|
---|
10 |
|
---|
11 | // include config.h
|
---|
12 | #ifdef HAVE_CONFIG_H
|
---|
13 | #include <config.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #include <iosfwd>
|
---|
17 |
|
---|
18 | #include "CodePatterns/Registry.hpp"
|
---|
19 |
|
---|
20 | class EmpiricalPotential;
|
---|
21 | class Particle;
|
---|
22 |
|
---|
23 | /** This template class can serialize items contained in a general Registry
|
---|
24 | * that contain function stream_to().
|
---|
25 | */
|
---|
26 | template <class T>
|
---|
27 | class RegistrySerializer
|
---|
28 | {
|
---|
29 | public:
|
---|
30 | /** Constructor for class RegistrySerializer.
|
---|
31 | *
|
---|
32 | * \param _to_serialize stream to serialize to
|
---|
33 | * \param _instance registry instance to serialize
|
---|
34 | * \param _name optional name for debugging
|
---|
35 | */
|
---|
36 | RegistrySerializer(
|
---|
37 | std::ostream &_to_serialize,
|
---|
38 | Registry<T> &_instance,
|
---|
39 | const std::string _name = "item") :
|
---|
40 | to_serialize(_to_serialize),
|
---|
41 | instance(_instance),
|
---|
42 | name(_name)
|
---|
43 | {}
|
---|
44 |
|
---|
45 | /** Destructor for class RegistrySerializer.
|
---|
46 | *
|
---|
47 | */
|
---|
48 | ~RegistrySerializer()
|
---|
49 | {}
|
---|
50 |
|
---|
51 | /** Function to stream all potentials present in PotentialRegistry to
|
---|
52 | * internally stored stream.
|
---|
53 | *
|
---|
54 | */
|
---|
55 | void operator()();
|
---|
56 |
|
---|
57 | private:
|
---|
58 | std::ostream &to_serialize;
|
---|
59 | const Registry<T> &instance;
|
---|
60 | const std::string name;
|
---|
61 | };
|
---|
62 |
|
---|
63 | #include "RegistrySerializer_impl.hpp"
|
---|
64 |
|
---|
65 | template <>
|
---|
66 | void RegistrySerializer<EmpiricalPotential>::operator()();
|
---|
67 |
|
---|
68 | template <>
|
---|
69 | void RegistrySerializer<Particle>::operator()();
|
---|
70 |
|
---|
71 | #endif /* REGISTRYSERIALIZER_HPP_ */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.