Gyoto
GyotoObject.h
Go to the documentation of this file.
1 
6 /*
7  Copyright 2014-2015 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 
26 #ifndef __GyotoObject_H_
27 #define __GyotoObject_H_
28 
29 #include "GyotoConfig.h"
30 #include <string>
31 #include <vector>
32 
33 namespace Gyoto {
34  class Object;
35  class Property;
36  class Value;
37  class FactoryMessenger;
38 }
39 
41 
46 #define GYOTO_OBJECT_ACCESSORS_STRING(method) \
47  virtual void method(std::string const&); \
48  virtual std::string method() const;
49 
51 
59 #define GYOTO_OBJECT_ACCESSORS(type, method) \
60  virtual void method(type); \
61  virtual type method() const;
62 
64 
69 #define GYOTO_OBJECT_ACCESSORS_UNIT(method) \
70  GYOTO_OBJECT_ACCESSORS(double, method) \
71  virtual void method(double, std::string const &); \
72  virtual double method(std::string const &) const;
73 
75 
83 #define GYOTO_OBJECT \
84  static Property const properties[]; \
85  virtual Property const * getProperties() const
86 
88 
137 {
138  protected:
140 
147  std::string kind_;
148  public:
173  Object (std::string const &kind) ;
175 
177  Object () ;
178 
180  Object (Object const &orig) ;
181 
183  virtual ~Object();
184 
186  void set(Property const &p, Value val);
187 
189  void set(Property const &p, Value val, std::string const &unit);
190 
192  void set(std::string const &pname, Value val);
193 
195  void set(std::string const &pname, Value val, std::string const &unit);
196 
198  Value get(Property const &p) const;
199 
201  Value get(std::string const &pname) const;
202 
204  Value get(Property const &p, std::string const &unit) const;
205 
207  Value get(std::string const &pname, std::string const &unit) const;
208 
210 
216  Property const * property(std::string const pname) const;
217 
218 #ifdef GYOTO_USE_XERCES
219 
247  virtual void fillProperty(Gyoto::FactoryMessenger *fmp,
248  Property const &p) const ;
249 
251 
265  virtual void fillElement(Gyoto::FactoryMessenger *fmp) const ;
266 
267 
269 
304  virtual void setParameters(Gyoto::FactoryMessenger *fmp) ;
305 #endif
306 
335  virtual int setParameter(std::string name,
336  std::string content,
337  std::string unit);
338 
371  virtual void setParameter(Gyoto::Property const &p,
372  std::string const &name,
373  std::string const &content,
374  std::string const &unit);
375 
376 };
377 
378 #endif
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:83
virtual ~Object()
Virtual destructor.
void set(Property const &p, Value val)
Set Value of a Property.
virtual void setParameters(Gyoto::FactoryMessenger *fmp)
Main loop for parsing Properties from XML description.
Property const * property(std::string const pname) const
Find property by name.
Compile-time configuration.
Property that can be set and got using standard methods.
Definition: GyotoProperty.h:313
virtual void fillElement(Gyoto::FactoryMessenger *fmp) const
Fill the XML element for this Object.
Object()
Default constructor.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
virtual int setParameter(std::string name, std::string content, std::string unit)
Set parameter by name.
Container for the value of a Property.
Definition: GyotoValue.h:60
std::string kind_
The "kind" that is output in the XML entity.
Definition: GyotoObject.h:147
Object with properties.
Definition: GyotoObject.h:136
virtual void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const
Output a single Property to XML.