~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/common_cpp/Converter/DataConverters/PrimitiveConvertersJobHeader.hh

  • Committer: Christopher Hunt
  • Date: 2015-06-18 14:48:59 UTC
  • mfrom: (697.69.1 merge)
  • mto: (697.69.2 merge_hunt)
  • mto: This revision was merged to the branch mainline in revision 708.
  • Revision ID: christopher.hunt08@imperial.ac.uk-20150618144859-rki5ma1lv8722w41
Merged in latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
 
2
 *
 
3
 * MAUS is free software: you can redistribute it and/or modify
 
4
 * it under the terms of the GNU General Public License as published by
 
5
 * the Free Software Foundation, either version 3 of the License, or
 
6
 * (at your option) any later version.
 
7
 *
 
8
 * MAUS is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with MAUS.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
 
 
18
#ifndef SRC_COMMON_CPP_CONVERTERS_DATACONVERTERS_PRIMITIVECONVERTERSJH_H
 
19
#define SRC_COMMON_CPP_CONVERTERS_DATACONVERTERS_PRIMITIVECONVERTERSJH_H
 
20
#include <string>
 
21
 
 
22
#include "src/common_cpp/Converter/DataConverters/JsonCppJobHeaderConverter.hh"
 
23
#include "src/common_cpp/Converter/DataConverters/CppJsonJobHeaderConverter.hh"
 
24
 
 
25
namespace MAUS {
 
26
class JobHeaderData;
 
27
 
 
28
/////////////////////////// X TO JobHeaderData ////////////////////////////
 
29
 
 
30
 
 
31
class StringJobHeaderConverter : public ConverterBase<std::string, JobHeaderData> {
 
32
  public:
 
33
    StringJobHeaderConverter()
 
34
      : ConverterBase<std::string, JobHeaderData>("StringDataConverter") {}
 
35
 
 
36
  private:
 
37
    JobHeaderData* _convert(const std::string* str) const {
 
38
        Json::Value* json = StringJsonConverter().convert(str);
 
39
        JobHeaderData* jh = JsonCppJobHeaderConverter().convert(json);
 
40
        delete json;
 
41
        return jh;
 
42
    }
 
43
};
 
44
 
 
45
class PyDictJobHeaderConverter : public ConverterBase<PyObject, JobHeaderData> {
 
46
  public:
 
47
    PyDictJobHeaderConverter()
 
48
      : ConverterBase<PyObject, JobHeaderData>("PyDictJobHeaderConverter") {}
 
49
 
 
50
  private:
 
51
    JobHeaderData* _convert(const PyObject* obj) const {
 
52
        std::string* str = PyDictStringConverter().convert(obj);
 
53
        JobHeaderData* jh = StringJobHeaderConverter().convert(str);
 
54
        delete str;
 
55
        return jh;
 
56
    }
 
57
};
 
58
 
 
59
 
 
60
/////////////////////////// JobHeaderData TO X ////////////////////////////
 
61
 
 
62
class JobHeaderStringConverter : public ConverterBase<JobHeaderData, std::string> {
 
63
  public:
 
64
    JobHeaderStringConverter()
 
65
      : ConverterBase<JobHeaderData, std::string>("JobHeaderStringConverter") {}
 
66
 
 
67
  private:
 
68
    std::string* _convert(const JobHeaderData* jh) const {
 
69
        Json::Value* json = CppJsonJobHeaderConverter().convert(jh);
 
70
        std::string* str = JsonStringConverter().convert(json);
 
71
        delete json;
 
72
        return str;
 
73
    }
 
74
};
 
75
 
 
76
class JobHeaderJobHeaderConverter : public ConverterBase<JobHeaderData, JobHeaderData> {
 
77
  public:
 
78
    JobHeaderJobHeaderConverter()
 
79
      : ConverterBase<JobHeaderData, JobHeaderData>("JobHeaderJobHeaderConverter") {}
 
80
 
 
81
  private:
 
82
    JobHeaderData* _convert(const JobHeaderData* jh) const {
 
83
        return new JobHeaderData(*jh);
 
84
    }
 
85
};
 
86
 
 
87
class JobHeaderPyDictConverter : public ConverterBase<JobHeaderData, PyObject> {
 
88
  public:
 
89
    JobHeaderPyDictConverter()
 
90
      : ConverterBase<JobHeaderData, PyObject>("JobHeaderPyDictConverter") {}
 
91
 
 
92
  private:
 
93
    PyObject* _convert(const JobHeaderData* jh) const {
 
94
        std::string* str = JobHeaderStringConverter().convert(jh);
 
95
        PyObject* obj = StringPyDictConverter().convert(str);
 
96
        delete str;
 
97
        return obj;
 
98
    }
 
99
};
 
100
}
 
101
#endif //  SRC_COMMON_CPP_CONVERTERS_DATACONVERTERS_PRIMITIVECONVERTERSJH_H
 
102
 
 
103