Gyoto
Classes | Namespaces | Macros
GyotoProperty.h File Reference

Introspectable properties. More...

#include "GyotoConfig.h"
#include <string>
#include <vector>

Go to the source code of this file.

Classes

class  Gyoto::Property
 Property that can be set and got using standard methods. More...
 
union  Gyoto::Property::setter_t
 Union holding an accessor to set any type. More...
 
union  Gyoto::Property::getter_t
 Union holding an accessor to get any type. More...
 
union  Gyoto::Property::setter_unit_t
 Union holding an accessor to set double or vector<double> with unit. More...
 
union  Gyoto::Property::getter_unit_t
 Union holding an accessor to get double or vector<double> with unit. More...
 

Namespaces

namespace  Gyoto
 Namespace for the Gyoto library.
 
namespace  Gyoto::Metric
 Access to metrics.
 
namespace  Gyoto::Astrobj
 Access to astronomical objects.
 
namespace  Gyoto::Spectrum
 Spectrum of a simple object (e.g. a Gyoto::Astrobj::Star)
 
namespace  Gyoto::Spectrometer
 Access to spectrometers.
 

Macros

#define GYOTO_PLUGIN
 
#define GYOTO_PROPERTY_THREAD_UNSAFE(class)    bool class::isThreadSafe() const {return false;}
 Define the class as not beeing thread-safe. More...
 
#define GYOTO_PROPERTY_ACCESSORS(class, type, member, method)
 Define a pair of accessors to scalar member (double, long, size_t) More...
 
#define GYOTO_PROPERTY_ACCESSORS_SPECIAL(class, type, member, method, set, get)
 Define a pair of accessors to scalar member (double, long, size_t) More...
 
#define GYOTO_PROPERTY_ACCESSORS_GEOMETRICAL(class, member, method, metric)
 Define 4 accessors to double scalar member in geometrical units. More...
 
#define GYOTO_PROPERTY_ACCESSORS_GEOMETRICAL_SPECIAL(class, member, method, metric, set, get)
 GYOTO_PROPERTY_ACCESSORS_GEOMETRICAL + GYOTO_PROPERTY_ACCESSORS_SPECIAL. More...
 
#define GYOTO_PROPERTY_ACCESSORS_UNIT(class, member, method, unit)
 Define 4 accessors to double scalar member in specified units. More...
 
#define GYOTO_PROPERTY_START(...)
 Start Property list. More...
 
#define GYOTO_PROPERTY_BOOL(...)
 Define a new Property of type bool. More...
 
#define GYOTO_PROPERTY_DOUBLE(...)
 Define a Property of type double. More...
 
#define GYOTO_PROPERTY_DOUBLE_UNIT(...)
 Define a Property of type double with unit. More...
 
#define GYOTO_PROPERTY_VECTOR_DOUBLE(...)
 Define a Property of type vector<double> More...
 
#define GYOTO_PROPERTY_VECTOR_DOUBLE_UNIT(...)
 Define a Property of type vector<double> with unit. More...
 
#define GYOTO_PROPERTY_STRING(...)
 Define a Property of type String. More...
 
#define GYOTO_PROPERTY_FILENAME(...)
 Define a Property of type Filename. More...
 
#define GYOTO_PROPERTY_LONG(...)
 Define a Property of type long. More...
 
#define GYOTO_PROPERTY_UNSIGNED_LONG(...)
 Define a Property of type unsigned long. More...
 
#define GYOTO_PROPERTY_VECTOR_UNSIGNED_LONG(...)
 Define a Property of type vector<unsigned long> More...
 
#define GYOTO_PROPERTY_SIZE_T(...)
 Define a Property of type size_t. More...
 
#define GYOTO_PROPERTY_METRIC(...)
 Define a Property of type Gyoto::Metric::Generic. More...
 
#define GYOTO_PROPERTY_SPECTRUM(...)
 Define a Property of type Gyoto::Spectrum::Generic. More...
 
#define GYOTO_PROPERTY_ASTROBJ(...)
 Define a Property of type Gyoto::Astrobj::Generic. More...
 
#define GYOTO_PROPERTY_SCREEN(...)
 Define a Property of type Gyoto::Screen. More...
 
#define GYOTO_PROPERTY_SPECTROMETER(...)
 Define a Property of type Gyoto::Spectrometer::Generic. More...
 
#define GYOTO_PROPERTY_END(class, next)
 Define class::properties and class::getProperties() More...
 

Detailed Description

Introspectable properties.

Macro Definition Documentation

◆ GYOTO_PROPERTY_ACCESSORS

#define GYOTO_PROPERTY_ACCESSORS (   class,
  type,
  member,
  method 
)
Value:
void class::method(type v) {member=v;} \
type class::method() const {return member;}

Define a pair of accessors to scalar member (double, long, size_t)

Accessors must also be declared in the class declaration, which can be done using #GYOTO_OBJECT_SCALAR_ACCESSORS.

◆ GYOTO_PROPERTY_ACCESSORS_GEOMETRICAL

#define GYOTO_PROPERTY_ACCESSORS_GEOMETRICAL (   class,
  member,
  method,
  metric 
)
Value:
GYOTO_PROPERTY_ACCESSORS(class, double, member, method) \
void class::method(double v, std::string const &u) { \
member=Units::ToGeometrical(v, u, metric); \
} \
double class::method(std::string const &u) const { \
return Units::FromGeometrical(member, u, metric); \
}
#define GYOTO_PROPERTY_ACCESSORS(class, type, member, method)
Define a pair of accessors to scalar member (double, long, size_t)
Definition: GyotoProperty.h:60
double ToGeometrical(double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg)
Convert from arbitrary length unit to geometrical units.
double FromGeometrical(double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg)
Convert to arbitrary length unit from geometrical units.

Define 4 accessors to double scalar member in geometrical units.

Accessors must also be declared in the class declaration, which can be done using GYOTO_OBJECT_ACCESSORS_UNIT.

Parameters
classclass name
membermember holding the value in geometrical unit
methodname for accessors \metric member or expression yielding metric (which defines the geometrical unit)

◆ GYOTO_PROPERTY_ACCESSORS_GEOMETRICAL_SPECIAL

#define GYOTO_PROPERTY_ACCESSORS_GEOMETRICAL_SPECIAL (   class,
  member,
  method,
  metric,
  set,
  get 
)
Value:
GYOTO_PROPERTY_ACCESSORS_SPECIAL(class, double, member, method, set, get) \
void class::method(double v, std::string const &u) { \
member=Units::ToGeometrical(v, u, metric); \
} \
double class::method(std::string const &u) const { \
return Units::FromGeometrical(member, u, metric); \
}
#define GYOTO_PROPERTY_ACCESSORS_SPECIAL(class, type, member, method, set, get)
Define a pair of accessors to scalar member (double, long, size_t)
Definition: GyotoProperty.h:73

GYOTO_PROPERTY_ACCESSORS_GEOMETRICAL + GYOTO_PROPERTY_ACCESSORS_SPECIAL.

Accessors must also be declared in the class declaration, which can be done using GYOTO_OBJECT_ACCESSORS_UNIT.

Parameters
classclass name
membermember holding the value in geometrical unit
methodname for accessors \metric member or expression yielding metric (which defines the geometrical unit)

◆ GYOTO_PROPERTY_ACCESSORS_SPECIAL

#define GYOTO_PROPERTY_ACCESSORS_SPECIAL (   class,
  type,
  member,
  method,
  set,
  get 
)
Value:
void class::method(type v) {member=v; set } \
type class::method() const {get ; return member;}

Define a pair of accessors to scalar member (double, long, size_t)

Accessors must also be declared in the class declaration, which can be done using #GYOTO_OBJECT_SCALAR_ACCESSORS.

This version allows performing sepcial actions in the accessors, in addition to the usual stuff.

◆ GYOTO_PROPERTY_ACCESSORS_UNIT

#define GYOTO_PROPERTY_ACCESSORS_UNIT (   class,
  member,
  method,
  unit 
)
Value:
GYOTO_PROPERTY_ACCESSORS(class, double, member, method) \
void class::method(double v, std::string const &u) { \
method(Units::Converter(u, unit)(v)); \
} \
double class::method(std::string const &u) const { \
return Units::Converter(unit, u)(method()); \
}

Define 4 accessors to double scalar member in specified units.

Accessors must also be declared in the class declaration, which can be done using GYOTO_OBJECT_ACCESSORS_UNIT.

Parameters
classclass name
membermember holding the value in specified unit
methodname for accessors \unit unit

◆ GYOTO_PROPERTY_ASTROBJ

#define GYOTO_PROPERTY_ASTROBJ (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_ASTROBJ_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_ASTROBJ_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type Gyoto::Astrobj::Generic.

◆ GYOTO_PROPERTY_BOOL

#define GYOTO_PROPERTY_BOOL (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
"wrong number of arguments", \
GYOTO_PROPERTY_BOOL_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_BOOL_NODOC(__VA_ARGS__), \
"wrong number of arguments", \
"wrong number of arguments", \
"wrong number of arguments", \
"wrong number of arguments" \
)

Define a new Property of type bool.

◆ GYOTO_PROPERTY_DOUBLE

#define GYOTO_PROPERTY_DOUBLE (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_DOUBLE_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_DOUBLE_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type double.

◆ GYOTO_PROPERTY_DOUBLE_UNIT

#define GYOTO_PROPERTY_DOUBLE_UNIT (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_DOUBLE_UNIT_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_DOUBLE_UNIT_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type double with unit.

◆ GYOTO_PROPERTY_END

#define GYOTO_PROPERTY_END (   class,
  next 
)
Value:
Property(next)}; \
Gyoto::Property const * class::getProperties() const { \
return class::properties; \
} \
const std::string class::builtinPluginValue ( GYOTO_STRINGIFY(GYOTO_PLUGIN) ); \
std::vector<std::string> class::plugins() const { \
if (plugins_.size() == 0) { \
std::vector<std::string> p; \
p.push_back(class::builtinPluginValue); \
return p; \
} \
return plugins_; \
} \
void class::plugins(std::vector<std::string> const & plugname) { \
plugins_=plugname; \
}
#define GYOTO_STRINGIFY(a)
Stringify macro content.
Definition: GyotoDefs.h:566

Define class::properties and class::getProperties()

◆ GYOTO_PROPERTY_FILENAME

#define GYOTO_PROPERTY_FILENAME (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_FILENAME_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_FILENAME_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type Filename.

◆ GYOTO_PROPERTY_LONG

#define GYOTO_PROPERTY_LONG (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_LONG_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_LONG_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type long.

◆ GYOTO_PROPERTY_METRIC

#define GYOTO_PROPERTY_METRIC (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_METRIC_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_METRIC_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type Gyoto::Metric::Generic.

◆ GYOTO_PROPERTY_SCREEN

#define GYOTO_PROPERTY_SCREEN (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_SCREEN_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_SCREEN_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type Gyoto::Screen.

◆ GYOTO_PROPERTY_SIZE_T

#define GYOTO_PROPERTY_SIZE_T (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_SIZE_T_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_SIZE_T_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type size_t.

◆ GYOTO_PROPERTY_SPECTROMETER

#define GYOTO_PROPERTY_SPECTROMETER (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_SPECTROMETER_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_SPECTROMETER_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type Gyoto::Spectrometer::Generic.

◆ GYOTO_PROPERTY_SPECTRUM

#define GYOTO_PROPERTY_SPECTRUM (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_SPECTRUM_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_SPECTRUM_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type Gyoto::Spectrum::Generic.

◆ GYOTO_PROPERTY_START

#define GYOTO_PROPERTY_START (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
"wrong number of arguments", \
"wrong number of arguments", \
"wrong number of arguments", \
"wrong number of arguments", \
GYOTO_PROPERTY_START_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_START_NODOC(__VA_ARGS__), \
"wrong number of arguments" \
)

Start Property list.

Parameters
classClass for which we are defining a Property list
docDocumentation for this class. Optional but recommended.

◆ GYOTO_PROPERTY_STRING

#define GYOTO_PROPERTY_STRING (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_STRING_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_STRING_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type String.

◆ GYOTO_PROPERTY_THREAD_UNSAFE

#define GYOTO_PROPERTY_THREAD_UNSAFE (   class)     bool class::isThreadSafe() const {return false;}

Define the class as not beeing thread-safe.

See also GYOTO_OBJECT_THREAD_SAFETY

◆ GYOTO_PROPERTY_UNSIGNED_LONG

#define GYOTO_PROPERTY_UNSIGNED_LONG (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_UNSIGNED_LONG_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_UNSIGNED_LONG_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type unsigned long.

◆ GYOTO_PROPERTY_VECTOR_DOUBLE

#define GYOTO_PROPERTY_VECTOR_DOUBLE (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_VECTOR_DOUBLE_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_VECTOR_DOUBLE_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type vector<double>

◆ GYOTO_PROPERTY_VECTOR_DOUBLE_UNIT

#define GYOTO_PROPERTY_VECTOR_DOUBLE_UNIT (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_VECTOR_DOUBLE_UNIT_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_VECTOR_DOUBLE_UNIT_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type vector<double> with unit.

◆ GYOTO_PROPERTY_VECTOR_UNSIGNED_LONG

#define GYOTO_PROPERTY_VECTOR_UNSIGNED_LONG (   ...)
Value:
GYOTO_PROPERTY_CHOOSER(,##__VA_ARGS__, \
GYOTO_NOTHING_6, \
GYOTO_NOTHING_5, \
GYOTO_PROPERTY_VECTOR_UNSIGNED_LONG_DOC(__VA_ARGS__), \
GYOTO_PROPERTY_VECTOR_UNSIGNED_LONG_NODOC(__VA_ARGS__), \
GYOTO_NOTHING_2, \
GYOTO_NOTHING_1, \
GYOTO_NOTHING_0 \
)

Define a Property of type vector<unsigned long>