GyotoObject.h
Go to the documentation of this file.
/*
Copyright 2014-2016 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 __GyotoObject_H_
#define __GyotoObject_H_
#include "GyotoConfig.h"
#include "GyotoSmartPointer.h"
#include <string>
#include <vector>
namespace Gyoto {
class Object;
class Property;
class Value;
class FactoryMessenger;
}
#define GYOTO_OBJECT_ACCESSORS_STRING(method) \
virtual void method(std::string const&); \
virtual std::string method() const;
#define GYOTO_OBJECT_ACCESSORS(type, method) \
virtual void method(type); \
virtual type method() const;
#define GYOTO_OBJECT_ACCESSORS_UNIT(method) \
GYOTO_OBJECT_ACCESSORS(double, method) \
virtual void method(double, std::string const &); \
virtual double method(std::string const &) const;
#define GYOTO_OBJECT \
static Property const properties[]; \
virtual Property const * getProperties() const; \
static const std::string builtinPluginValue; \
virtual void plugins(std::vector<std::string> const & plugname); \
virtual std::vector<std::string> plugins() const
#define GYOTO_OBJECT_THREAD_SAFETY \
virtual bool isThreadSafe() const
class Gyoto::Object
{
protected:
std::string kind_;
std::vector<std::string> plugins_;
public:
virtual bool isThreadSafe() const;
GYOTO_OBJECT;
Object (std::string const &kind) ;
Object () ;
Object (Object const &orig) ;
virtual ~Object();
virtual void set(Property const &p, Value val);
virtual void set(Property const &p, Value val, std::string const &unit);
virtual void set(std::string const &pname, Value val);
virtual void set(std::string const &pname, Value val, std::string const &unit);
virtual Value get(Property const &p) const;
virtual Value get(std::string const &pname) const;
virtual Value get(Property const &p, std::string const &unit) const;
virtual Value get(std::string const &pname, std::string const &unit) const;
Property const * property(std::string const pname) const;
#ifdef GYOTO_USE_XERCES
virtual void fillProperty(Gyoto::FactoryMessenger *fmp,
Property const &p) const ;
virtual void fillElement(Gyoto::FactoryMessenger *fmp) const ;
virtual void setParameters(Gyoto::FactoryMessenger *fmp) ;
#endif
virtual int setParameter(std::string name,
std::string content,
std::string unit);
virtual void setParameter(Gyoto::Property const &p,
std::string const &name,
std::string const &content,
std::string const &unit);
std::string describeProperty(Gyoto::Property const &p) const ;
void help() const ;
protected:
virtual void kind(const std::string);
public:
virtual std::string kind() const;
};
#endif
GyotoConfig.h
Compile-time configuration.
GYOTO_OBJECT
#define GYOTO_OBJECT
Declare class::properties and class::getProperties().
Definition GyotoObject.h:84
GyotoSmartPointer.h
Reference-counting pointers.
Gyoto::FactoryMessenger
Factory / SmartPointee::Subcontractor_t interface.
Definition GyotoFactoryMessenger.h:92
Gyoto::Object
Object with properties.
Definition GyotoObject.h:152
Gyoto::Object::plugins_
std::vector< std::string > plugins_
The plug-ins that needs to be loaded to access this instance's class.
Definition GyotoObject.h:172
Gyoto::Object::isThreadSafe
virtual bool isThreadSafe() const
Whether this class is thread-safe.
Gyoto::Object::fillElement
virtual void fillElement(Gyoto::FactoryMessenger *fmp) const
Fill the XML element for this Object.
Gyoto::Object::fillProperty
virtual void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const
Output a single Property to XML.
Gyoto::Object::help
void help() const
Print (to stdout) some help on this class.
Gyoto::Object::Object
Object(Object const &orig)
Deep copy constructor.
Gyoto::Object::setParameter
virtual void setParameter(Gyoto::Property const &p, std::string const &name, std::string const &content, std::string const &unit)
Set parameter by Property (and name).
Gyoto::Object::setParameter
virtual int setParameter(std::string name, std::string content, std::string unit)
Set parameter by name.
Gyoto::Object::Object
Object(std::string const &kind)
Constructor setting kind.
Gyoto::Object::Object
Object()
Default constructor.
Gyoto::Object::set
virtual void set(Property const &p, Value val)
Set Value of a Property.
Gyoto::Object::describeProperty
std::string describeProperty(Gyoto::Property const &p) const
Format desrciption for a property.
Gyoto::Object::get
virtual Value get(Property const &p) const
Get Value of a Property.
Gyoto::Object::get
virtual Value get(std::string const &pname, std::string const &unit) const
Get Value of a Property, converted to unit.
Gyoto::Object::kind
virtual std::string kind() const
Get kind_.
Gyoto::Object::set
virtual void set(Property const &p, Value val, std::string const &unit)
Set Value (expressed in unit) of a Property.
Gyoto::Object::setParameters
virtual void setParameters(Gyoto::FactoryMessenger *fmp)
Main loop for parsing Properties from XML description.
Gyoto::Object::kind
virtual void kind(const std::string)
Set kind_.
Gyoto::Object::~Object
virtual ~Object()
Virtual destructor.
Gyoto::Object::set
virtual void set(std::string const &pname, Value val)
Set Value of a Property.
Gyoto::Object::set
virtual void set(std::string const &pname, Value val, std::string const &unit)
Set Value (expressed in unit) of a Property.
Gyoto::Object::kind_
std::string kind_
The "kind" that is output in the XML entity.
Definition GyotoObject.h:162
Gyoto::Object::property
Property const * property(std::string const pname) const
Find property by name.
Gyoto::Object::get
virtual Value get(Property const &p, std::string const &unit) const
Get Value of a Property, converted to unit.
Gyoto::Object::get
virtual Value get(std::string const &pname) const
Get Value of a Property.
Gyoto::Property
Property that can be set and got using standard methods.
Definition GyotoProperty.h:608
Gyoto::Value
Container for the value of a Property.
Definition GyotoValue.h:60
Gyoto
Namespace for the Gyoto library.
Definition GyotoAstrobj.h:44