Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDOMToPMTMaskMap.hh
Go to the documentation of this file.
1#ifndef __JTRIGGER__JDOMTOPMTMASKMAP__
2#define __JTRIGGER__JDOMTOPMTMASKMAP__
3
4#include <istream>
5#include <ostream>
6#include <map>
7
10#include "JLang/JException.hh"
11#include "JIO/JSerialisable.hh"
12
13/**
14 * \author rbruijn
15 */
16
17namespace JTRIGGER {}
18namespace JPP { using namespace JTRIGGER; }
19
20namespace JTRIGGER {
21
25 using JIO::JReader;
26 using JIO::JWriter;
28
30 public std::map<JModuleIdentifier, JPMTMask>,
32 {
33 public:
34
39
41 {
42 return at(id);
43 }
44
45
46 friend inline std::istream& operator>>(std::istream& in, JDOMToPMTMaskMap& masks)
47 {
48 masks.clear();
49
50 unsigned int n;
51
52 if(in >> n) {
53
55 JPMTMask mask;
56
57 for(; n !=0 && in; --n) {
58
59 in >> id >>mask;
60
61 if(!(masks.insert(std::make_pair(id,mask))).second) {
62 throw JException("Key already exists in map.");
63 }
64 }
65 }
66
67 return in;
68 }
69
70 friend inline std::ostream& operator<<(std::ostream& out, const JDOMToPMTMaskMap& masks)
71 {
72 using namespace std;
73
74 out << masks.size();
75 out << endl;
76
78 dommask!=masks.end();++dommask)
79 {
80 out << dommask->first << ' ' << dommask->second << endl;
81
82 }
83 return out;
84 }
85
86 virtual JReader& read(JReader & in) override
87 {
88 clear();
89
90 unsigned int n;
91
92 if(in >> n) {
93
95 JPMTMask mask;
96
97 for(; n !=0 && in; --n) {
98
99 in >> id >>mask;
100
101 if(!(insert(std::make_pair(id,mask))).second) {
102 throw JException("Key already exists in map.");
103 }
104 }
105 }
106
107 return in;
108 }
109
110
111 virtual JWriter& write(JWriter& out) const override
112 {
113 using namespace std;
114
115 unsigned int n = size();
116
117 out << n;
118
120 dommask!=this->end(); ++dommask )
121 {
122 out << dommask->first
123 << dommask->second;
124
125 }
126 return out;
127 }
128
129
130 // ClassDef(JDOMToPMTMaskMap,1);
131 };
132
133
134 }
135
136
137
138#endif
Exceptions.
Interface for binary input.
Forward declaration of binary output.
Interface for binary output.
General exception.
Definition JException.hh:24
Auxiliary class for object identification.
Definition JObjectID.hh:25
friend std::istream & operator>>(std::istream &in, JDOMToPMTMaskMap &masks)
virtual JReader & read(JReader &in) override
Read from input.
virtual JWriter & write(JWriter &out) const override
Write to output.
friend std::ostream & operator<<(std::ostream &out, const JDOMToPMTMaskMap &masks)
const JPMTMask & getPMTMask(const JModuleIdentifier &id)
Auxiliary class for PMT mask.
Definition JPMTMask.hh:56
const char * map
Definition elog.cc:87
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for triggering.