Gyoto
GyotoFactoryMessenger.h
Go to the documentation of this file.
1
5#ifdef GYOTO_USE_XERCES
6/*
7 Copyright 2011-2014, 2016, 2018 Thibaut Paumard
8
9 This file is part of Gyoto.
10
11 Gyoto is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15
16 Gyoto is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25#ifndef __GyotoFactoryMessenger_H_
26#define __GyotoFactoryMessenger_H_
27
29
33#ifndef XERCES_INCLUDE_WCHAR_H
34#define XERCES_INCLUDE_WCHAR_H 0
35#endif
36#include <xercesc/dom/DOMElement.hpp>
37#include <vector>
38#include <string>
39#include <GyotoDefs.h>
40#include <GyotoSmartPointer.h>
41
42namespace Gyoto {
43 class Factory;
44 class FactoryMessenger;
45 namespace Metric { class Generic; }
46 namespace Astrobj { class Generic; }
47 namespace Spectrum { class Generic ; }
48 class Screen;
49 class Photon;
50}
51
93 private:
96 xercesc::DOMElement *element_;
98 xercesc::DOMNodeList* children_;
100 XMLSize_t nodeCount_;
102 XMLSize_t curNodeIndex_;
104 public:
105 FactoryMessenger(Gyoto::Factory*, xercesc::DOMElement*);
107 FactoryMessenger(const FactoryMessenger& parent, std::string) ;
109
110 void reset();
112
114
124
134
144
154
169 int getNextParameter(std::string* name,
170 std::string* content,
171 std::string* unit=NULL);
173
185 std::string getSelfAttribute(std::string attrname) const ;
187
197 std::string getAttribute(std::string attrname) const ;
199
213 std::string getFullContent() const ;
215
236
237
250 std::string fullPath(std::string relpath) ;
252
253
255
283
289
295
296
307 void setParameter(std::string name);
309
317 void setParameter(std::string name, double value);
319
327 void setParameter(std::string name, long int value);
329
337 void setParameter(std::string name, unsigned int value);
339
347 void setParameter(std::string name, unsigned long value);
349
357 void setParameter(std::string name, int value);
359
366 void setParameter(std::string name, std::string value);
368
392 void setParameter(std::string name, double val[], size_t n,
393 FactoryMessenger** child= NULL);
395
396 void setParameter(std::string name, std::vector<double> const &val,
397 FactoryMessenger** child= NULL);
398 void setParameter(std::string name, std::vector<unsigned long> const &val,
399 FactoryMessenger** child= NULL);
401
413 void setSelfAttribute(std::string attrname, std::string value) ;
415
419 void setSelfAttribute(std::string attrname, unsigned long value) ;
421
425 void setSelfAttribute(std::string attrname, unsigned int value) ;
427
431 void setSelfAttribute(std::string attrname, double value) ;
433
441 void setFullContent(std::string value) ;
443
462 FactoryMessenger* makeChild(std::string name);
464
473 static size_t parseArray(std::string src, double dst[], size_t max_tokens);
474
481 static std::vector<double> parseArray(std::string src);
482
489 static std::vector<unsigned long> parseArrayULong(std::string src);
490};
491
492#endif
493#endif
Gyoto ubiquitous macros and typedefs.
Reference-counting pointers.
XML input/output.
Definition: GyotoFactory.h:115
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
FactoryMessenger(Gyoto::Factory *, xercesc::DOMElement *)
Constructor called before subcontracting.
FactoryMessenger(const FactoryMessenger &parent, std::string)
Constructor called before fillElement.
void setParameter(std::string name, unsigned long value)
Output parameter.
std::string fullPath(std::string relpath)
Transform path into full path specification.
xercesc::DOMElement * element_
The XML element concerned by this transaction.
Definition: GyotoFactoryMessenger.h:96
void setParameter(std::string name, double val[], size_t n, FactoryMessenger **child=NULL)
Output an array of parameters.
std::string getSelfAttribute(std::string attrname) const
Get attribute of FactoryMessenger::element_.
void screen(SmartPointer< Screen >)
Set the Screen.
std::string getFullContent() const
Get full content of element_.
std::string getAttribute(std::string attrname) const
Get attribute of a last retrieved parameter.
SmartPointer< Astrobj::Generic > astrobj()
Build and get the Astrobj described in this XML file.
void setFullContent(std::string value)
Low level, prefer setParameter()
XMLSize_t nodeCount_
The number of children of the XML element concerned by this transaction.
Definition: GyotoFactoryMessenger.h:100
void setParameter(std::string name, long int value)
Output parameter.
static std::vector< double > parseArray(std::string src)
Parse string into array.
FactoryMessenger * makeChild(std::string name)
Create child FactoryMessenger.
void setParameter(std::string name, double value)
Output parameter.
int getNextParameter(std::string *name, std::string *content, std::string *unit=NULL)
Get name and value of next parameter.
void setParameter(std::string name)
Output parameter.
void setSelfAttribute(std::string attrname, double value)
Set attribute in FactoryMessenger::element_.
static std::vector< unsigned long > parseArrayULong(std::string src)
Parse string into array.
Gyoto::Factory * employer_
The Factory that sent this messenger.
Definition: GyotoFactoryMessenger.h:94
void metric(SmartPointer< Metric::Generic >)
Set the Metric.
void astrobj(SmartPointer< Astrobj::Generic >)
Set the Astrobj.
static size_t parseArray(std::string src, double dst[], size_t max_tokens)
Parse string into array.
SmartPointer< Metric::Generic > metric()
Build and get the Metric described in this XML file.
xercesc::DOMNodeList * children_
The children of the XML element concerned by this transaction.
Definition: GyotoFactoryMessenger.h:98
void setSelfAttribute(std::string attrname, std::string value)
Set attribute in FactoryMessenger::element_.
SmartPointer< Photon > photon()
Build and get the Photon described in this XML file.
FactoryMessenger * getChild() const
Get another FactoryMessenger instance initialized to current child.
void setParameter(std::string name, unsigned int value)
Output parameter.
void setParameter(std::string name, std::string value)
Output parameter.
void reset()
Get back to first parameter.
void setSelfAttribute(std::string attrname, unsigned long value)
Set attribute in FactoryMessenger::element_.
SmartPointer< Screen > screen()
Build and get the Screen described in this XML file.
void setSelfAttribute(std::string attrname, unsigned int value)
Set attribute in FactoryMessenger::element_.
XMLSize_t curNodeIndex_
Current child.
Definition: GyotoFactoryMessenger.h:102
void setParameter(std::string name, int value)
Output parameter.
void setParameter(std::string name, std::vector< unsigned long > const &val, FactoryMessenger **child=NULL)
Output a vector of parameters.
Pointers performing reference counting.
Definition: GyotoSmartPointer.h:135
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43