Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
cheprep::BHepRepWriter Class Reference

#include <BHepRepWriter.h>

+ Inheritance diagram for cheprep::BHepRepWriter:

Public Member Functions

 BHepRepWriter (std::ostream &os)
 
virtual ~BHepRepWriter ()
 
void close ()
 
void openDoc (std::string version="BinaryHepRep/1.0", std::string encoding="UTF-8", bool standalone=false)
 
void closeDoc (bool force=false)
 
void openTag (std::string name)
 
void closeTag ()
 
void printTag (std::string name)
 
void setAttribute (std::string name, char *value)
 
void setAttribute (std::string name, std::string value)
 
void setAttribute (std::string name, std::vector< double > value)
 
void setAttribute (std::string name, int64 value)
 
void setAttribute (std::string name, int value)
 
void setAttribute (std::string name, bool value)
 
void setAttribute (std::string name, double value)
 
void openTag (std::string ns, std::string name)
 
void printTag (std::string ns, std::string name)
 
void setAttribute (std::string ns, std::string name, std::string value)
 
void setAttribute (std::string ns, std::string name, double value)
 
- Public Member Functions inherited from cheprep::AbstractXMLWriter
 AbstractXMLWriter (std::string aDefaultNameSpace)
 
virtual ~AbstractXMLWriter ()
 
virtual void openTag (std::string ns, std::string name)=0
 
virtual void printTag (std::string ns, std::string name)=0
 
virtual void setAttribute (std::string ns, std::string name, std::string value)=0
 
virtual void setAttribute (std::string ns, std::string name, double value)=0
 
virtual void close ()=0
 
virtual void openDoc (std::string version="1.0", std::string encoding="", bool standalone=false)=0
 
virtual void closeDoc (bool force=false)=0
 
virtual void openTag (std::string name)=0
 
virtual void closeTag ()=0
 
virtual void printTag (std::string name)=0
 
virtual void setAttribute (std::string name, char *value)=0
 
virtual void setAttribute (std::string name, std::string value)=0
 
virtual void setAttribute (std::string name, std::vector< double > value)=0
 
virtual void setAttribute (std::string name, int64 value)=0
 
virtual void setAttribute (std::string name, int value)=0
 
virtual void setAttribute (std::string name, bool value)=0
 
virtual void setAttribute (std::string name, double value)=0
 

Additional Inherited Members

- Protected Attributes inherited from cheprep::AbstractXMLWriter
std::string defaultNameSpace
 

Detailed Description

Definition at line 19 of file BHepRepWriter.h.

Constructor & Destructor Documentation

◆ BHepRepWriter()

cheprep::BHepRepWriter::BHepRepWriter ( std::ostream &  os)

Definition at line 20 of file BHepRepWriter.cc.

21 : AbstractXMLWriter("heprep"),
22 os(ostrm),
23 singlePrecision(true) {
24
25 // resolve endiannes
26 union { long l; char c[sizeof (long)]; } u;
27 u.l = 1;
28 isBigEndian = (u.c[sizeof (long) - 1] == 1);
29
30// std::cout << "Host is " << (isBigEndian ? "Big-Endian" : "Little-Endian") << "." << std::endl;
31
32 if (tags.size() <= 0) {
33 // tags
34 tags["heprep"] = 0x05;
35 tags["attdef"] = 0x06;
36 tags["attvalue"] = 0x07;
37 tags["instance"] = 0x08;
38 tags["treeid"] = 0x09;
39 tags["action"] = 0x0a;
40 tags["instancetree"] = 0x0b;
41 tags["type"] = 0x0c;
42 tags["typetree"] = 0x0d;
43 tags["layer"] = 0x0e;
44 tags["point"] = 0x0f;
45 }
46
47 if (attributes.size() <= 0) {
48 // attribute names
49 attributes["version"] = 0x05;
50 attributes["xmlns"] = 0x06;
51 attributes["xmlns:xsi"] = 0x07;
52 attributes["xsi:schemaLocation"] = 0x08;
53
54 attributes["valueString"] = 0x10;
55 attributes["valueColor"] = 0x11;
56 attributes["valueLong"] = 0x12;
57 attributes["valueInt"] = 0x13;
58 attributes["valueBoolean"] = 0x14;
59 attributes["valueDouble"] = 0x15;
60
61 attributes["name"] = 0x20;
62 attributes["type"] = 0x22;
63 attributes["showlabel"] = 0x23;
64 attributes["desc"] = 0x24;
65 attributes["category"] = 0x25;
66 attributes["extra"] = 0x26;
67 attributes["x"] = 0x27;
68 attributes["y"] = 0x28;
69 attributes["z"] = 0x29;
70 attributes["qualifier"] = 0x2a;
71 attributes["expression"] = 0x2b;
72 attributes["typetreename"] = 0x2c;
73 attributes["typetreeversion"] = 0x2d;
74 attributes["order"] = 0x2e;
75
76 // for PI
77 attributes["eof"] = 0x7f;
78 }
79
80 if (values.size() <= 0) {
81 // attribute values
82 values["drawas"] = 0x85;
83 values["drawasoptions"] = 0x86;
84 values["visibility"] = 0x87;
85
86 values["label"] = 0x88;
87
88 values["fontname"] = 0x89;
89 values["fontstyle"] = 0x8a;
90 values["fontsize"] = 0x8b;
91 values["fontcolor"] = 0x8c;
92 values["fonthasframe"] = 0x8d;
93 values["fontframecolor"] = 0x8e;
94 values["fontframewidth"] = 0x8f;
95 values["fonthasbanner"] = 0x90;
96 values["fontbannercolor"] = 0x91;
97
98 values["color"] = 0x92;
99 values["framecolor"] = 0x93;
100 values["layer"] = 0x94;
101 values["markname"] = 0x95;
102 values["marksize"] = 0x96;
103 values["marksizemultiplier"] = 0x97;
104 values["marktype"] = 0x98;
105 values["hasframe"] = 0x99;
106 values["framecolor"] = 0x9a;
107 values["framewidth"] = 0x9b;
108
109 values["linestyle"] = 0x9c;
110 values["linewidth"] = 0x9d;
111 values["linewidthmultiplier"] = 0x9e;
112 values["linehasarrow"] = 0x9f;
113
114 values["fillcolor"] = 0xa0;
115 values["filltype"] = 0xa1;
116 values["fill"] = 0xa2;
117
118 values["radius"] = 0xa3;
119 values["phi"] = 0xa4;
120 values["theta"] = 0xa5;
121 values["omega"] = 0xa6;
122 values["radius1"] = 0xa7;
123 values["radius2"] = 0xa8;
124 values["radius3"] = 0xa9;
125 values["curvature"] = 0xaa;
126 values["flylength"] = 0xab;
127 values["faces"] = 0xac;
128
129 values["text"] = 0xad;
130 values["hpos"] = 0xae;
131 values["vpos"] = 0xaf;
132 values["halign"] = 0xb0;
133 values["valign"] = 0xb1;
134
135 values["ispickable"] = 0xb2;
136 values["showparentvalues"] = 0xb3;
137 values["pickparent"] = 0xb4;
138
139 // attvalue values
140 values["false"] = 0xd0;
141 values["true"] = 0xd1;
142
143 values["point"] = 0xd2;
144 values["line"] = 0xd3;
145 values["helix"] = 0xd4;
146 values["polygon"] = 0xd5;
147 values["circle"] = 0xd6;
148 values["curve"] = 0xd7;
149 values["ellipse"] = 0xd8;
150 values["ellipsoid"] = 0xd9;
151 values["prism"] = 0xda;
152 values["cylinder"] = 0xdb;
153 values["ellipseprism"] = 0xdc;
154 values["text"] = 0xdd;
155
156 values["nonzero"] = 0xde;
157 values["evenodd"] = 0xdf;
158
159 values["circle"] = 0xe0;
160 values["box"] = 0xe1;
161 values["uptriangle"] = 0xe2;
162 values["dntriangle"] = 0xe3;
163 values["diamond"] = 0xe4;
164 values["cross"] = 0xe5;
165 values["star"] = 0xe6;
166 values["plus"] = 0xe7;
167 values["hline"] = 0xe8;
168 values["vline"] = 0xe9;
169
170 values["solid"] = 0xea;
171 values["dotted"] = 0xeb;
172 values["dashed"] = 0xec;
173 values["dotdash"] = 0xed;
174
175 values["none"] = 0xee;
176 values["start"] = 0xef;
177 values["end"] = 0xf0;
178 values["both"] = 0xf1;
179
180 values["serif"] = 0xf2;
181 values["sansserif"] = 0xf3;
182 values["monotype"] = 0xf4;
183 values["symbol"] = 0xf5;
184
185 values["plain"] = 0xf6;
186 values["bold"] = 0xf7;
187 values["italic"] = 0xf8;
188
189 values["top"] = 0xf9;
190 values["baseline"] = 0xfa;
191 values["center"] = 0xfb;
192 values["bottom"] = 0xfc;
193
194 values["left"] = 0xfd;
195 values["right"] = 0xfe;
196
197 values["default"] = 0xff;
198 }
199 }
AbstractXMLWriter(std::string aDefaultNameSpace)

◆ ~BHepRepWriter()

cheprep::BHepRepWriter::~BHepRepWriter ( )
virtual

Definition at line 201 of file BHepRepWriter.cc.

201 {
202 }

Member Function Documentation

◆ close()

void cheprep::BHepRepWriter::close ( )
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 204 of file BHepRepWriter.cc.

204 {
205 }

◆ closeDoc()

void cheprep::BHepRepWriter::closeDoc ( bool  force = false)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 225 of file BHepRepWriter.cc.

225 {
226 writeByte(PI);
227 writeByte(attributes["eof"]);
228 writeByte(END);
229 }

◆ closeTag()

void cheprep::BHepRepWriter::closeTag ( )
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 235 of file BHepRepWriter.cc.

235 {
236 writePoints();
237 writeByte(END);
238 }

◆ openDoc()

void cheprep::BHepRepWriter::openDoc ( std::string  version = "BinaryHepRep/1.0",
std::string  encoding = "UTF-8",
bool  standalone = false 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 207 of file BHepRepWriter.cc.

207 {
208 stringValues.clear();
209
210 // header
211 writeByte(WBXML_VERSION);
212 writeMultiByteInt(UNKNOWN_PID);
213 writeMultiByteInt(UTF8);
214
215 version = "BinaryHepRep/1.0";
216
217 // string table
218 writeMultiByteInt(version.length()+1);
219
220 // BHepRep Header (as part of the string table)
221 writeString(version);
222
223 }

◆ openTag() [1/2]

void cheprep::BHepRepWriter::openTag ( std::string  name)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 231 of file BHepRepWriter.cc.

231 {
232 writeTag(name, true);
233 }

Referenced by openTag().

◆ openTag() [2/2]

void cheprep::BHepRepWriter::openTag ( std::string  ns,
std::string  name 
)
inlinevirtual

Implements cheprep::AbstractXMLWriter.

Definition at line 43 of file BHepRepWriter.h.

43 {
44 openTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
45 }
void openTag(std::string name)
#define ns
Definition: xmlparse.cc:614

◆ printTag() [1/2]

void cheprep::BHepRepWriter::printTag ( std::string  name)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 240 of file BHepRepWriter.cc.

240 {
241 writeTag(name);
242 }

Referenced by printTag().

◆ printTag() [2/2]

void cheprep::BHepRepWriter::printTag ( std::string  ns,
std::string  name 
)
inlinevirtual

Implements cheprep::AbstractXMLWriter.

Definition at line 46 of file BHepRepWriter.h.

46 {
47 printTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
48 }
void printTag(std::string name)

◆ setAttribute() [1/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  name,
bool  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 452 of file BHepRepWriter.cc.

452 {
453 if (name == "value") name = name.append("Boolean");
454
455 // make sure the attribute name is defined
456 if (attributes.count(name) <= 0) {
457 std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
458 return;
459 }
460
461 booleanAttributes[name] = value;
462 }
const char * name(G4int ptype)

◆ setAttribute() [2/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  name,
char *  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 400 of file BHepRepWriter.cc.

400 {
401 setAttribute(name, (std::string)value);
402 }
void setAttribute(std::string name, char *value)

Referenced by setAttribute().

◆ setAttribute() [3/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  name,
double  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 464 of file BHepRepWriter.cc.

464 {
465 if (name == "value") name = name.append("Double");
466
467 // make sure the attribute name is defined
468 if (attributes.count(name) <= 0) {
469 std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
470 return;
471 }
472
473 doubleAttributes[name] = value;
474 }

◆ setAttribute() [4/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  name,
int  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 440 of file BHepRepWriter.cc.

440 {
441 if (name == "value") name = name.append("Int");
442
443 // make sure the attribute name is defined
444 if (attributes.count(name) <= 0) {
445 std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
446 return;
447 }
448
449 intAttributes[name] = value;
450 }

◆ setAttribute() [5/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  name,
int64  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 428 of file BHepRepWriter.cc.

428 {
429 if (name == "value") name = name.append("Long");
430
431 // make sure the attribute name is defined
432 if (attributes.count(name) <= 0) {
433 std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
434 return;
435 }
436
437 longAttributes[name] = value;
438 }

◆ setAttribute() [6/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  name,
std::string  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 404 of file BHepRepWriter.cc.

404 {
405 if (name == "value") name = name.append("String");
406
407 // make sure the attribute name is defined
408 if (attributes.count(name) <= 0) {
409 std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
410 return;
411 }
412
413 stringAttributes[name] = value;
414 }

◆ setAttribute() [7/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  name,
std::vector< double >  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 416 of file BHepRepWriter.cc.

416 {
417 if (name == "value") name = name.append("Color");
418
419 // make sure the attribute name is defined
420 if (attributes.count(name) <= 0) {
421 std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
422 return;
423 }
424
425 colorAttributes[name] = value;
426 }

◆ setAttribute() [8/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  ns,
std::string  name,
double  value 
)
inlinevirtual

Implements cheprep::AbstractXMLWriter.

Definition at line 52 of file BHepRepWriter.h.

52 {
53 setAttribute(ns.append(":").append(name), value);
54 }

◆ setAttribute() [9/9]

void cheprep::BHepRepWriter::setAttribute ( std::string  ns,
std::string  name,
std::string  value 
)
inlinevirtual

Implements cheprep::AbstractXMLWriter.

Definition at line 49 of file BHepRepWriter.h.

49 {
50 setAttribute(ns.append(":").append(name), value);
51 }

The documentation for this class was generated from the following files: