#include <XMLHepRepWriter.h>
Definition at line 37 of file XMLHepRepWriter.h.
◆ XMLHepRepWriter()
cheprep::XMLHepRepWriter::XMLHepRepWriter |
( |
std::ostream * |
out, |
|
|
bool |
randomAccess, |
|
|
bool |
compress |
|
) |
| |
Definition at line 20 of file XMLHepRepWriter.cc.
21 : out(os),
22 compress(useCompression),
23 xml(0) {
24
26
27 if (randomAccess) {
28 zip = new ZipOutputStream(*os);
29 out = zip;
30 gz = NULL;
31 } else {
32 zip = NULL;
33 if (useCompression) {
34#ifndef CHEPREP_NO_ZLIB
35 gz = new GZIPOutputStream(*os);
36 out = gz;
37#else
38 cerr << "WARNING: the .gz output stream you are creating will be a plain file," << endl;
39 cerr << "since compression support (ZLIB) was not compiled into the library." << endl;
40 cerr << "To add ZLIB support, you need to undefine CHEPREP_NO_ZLIB." << endl;
41 gz = NULL;
42#endif
43 } else {
44 gz = NULL;
45 }
46 }
47}
◆ ~XMLHepRepWriter()
cheprep::XMLHepRepWriter::~XMLHepRepWriter |
( |
| ) |
|
◆ addProperty()
bool cheprep::XMLHepRepWriter::addProperty |
( |
std::string |
key, |
|
|
std::string |
value |
|
) |
| |
|
virtual |
Adds a property, to be written to the HepRep file when closed.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 54 of file XMLHepRepWriter.cc.
54 {
55 properties[key] = value;
56 return true;
57}
◆ close()
bool cheprep::XMLHepRepWriter::close |
( |
| ) |
|
|
virtual |
Closes the writer and its underlying stream.
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 59 of file XMLHepRepWriter.cc.
59 {
60 if (zip != NULL) {
62
63 map<string, string>::iterator i = properties.begin();
64 while (i != properties.end()) {
65 *zip << (*i).first << "=" << (*i).second << endl;
66 i++;
67 }
70 }
71
72 if (gz != NULL) {
74 }
75 return true;
76}
void putNextEntry(const std::string &name, bool compress)
◆ write() [1/13]
bool cheprep::XMLHepRepWriter::write |
( |
HEPREP::HepRep * |
heprep, |
|
|
std::string |
name |
|
) |
| |
|
virtual |
Writes a HepRep.
- Parameters
-
heprep | to be written. |
name | for the heprep to be written (for tagged access), may be ommited. |
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 78 of file XMLHepRepWriter.cc.
78 {
79 if (zip != NULL) {
81 }
82
83 if (
name.rfind(
".bheprep") ==
name.length()-8) {
84 xml = new BHepRepWriter(*out);
85 } else {
87 }
88
91 xml->
setAttribute(
"xmlns", (
string)
"http://java.freehep.org/schemas/heprep/2.0");
92 xml->
setAttribute(
"xmlns",
"xsi",
"http://www.w3.org/2001/XMLSchema-instance");
93 xml->
setAttribute(
"xsi",
"schemaLocation",
"http://java.freehep.org/schemas/heprep/2.0 http://java.freehep.org/schemas/heprep/2.0/HepRep.xsd");
94 xml->
openTag(nameSpace,
"heprep");
97 for (vector<HepRepTypeTree*>::iterator i1=typeTreeSet.begin(); i1 != typeTreeSet.end(); i1++) {
99 }
101 for (vector<HepRepInstanceTree*>::iterator i2=instanceTreeSet.begin(); i2 != instanceTreeSet.end(); i2++) {
103 }
106
107 delete xml;
108
109 if (zip != NULL) {
111 }
112
113 return true;
114}
virtual std::vector< HepRepInstanceTree * > getInstanceTreeList()=0
virtual std::vector< HepRepTypeTree * > getTypeTreeList()=0
virtual std::vector< std::string > getLayerOrder()=0
virtual void setAttribute(std::string ns, std::string name, std::string value)=0
virtual void openTag(std::string ns, std::string name)=0
virtual void closeTag()=0
virtual void openDoc(std::string version="1.0", std::string encoding="", bool standalone=false)=0
virtual void closeDoc(bool force=false)=0
bool write(HEPREP::HepRep *heprep, std::string name)
const char * name(G4int ptype)
Referenced by write().
◆ write() [2/13]
Writes a HepRepAction.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 167 of file XMLHepRepWriter.cc.
167 {
171 return true;
172}
virtual std::string getExpression()=0
virtual std::string getName()=0
virtual void printTag(std::string ns, std::string name)=0
◆ write() [3/13]
Writes a HepRepAttDef.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 278 of file XMLHepRepWriter.cc.
278 {
284 return true;
285}
virtual std::string getExtra()=0
virtual std::string getName()=0
virtual std::string getDescription()=0
virtual std::string getCategory()=0
◆ write() [4/13]
Writes a HepRepAttribute.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 228 of file XMLHepRepWriter.cc.
228 {
229
230
232 if (layerAtt != NULL)
write(layerAtt);
233
235 for (set<HepRepAttValue*>::iterator i=attSet.begin(); i != attSet.end(); i++) {
237 }
238 return true;
239}
virtual HepRepAttValue * getAttValueFromNode(std::string lowerCaseName)=0
virtual std::set< HepRepAttValue * > getAttValuesFromNode()=0
◆ write() [5/13]
Writes a HepRepAttValue.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 249 of file XMLHepRepWriter.cc.
249 {
251
253
256 break;
258 break;
260 break;
262 break;
264 break;
266 break;
268 }
269
272 }
273
274 xml->
printTag(nameSpace,
"attvalue");
275 return true;
276}
virtual std::string getName()=0
virtual std::vector< double > getColor()=0
virtual bool getBoolean()=0
virtual std::string getString()=0
virtual int showLabel()=0
virtual int64 getLong()=0
virtual double getDouble()=0
virtual int getInteger()=0
virtual std::string getAsString()=0
◆ write() [6/13]
Writes a HepRepDefinition.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 241 of file XMLHepRepWriter.cc.
241 {
243 for (set<HepRepAttDef*>::iterator i=list.begin(); i != list.end(); i++) {
245 }
246 return true;
247}
virtual std::set< HepRepAttDef * > getAttDefsFromNode()=0
◆ write() [7/13]
Writes a HepRepInstance.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 195 of file XMLHepRepWriter.cc.
195 {
196
198 xml->
openTag(nameSpace,
"instance");
200
201 vector<HepRepPoint*> pointList = instance->
getPoints();
202 for (vector<HepRepPoint*>::iterator i1=pointList.begin(); i1 != pointList.end(); i1++) {
204 }
205
206 vector<HepRepInstance*> instanceList = instance->
getInstances();
207 for (vector<HepRepInstance*>::iterator i2=instanceList.begin(); i2 != instanceList.end(); i2++) {
209 }
211 return true;
212}
virtual HepRepType * getType()=0
virtual std::vector< HepRepPoint * > getPoints()=0
virtual std::vector< HepRepInstance * > getInstances()=0
virtual std::string getFullName()=0
◆ write() [8/13]
Writes a HepRepInstanceTree.
- Parameters
-
instanceTree | to be written. |
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 174 of file XMLHepRepWriter.cc.
174 {
179 xml->
openTag(nameSpace,
"instancetree");
180
182 for (vector<HepRepTreeID*>::iterator i1=instanceTreeSet.begin(); i1 != instanceTreeSet.end(); i1++) {
184 }
185
186
187 vector<HepRepInstance*> instanceList = instanceTree->
getInstances();
188 for (vector<HepRepInstance*>::iterator i2=instanceList.begin(); i2 != instanceList.end(); i2++) {
190 }
192 return true;
193}
virtual HepRepTreeID * getTypeTree()=0
virtual std::vector< HepRepInstance * > getInstances()=0
virtual std::vector< HepRepTreeID * > getInstanceTreeList()=0
virtual std::string getName()=0
virtual std::string getVersion()=0
◆ write() [9/13]
Writes a HepRepPoint.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 214 of file XMLHepRepWriter.cc.
214 {
219 xml->
openTag(nameSpace,
"point");
222 } else {
224 }
225 return true;
226}
◆ write() [10/13]
Writes a HepRepTreeID.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 159 of file XMLHepRepWriter.cc.
159 {
164 return true;
165}
virtual std::string getQualifier()=0
◆ write() [11/13]
Writes a HepRepType.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 145 of file XMLHepRepWriter.cc.
145 {
147 xml->
openTag(nameSpace,
"type");
150
152 for (vector<HepRepType*>::iterator i=types.begin(); i != types.end(); i++) {
154 }
156 return true;
157}
virtual std::string getName()=0
virtual std::vector< HepRepType * > getTypeList()=0
◆ write() [12/13]
Writes a HepRepTypeTree.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 131 of file XMLHepRepWriter.cc.
131 {
134 xml->
openTag(nameSpace,
"typetree");
135
136 vector<HepRepType*> types = typeTree->
getTypeList();
137 for (vector<HepRepType*>::iterator i=types.begin(); i != types.end(); i++) {
139 }
140
142 return true;
143}
virtual std::vector< HepRepType * > getTypeList()=0
◆ write() [13/13]
bool cheprep::XMLHepRepWriter::write |
( |
std::vector< std::string > |
layerOrder | ) |
|
|
virtual |
Writes the layerOrder.
- Parameters
-
- Returns
- false in case of a stream problem.
Implements HEPREP::HepRepWriter.
Definition at line 116 of file XMLHepRepWriter.cc.
116 {
117 string layerOrder = "";
118 bool comma = false;
119 for (vector<string>::iterator i=layers.begin(); i != layers.end(); i++) {
120 if (comma) {
121 layerOrder.append(", ");
122 }
123 layerOrder.append(*i);
124 comma = true;
125 }
128 return true;
129}
The documentation for this class was generated from the following files: