GyotoFactoryMessenger.h
Go to the documentation of this file.
#ifdef GYOTO_USE_XERCES
/*
Copyright 2011-2014, 2016, 2018 Thibaut Paumard
This file is part of Gyoto.
Gyoto is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gyoto is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GyotoFactoryMessenger_H_
#define __GyotoFactoryMessenger_H_
#ifndef XERCES_INCLUDE_WCHAR_H
#define XERCES_INCLUDE_WCHAR_H 0
#endif
#include <xercesc/dom/DOMElement.hpp>
#include <vector>
#include <string>
#include <GyotoDefs.h>
#include <GyotoSmartPointer.h>
namespace Gyoto {
class Factory;
class FactoryMessenger;
namespace Metric { class Generic; }
namespace Astrobj { class Generic; }
namespace Spectrum { class Generic ; }
class Screen;
class Photon;
}
class Gyoto::FactoryMessenger {
private:
Gyoto::Factory* employer_;
xercesc::DOMElement *element_;
xercesc::DOMNodeList* children_;
XMLSize_t nodeCount_;
XMLSize_t curNodeIndex_;
public:
FactoryMessenger(Gyoto::Factory*, xercesc::DOMElement*);
FactoryMessenger(const FactoryMessenger& parent, std::string) ;
void reset();
SmartPointer<Metric::Generic> metric () ;
SmartPointer<Screen> screen () ;
SmartPointer<Photon> photon () ;
SmartPointer<Astrobj::Generic> astrobj () ;
int getNextParameter(std::string* name,
std::string* content,
std::string* unit=NULL);
std::string getSelfAttribute(std::string attrname) const ;
std::string getAttribute(std::string attrname) const ;
std::string getFullContent() const ;
FactoryMessenger * getChild() const ;
std::string fullPath(std::string relpath) ;
void metric(SmartPointer<Metric::Generic>);
void astrobj(SmartPointer<Astrobj::Generic>);
void screen(SmartPointer<Screen>);
void setParameter(std::string name);
void setParameter(std::string name, double value);
void setParameter(std::string name, long int value);
void setParameter(std::string name, unsigned int value);
void setParameter(std::string name, unsigned long value);
void setParameter(std::string name, int value);
void setParameter(std::string name, std::string value);
void setParameter(std::string name, double val[], size_t n,
FactoryMessenger** child= NULL);
void setParameter(std::string name, std::vector<double> const &val,
FactoryMessenger** child= NULL);
void setParameter(std::string name, std::vector<unsigned long> const &val,
FactoryMessenger** child= NULL);
void setSelfAttribute(std::string attrname, std::string value) ;
void setSelfAttribute(std::string attrname, unsigned long value) ;
void setSelfAttribute(std::string attrname, unsigned int value) ;
void setSelfAttribute(std::string attrname, double value) ;
void setFullContent(std::string value) ;
FactoryMessenger* makeChild(std::string name);
static size_t parseArray(std::string src, double dst[], size_t max_tokens);
static std::vector<double> parseArray(std::string src);
static std::vector<unsigned long> parseArrayULong(std::string src);
};
#endif
#endif
GyotoDefs.h
Gyoto ubiquitous macros and typedefs.
GyotoSmartPointer.h
Reference-counting pointers.
Gyoto::Factory
XML input/output.
Definition GyotoFactory.h:115
Gyoto::FactoryMessenger
Factory / SmartPointee::Subcontractor_t interface.
Definition GyotoFactoryMessenger.h:92
Gyoto::FactoryMessenger::FactoryMessenger
FactoryMessenger(Gyoto::Factory *, xercesc::DOMElement *)
Constructor called before subcontracting.
Gyoto::FactoryMessenger::FactoryMessenger
FactoryMessenger(const FactoryMessenger &parent, std::string)
Constructor called before fillElement.
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name, unsigned long value)
Output parameter.
Gyoto::FactoryMessenger::fullPath
std::string fullPath(std::string relpath)
Transform path into full path specification.
Gyoto::FactoryMessenger::element_
xercesc::DOMElement * element_
The XML element concerned by this transaction.
Definition GyotoFactoryMessenger.h:96
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name, double val[], size_t n, FactoryMessenger **child=NULL)
Output an array of parameters.
Gyoto::FactoryMessenger::getSelfAttribute
std::string getSelfAttribute(std::string attrname) const
Get attribute of FactoryMessenger::element_.
Gyoto::FactoryMessenger::screen
void screen(SmartPointer< Screen >)
Set the Screen.
Gyoto::FactoryMessenger::getFullContent
std::string getFullContent() const
Get full content of element_.
Gyoto::FactoryMessenger::getAttribute
std::string getAttribute(std::string attrname) const
Get attribute of a last retrieved parameter.
Gyoto::FactoryMessenger::astrobj
SmartPointer< Astrobj::Generic > astrobj()
Build and get the Astrobj described in this XML file.
Gyoto::FactoryMessenger::setFullContent
void setFullContent(std::string value)
Low level, prefer setParameter().
Gyoto::FactoryMessenger::nodeCount_
XMLSize_t nodeCount_
The number of children of the XML element concerned by this transaction.
Definition GyotoFactoryMessenger.h:100
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name, long int value)
Output parameter.
Gyoto::FactoryMessenger::parseArray
static std::vector< double > parseArray(std::string src)
Parse string into array.
Gyoto::FactoryMessenger::makeChild
FactoryMessenger * makeChild(std::string name)
Create child FactoryMessenger.
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name, double value)
Output parameter.
Gyoto::FactoryMessenger::getNextParameter
int getNextParameter(std::string *name, std::string *content, std::string *unit=NULL)
Get name and value of next parameter.
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name)
Output parameter.
Gyoto::FactoryMessenger::setSelfAttribute
void setSelfAttribute(std::string attrname, double value)
Set attribute in FactoryMessenger::element_.
Gyoto::FactoryMessenger::parseArrayULong
static std::vector< unsigned long > parseArrayULong(std::string src)
Parse string into array.
Gyoto::FactoryMessenger::employer_
Gyoto::Factory * employer_
The Factory that sent this messenger.
Definition GyotoFactoryMessenger.h:94
Gyoto::FactoryMessenger::metric
void metric(SmartPointer< Metric::Generic >)
Set the Metric.
Gyoto::FactoryMessenger::astrobj
void astrobj(SmartPointer< Astrobj::Generic >)
Set the Astrobj.
Gyoto::FactoryMessenger::parseArray
static size_t parseArray(std::string src, double dst[], size_t max_tokens)
Parse string into array.
Gyoto::FactoryMessenger::metric
SmartPointer< Metric::Generic > metric()
Build and get the Metric described in this XML file.
Gyoto::FactoryMessenger::children_
xercesc::DOMNodeList * children_
The children of the XML element concerned by this transaction.
Definition GyotoFactoryMessenger.h:98
Gyoto::FactoryMessenger::setSelfAttribute
void setSelfAttribute(std::string attrname, std::string value)
Set attribute in FactoryMessenger::element_.
Gyoto::FactoryMessenger::photon
SmartPointer< Photon > photon()
Build and get the Photon described in this XML file.
Gyoto::FactoryMessenger::getChild
FactoryMessenger * getChild() const
Get another FactoryMessenger instance initialized to current child.
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name, unsigned int value)
Output parameter.
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name, std::string value)
Output parameter.
Gyoto::FactoryMessenger::reset
void reset()
Get back to first parameter.
Gyoto::FactoryMessenger::setSelfAttribute
void setSelfAttribute(std::string attrname, unsigned long value)
Set attribute in FactoryMessenger::element_.
Gyoto::FactoryMessenger::screen
SmartPointer< Screen > screen()
Build and get the Screen described in this XML file.
Gyoto::FactoryMessenger::setSelfAttribute
void setSelfAttribute(std::string attrname, unsigned int value)
Set attribute in FactoryMessenger::element_.
Gyoto::FactoryMessenger::curNodeIndex_
XMLSize_t curNodeIndex_
Current child.
Definition GyotoFactoryMessenger.h:102
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name, int value)
Output parameter.
Gyoto::FactoryMessenger::setParameter
void setParameter(std::string name, std::vector< unsigned long > const &val, FactoryMessenger **child=NULL)
Output a vector of parameters.
Gyoto::SmartPointer
Pointers performing reference counting.
Definition GyotoSmartPointer.h:135
Gyoto
Namespace for the Gyoto library.
Definition GyotoAstrobj.h:44