Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cheprep::BHepRepWriter Class Reference

#include <BHepRepWriter.h>

Inheritance diagram for cheprep::BHepRepWriter:
Collaboration 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 ()
 

Additional Inherited Members

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

Detailed Description

Definition at line 20 of file BHepRepWriter.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file BHepRepWriter.cc.

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

Definition at line 202 of file BHepRepWriter.cc.

202  {
203  }

Member Function Documentation

void cheprep::BHepRepWriter::close ( )
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 205 of file BHepRepWriter.cc.

205  {
206  }
void cheprep::BHepRepWriter::closeDoc ( bool  force = false)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 226 of file BHepRepWriter.cc.

226  {
227  writeByte(PI);
228  writeByte(attributes["eof"]);
229  writeByte(END);
230  }
void cheprep::BHepRepWriter::closeTag ( )
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 236 of file BHepRepWriter.cc.

236  {
237  writePoints();
238  writeByte(END);
239  }
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 208 of file BHepRepWriter.cc.

208  {
209  stringValues.clear();
210 
211  // header
212  writeByte(WBXML_VERSION);
213  writeMultiByteInt(UNKNOWN_PID);
214  writeMultiByteInt(UTF8);
215 
216  version = "BinaryHepRep/1.0";
217 
218  // string table
219  writeMultiByteInt(version.length()+1);
220 
221  // BHepRep Header (as part of the string table)
222  writeString(version);
223 
224  }
const XML_Char * version
Definition: expat.h:187
void cheprep::BHepRepWriter::openTag ( std::string  name)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 232 of file BHepRepWriter.cc.

232  {
233  writeTag(name, true);
234  }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

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

Implements cheprep::AbstractXMLWriter.

Definition at line 44 of file BHepRepWriter.h.

44  {
45  openTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
46  }
const XML_Char * name
Definition: expat.h:151
void openTag(std::string name)
#define ns
Definition: xmlparse.cc:614

Here is the call graph for this function:

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

Implements cheprep::AbstractXMLWriter.

Definition at line 241 of file BHepRepWriter.cc.

241  {
242  writeTag(name);
243  }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

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

Implements cheprep::AbstractXMLWriter.

Definition at line 47 of file BHepRepWriter.h.

47  {
48  printTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
49  }
void printTag(std::string name)
const XML_Char * name
Definition: expat.h:151
#define ns
Definition: xmlparse.cc:614

Here is the call graph for this function:

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

Implements cheprep::AbstractXMLWriter.

Definition at line 401 of file BHepRepWriter.cc.

401  {
402  setAttribute(name, (std::string)value);
403  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void setAttribute(std::string name, char *value)

Here is the caller graph for this function:

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

Implements cheprep::AbstractXMLWriter.

Definition at line 405 of file BHepRepWriter.cc.

405  {
406  if (name == "value") name = name.append("String");
407 
408  // make sure the attribute name is defined
409  if (attributes.count(name) <= 0) {
410  std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
411  return;
412  }
413 
414  stringAttributes[name] = value;
415  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void cheprep::BHepRepWriter::setAttribute ( std::string  name,
std::vector< double >  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 417 of file BHepRepWriter.cc.

417  {
418  if (name == "value") name = name.append("Color");
419 
420  // make sure the attribute name is defined
421  if (attributes.count(name) <= 0) {
422  std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
423  return;
424  }
425 
426  colorAttributes[name] = value;
427  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void cheprep::BHepRepWriter::setAttribute ( std::string  name,
int64  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 429 of file BHepRepWriter.cc.

429  {
430  if (name == "value") name = name.append("Long");
431 
432  // make sure the attribute name is defined
433  if (attributes.count(name) <= 0) {
434  std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
435  return;
436  }
437 
438  longAttributes[name] = value;
439  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void cheprep::BHepRepWriter::setAttribute ( std::string  name,
int  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 441 of file BHepRepWriter.cc.

441  {
442  if (name == "value") name = name.append("Int");
443 
444  // make sure the attribute name is defined
445  if (attributes.count(name) <= 0) {
446  std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
447  return;
448  }
449 
450  intAttributes[name] = value;
451  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void cheprep::BHepRepWriter::setAttribute ( std::string  name,
bool  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 453 of file BHepRepWriter.cc.

453  {
454  if (name == "value") name = name.append("Boolean");
455 
456  // make sure the attribute name is defined
457  if (attributes.count(name) <= 0) {
458  std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
459  return;
460  }
461 
462  booleanAttributes[name] = value;
463  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void cheprep::BHepRepWriter::setAttribute ( std::string  name,
double  value 
)
virtual

Implements cheprep::AbstractXMLWriter.

Definition at line 465 of file BHepRepWriter.cc.

465  {
466  if (name == "value") name = name.append("Double");
467 
468  // make sure the attribute name is defined
469  if (attributes.count(name) <= 0) {
470  std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
471  return;
472  }
473 
474  doubleAttributes[name] = value;
475  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void cheprep::BHepRepWriter::setAttribute ( std::string  ns,
std::string  name,
std::string  value 
)
inlinevirtual

Implements cheprep::AbstractXMLWriter.

Definition at line 50 of file BHepRepWriter.h.

50  {
51  setAttribute(ns.append(":").append(name), value);
52  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void setAttribute(std::string name, char *value)
#define ns
Definition: xmlparse.cc:614

Here is the call graph for this function:

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

Implements cheprep::AbstractXMLWriter.

Definition at line 53 of file BHepRepWriter.h.

53  {
54  setAttribute(ns.append(":").append(name), value);
55  }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
void setAttribute(std::string name, char *value)
#define ns
Definition: xmlparse.cc:614

Here is the call graph for this function:


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