Gyoto
GyotoObject.h
Go to the documentation of this file.
1 
6 /*
7  Copyright 2014-2016 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 "GyotoSmartPointer.h"
31 #include <string>
32 #include <vector>
33 
34 namespace Gyoto {
35  class Object;
36  class Property;
37  class Value;
38  class FactoryMessenger;
39 }
40 
42 
47 #define GYOTO_OBJECT_ACCESSORS_STRING(method) \
48  virtual void method(std::string const&); \
49  virtual std::string method() const;
50 
52 
60 #define GYOTO_OBJECT_ACCESSORS(type, method) \
61  virtual void method(type); \
62  virtual type method() const;
63 
65 
70 #define GYOTO_OBJECT_ACCESSORS_UNIT(method) \
71  GYOTO_OBJECT_ACCESSORS(double, method) \
72  virtual void method(double, std::string const &); \
73  virtual double method(std::string const &) const;
74 
76 
84 #define GYOTO_OBJECT \
85  static Property const properties[]; \
86  virtual Property const * getProperties() const; \
87  static const std::string builtinPluginValue; \
88  virtual void plugins(std::vector<std::string> const & plugname); \
89  virtual std::vector<std::string> plugins() const
90 
92 
99 #define GYOTO_OBJECT_THREAD_SAFETY \
100  virtual bool isThreadSafe() const
101 
103 
152 {
153  protected:
155 
162  std::string kind_;
163 
165 
172  std::vector<std::string> plugins_;
173 
174  public:
176 
197  virtual bool isThreadSafe() const;
198 
199 
224  Object (std::string const &kind) ;
226 
228  Object () ;
229 
231  Object (Object const &orig) ;
232 
234  virtual ~Object();
235 
237  void set(Property const &p, Value val);
238 
240  void set(Property const &p, Value val, std::string const &unit);
241 
243  void set(std::string const &pname, Value val);
244 
246  void set(std::string const &pname, Value val, std::string const &unit);
247 
249  Value get(Property const &p) const;
250 
252  Value get(std::string const &pname) const;
253 
255  Value get(Property const &p, std::string const &unit) const;
256 
258  Value get(std::string const &pname, std::string const &unit) const;
259 
261 
267  Property const * property(std::string const pname) const;
268 
269 #ifdef GYOTO_USE_XERCES
270 
298  virtual void fillProperty(Gyoto::FactoryMessenger *fmp,
299  Property const &p) const ;
300 
302 
316  virtual void fillElement(Gyoto::FactoryMessenger *fmp) const ;
317 
318 
320 
355  virtual void setParameters(Gyoto::FactoryMessenger *fmp) ;
356 #endif
357 
390  virtual int setParameter(std::string name,
391  std::string content,
392  std::string unit);
393 
426  virtual void setParameter(Gyoto::Property const &p,
427  std::string const &name,
428  std::string const &content,
429  std::string const &unit);
430 
437  std::string describeProperty(Gyoto::Property const &p) const ;
438 
444  void help() const ;
445 };
446 
447 #endif
virtual bool isThreadSafe() const
Whether this class is thread-safe.
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:84
virtual ~Object()
Virtual destructor.
void help() const
Print (to stdout) some help on this class.
Reference-counting pointers.
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
virtual void setParameters(Gyoto::FactoryMessenger *fmp)
Main loop for parsing Properties from XML description.
std::vector< std::string > plugins_
The plug-ins that needs to be loaded to access this instance&#39;s class.
Definition: GyotoObject.h:172
Compile-time configuration.
Property const * property(std::string const pname) const
Find property by name.
Property that can be set and got using standard methods.
Definition: GyotoProperty.h:607
Object()
Default constructor.
std::string describeProperty(Gyoto::Property const &p) const
Format desrciption for a property.
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:162
Object with properties.
Definition: GyotoObject.h:151
virtual void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const
Output a single Property to XML.
virtual void fillElement(Gyoto::FactoryMessenger *fmp) const
Fill the XML element for this Object.