[Debian-astro-commits] [gyoto] 117/221: Split GyotoObject.h and Object.C in Object, Property and Value; Move Gyoto::Property::Value to Gyoto::Value; Add Metric member to Gyoto::Value; Make metric a Property in Astrobj::Generic.

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

thibaut pushed a commit to branch master
in repository gyoto.

commit d7912a1152d7d265381829e78a8f996f62912631
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Thu Nov 27 17:21:39 2014 +0100

    Split GyotoObject.h and Object.C in Object, Property and Value;
    Move Gyoto::Property::Value to Gyoto::Value;
    Add Metric member to Gyoto::Value;
    Make metric a Property in Astrobj::Generic.
---
 include/GyotoAstrobj.h                     |   9 --
 include/GyotoObject.h                      | 201 +----------------------------
 include/{GyotoObject.h => GyotoProperty.h} | 154 ++++------------------
 include/GyotoValue.h                       |  70 ++++++++++
 lib/Astrobj.C                              |  10 +-
 lib/KerrBL.C                               |   1 +
 lib/KerrKS.C                               |   1 +
 lib/Makefile.am                            |   6 +-
 lib/Makefile.in                            |  20 +--
 lib/Metric.C                               |   1 +
 lib/Minkowski.C                            |   1 +
 lib/NumericalMetricLorene.C                |   1 +
 lib/Object.C                               | 115 ++++-------------
 lib/Property.C                             |  69 ++++++++++
 lib/RotStar3_1.C                           |   1 +
 lib/StandardAstrobj.C                      |   1 +
 lib/Value.C                                |  42 ++++++
 yorick/gyoto_utils.C                       |  16 ++-
 18 files changed, 278 insertions(+), 441 deletions(-)

diff --git a/include/GyotoAstrobj.h b/include/GyotoAstrobj.h
index 0d16bfa..92dfa69 100644
--- a/include/GyotoAstrobj.h
+++ b/include/GyotoAstrobj.h
@@ -353,15 +353,6 @@ class Gyoto::Astrobj::Generic : public Gyoto::SmartPointee {
 
 #ifdef GYOTO_USE_XERCES
   /**
-   * \brief Fill XML section
-   *
-   * Astrobj implementations should impement fillElement to save their
-   * parameters to XML and call the generic implementation to save
-   * generic parts such as Flag_radtrans: Generic::fillElement(fmp).
-   */
-  virtual void fillElement(FactoryMessenger *fmp) const ;
-
-  /**
    * \brief Main loop in Subcontractor_t function
    *
    * The Subcontractor_t function for each Astrobj kind should look
diff --git a/include/GyotoObject.h b/include/GyotoObject.h
index b9b2330..5769b4a 100644
--- a/include/GyotoObject.h
+++ b/include/GyotoObject.h
@@ -33,207 +33,16 @@
 namespace Gyoto {
   class Object;
   class Property;
+  class Value;
   class FactoryMessenger;
 }
 
-/// Make an NULL-terminated array of ancestors
-/**
- * Called automatically in GYOTO_PROPERTY_*
- */
-#define GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor)	\
-  Property const * const name##_ancestors[] = {ancestor, NULL}
-
-/// Define a new Property of type Bool
-/*
- * Declares a static variable named "name". name and namef should not
- * be quoted.
- *
- * \param[in] class name
- * \param[in] name name of property if true;
- * \param[in] namef name of property if false;
- * \param[in] fname name of functions for setting or getting the property
- * \param[in] ancestor pointer to next Property instance
- */
-#define GYOTO_PROPERTY_BOOL(class, name, namef, fname, ancestor) \
-  GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor); \
-  Property const name				 \
-  (#name,					 \
-   #namef,								\
-   (Gyoto::Property::set_bool_t)&class :: fname,			\
-   (Gyoto::Property::get_bool_t)&class :: fname,			\
-   name##_ancestors)
-
-/// Define a Property of type Double
-#define GYOTO_PROPERTY_DOUBLE(class, name, fname, ancestor)	\
-  GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor); \
-  Property const name \
-        (#name, \
-	   (Gyoto::Property::set_double_t)&class::fname,	\
-	   (Gyoto::Property::get_double_t)&class::fname,	\
-         name##_ancestors)
-
-/// Define a Property of type Double supporting unit
-#define GYOTO_PROPERTY_DOUBLE_UNIT(class, name, fname, ancestor) \
-  GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor); \
-  Property const name \
-        (#name, \
-	 (Gyoto::Property::set_double_t)&class::fname,	\
-	 (Gyoto::Property::get_double_t)&class::fname,	\
-	 (Gyoto::Property::set_double_unit_t)&class::fname,	\
-	 (Gyoto::Property::get_double_unit_t)&class::fname,	\
-         name##_ancestors)
-
-/// Define a Property of type Filename
-#define GYOTO_PROPERTY_FILENAME(class, name, fname, ancestor)	\
-  GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor); \
-  Property const name \
-        (#name, \
-	   (Gyoto::Property::set_string_t)&class::fname,	\
-	   (Gyoto::Property::get_string_t)&class::fname,	\
-         name##_ancestors, true)
-
-/// Define a Property of type String
-#define GYOTO_PROPERTY_STRING(class, name, fname, ancestor)	\
-  GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor); \
-  Property const name \
-        (#name, \
-	   (Gyoto::Property::set_string_t)&class::fname,	\
-	   (Gyoto::Property::get_string_t)&class::fname,	\
-         name##_ancestors, false)
-
-/// Define a Property of type String
-#define GYOTO_PROPERTY_VECTOR_DOUBLE(class, name, fname, ancestor)	\
-  GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor); \
-  Property const name \
-        (#name, \
-	   (Gyoto::Property::set_vector_double_t)&class::fname,	\
-	   (Gyoto::Property::get_vector_double_t)&class::fname,	\
-         name##_ancestors)
-
-/// Define class::properties and class::getProperties() 
-#define GYOTO_PROPERTY_FINALIZE(class, ancestor)		\
-  Property const * const class::properties = ancestor;		\
-  Property const * class::getProperties() const {		\
-    return class::properties;					\
- }
-
 /// Declare  class::properties and class::getProperties()
 #define GYOTO_OBJECT \
   static Property const * const properties;		\
   virtual Property const * getProperties() const
 
 /**
- * \brief Property
- */
-class Gyoto::Property
-{
- private:
-
- public:
-  enum type_e {double_t, long_t, bool_t, string_t, filename_t,
-	       vector_double_t};
-  std::string name;
-  std::string name_false;
-  int type;
-  typedef void (Object::* set_double_t)(double val);
-  typedef double (Object::* get_double_t)() const;
-  typedef void (Object::* set_double_unit_t)(double val,
-					     std::string const &unit);
-  typedef double (Object::* get_double_unit_t)(std::string const &unit) const;
-  typedef void (Object::* set_long_t)(double val);
-  typedef long (Object::* get_long_t)() const;
-  typedef void (Object::* set_bool_t)(bool val);
-  typedef bool (Object::* get_bool_t)() const;
-  typedef void (Object::* set_string_t)(std::string const&);
-  typedef std::string (Object::* get_string_t)() const;
-  typedef void (Object::* set_fname_t)(std::string const&);
-  typedef std::string (Object::* get_fname_t)() const;
-  typedef void (Object::* set_vector_double_t)(std::vector<double> const&);
-  typedef std::vector<double> (Object::* get_vector_double_t)() const;
-  union setter_t {
-    set_double_t set_double;
-    set_long_t set_long;
-    set_bool_t set_bool;
-    set_string_t set_string;
-    set_vector_double_t set_vdouble;
-  };
-  union getter_t {
-    get_double_t get_double;
-    get_long_t get_long;
-    get_bool_t get_bool;
-    get_string_t get_string;
-    get_vector_double_t get_vdouble;
-  };
-  union setter_unit_t {set_double_unit_t set_double;};
-  union getter_unit_t {get_double_unit_t get_double;};
-  setter_t setter;
-  getter_t getter;
-  setter_unit_t setter_unit;
-  getter_unit_t getter_unit;
-  Property const * const  * const parents;
-  
-  Property(std::string name,
-	   set_double_t set_double,
-	   get_double_t get_double,
-	   Property const * const * ancestors);
-
-  Property(std::string name,
-	   set_double_t set_double,
-	   get_double_t get_double,
-	   set_double_unit_t set_double_unit,
-	   get_double_unit_t get_double_unit,
-	   Property const * const * ancestors);
-
-  Property(std::string name,
-	   std::string name_false,
-	   set_bool_t set_bool,
-	   get_bool_t get_bool,
-	   Property const * const * ancestors);
-
-  Property(std::string name,
-	   set_string_t set_string,
-	   get_string_t get_string,
-	   Property const * const * ancestors,
-	   bool is_filename=false);
-
-  Property(std::string name,
-	   set_vector_double_t set_vdouble,
-	   get_vector_double_t get_vdouble,
-	   Property const * const * ancestors);
-
-  Property const * find(std::string name) const;
-
-  class Value {
-  public:
-    Value();
-    ~Value();
-
-    double Double;
-    Value(double);
-    operator double() const;
-
-    bool Bool;
-    Value(bool);
-    operator bool() const;
-
-    long Long;
-    Value(long);
-    operator long() const;
-
-    std::string String;
-    Value(std::string);
-    operator std::string() const;
-
-    std::vector<double> VDouble;
-    Value(std::vector<double>);
-    operator std::vector<double>() const;
-
-  };
-
-};
-
-
-/**
  * \brief Object with properties
  */
 class Gyoto::Object
@@ -246,11 +55,11 @@ class Gyoto::Object
   Object () ;
   Object (Object const &orig) ;
   virtual ~Object();
-  void set(Property const &p, Property::Value const & val);
-  void set(Property const &p, Property::Value const & val, std::string const &unit);
+  void set(Property const &p, Value val);
+  void set(Property const &p, Value val, std::string const &unit);
 
-  Property::Value get(Property const &p) const;
-  Property::Value get(Property const &p, std::string const &unit) const;
+  Value get(Property const &p) const;
+  Value get(Property const &p, std::string const &unit) const;
 
   Property const * property(std::string const pname) const;
 
diff --git a/include/GyotoObject.h b/include/GyotoProperty.h
similarity index 63%
copy from include/GyotoObject.h
copy to include/GyotoProperty.h
index b9b2330..ca99499 100644
--- a/include/GyotoObject.h
+++ b/include/GyotoProperty.h
@@ -23,8 +23,8 @@
  */
 
 
-#ifndef __GyotoObject_H_
-#define __GyotoObject_H_
+#ifndef __GyotoProperty_H_
+#define __GyotoProperty_H_
 
 #include "GyotoConfig.h"
 #include <string>
@@ -33,7 +33,8 @@
 namespace Gyoto {
   class Object;
   class Property;
-  class FactoryMessenger;
+  namespace Metric { class Generic; }
+  template <class T> class SmartPointer;
 }
 
 /// Make an NULL-terminated array of ancestors
@@ -101,7 +102,7 @@ namespace Gyoto {
 	   (Gyoto::Property::get_string_t)&class::fname,	\
          name##_ancestors, false)
 
-/// Define a Property of type String
+/// Define a Property of type vector<double>
 #define GYOTO_PROPERTY_VECTOR_DOUBLE(class, name, fname, ancestor)	\
   GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor); \
   Property const name \
@@ -110,6 +111,15 @@ namespace Gyoto {
 	   (Gyoto::Property::get_vector_double_t)&class::fname,	\
          name##_ancestors)
 
+/// Define a Property of type Gyoto::Metric::Generic
+#define GYOTO_PROPERTY_METRIC(class, name, fname, ancestor)	\
+  GYOTO_PROPERTY_MAKE_ANCESTORS(name, ancestor);		\
+  Property const name						\
+        (#name,								\
+	 (Gyoto::Property::set_metric_t)&class::fname,			\
+	 (Gyoto::Property::get_metric_t)&class::fname,			\
+	name##_ancestors)
+
 /// Define class::properties and class::getProperties() 
 #define GYOTO_PROPERTY_FINALIZE(class, ancestor)		\
   Property const * const class::properties = ancestor;		\
@@ -117,11 +127,6 @@ namespace Gyoto {
     return class::properties;					\
  }
 
-/// Declare  class::properties and class::getProperties()
-#define GYOTO_OBJECT \
-  static Property const * const properties;		\
-  virtual Property const * getProperties() const
-
 /**
  * \brief Property
  */
@@ -131,7 +136,7 @@ class Gyoto::Property
 
  public:
   enum type_e {double_t, long_t, bool_t, string_t, filename_t,
-	       vector_double_t};
+	       vector_double_t, metric_t};
   std::string name;
   std::string name_false;
   int type;
@@ -150,12 +155,19 @@ class Gyoto::Property
   typedef std::string (Object::* get_fname_t)() const;
   typedef void (Object::* set_vector_double_t)(std::vector<double> const&);
   typedef std::vector<double> (Object::* get_vector_double_t)() const;
+
+  typedef void (Object::* set_metric_t)
+    (Gyoto::SmartPointer<Gyoto::Metric::Generic>);
+  typedef Gyoto::SmartPointer<Gyoto::Metric::Generic>
+    (Object::* get_metric_t)() const;
+
   union setter_t {
     set_double_t set_double;
     set_long_t set_long;
     set_bool_t set_bool;
     set_string_t set_string;
     set_vector_double_t set_vdouble;
+    set_metric_t set_metric;
   };
   union getter_t {
     get_double_t get_double;
@@ -163,6 +175,7 @@ class Gyoto::Property
     get_bool_t get_bool;
     get_string_t get_string;
     get_vector_double_t get_vdouble;
+    get_metric_t get_metric;
   };
   union setter_unit_t {set_double_unit_t set_double;};
   union getter_unit_t {get_double_unit_t get_double;};
@@ -201,123 +214,12 @@ class Gyoto::Property
 	   get_vector_double_t get_vdouble,
 	   Property const * const * ancestors);
 
-  Property const * find(std::string name) const;
-
-  class Value {
-  public:
-    Value();
-    ~Value();
-
-    double Double;
-    Value(double);
-    operator double() const;
-
-    bool Bool;
-    Value(bool);
-    operator bool() const;
-
-    long Long;
-    Value(long);
-    operator long() const;
-
-    std::string String;
-    Value(std::string);
-    operator std::string() const;
-
-    std::vector<double> VDouble;
-    Value(std::vector<double>);
-    operator std::vector<double>() const;
-
-  };
-
-};
-
-
-/**
- * \brief Object with properties
- */
-class Gyoto::Object
-{
- protected:
-  std::string kind_;
- public:
-  GYOTO_OBJECT;
-  Object (std::string const &kind) ;
-  Object () ;
-  Object (Object const &orig) ;
-  virtual ~Object();
-  void set(Property const &p, Property::Value const & val);
-  void set(Property const &p, Property::Value const & val, std::string const &unit);
-
-  Property::Value get(Property const &p) const;
-  Property::Value get(Property const &p, std::string const &unit) const;
-
-  Property const * property(std::string const pname) const;
-
-#ifdef GYOTO_USE_XERCES
-  void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const ;
-
-  /// Called from Factory
-  /**
-   * Object implementations should impement fillElement to save their
-   * parameters to XML and call the Metric::fillElement(fmp) for the
-   * shared properties
-   */
-  virtual void fillElement(Gyoto::FactoryMessenger *fmp) const ;
-
-  /**
-   * \brief Main loop in Subcontractor_t function
-   *
-   * The Subcontractor_t function for each Metric kind should look
-   * somewhat like this (templated as
-   * Gyoto::Metric::Subcontractor<MyKind>):
-\code
-SmartPointer<Metric::Generic>
-Gyoto::Metric::MyKind::Subcontractor(FactoryMessenger* fmp) {
-  SmartPointer<MyKind> gg = new MyKind();
-  gg -> setParameters(fmp);
-  return gg;
-}
-\endcode
-   *
-   * Each metric kind should implement setParameter(string name,
-   * string content, string unit) to interpret the individual XML
-   * elements. setParameters() can be overloaded in case the specific
-   * Metric class needs low level access to the FactoryMessenger. See
-   * Gyoto::Astrobj::UniformSphere::setParameters().
-   */
-  virtual void setParameters(Gyoto::FactoryMessenger *fmp) ;
-#endif
-  /**
-   * \brief Set parameter by name
-   *
-   * Assume MyKind is a subclass of Metric::Generic which has two
-   * members (a string StringMember and a double DoubleMember):
-\code
-int MyKind::setParameter(std::string name, std::string content, std::string unit) {
- if      (name=="StringMember") setStringMember(content);
- else if (name=="DoubleMember") setDoubleMemeber(atof(content.c_str()), unit);
- else return Generic::setParameter(name, content, unit);
- return 0;
-}
-\endcode
-   * If MyKind is not a direct subclass of Generic, it should call the
-   * corresponding setParameter() implementation instead of
-   * Generic::setParameter().
-   *
-   * \param name XML name of the parameter
-   * \param content string representation of the value
-   * \param unit string representation of the unit
-   * \return 0 if this parameter is known, 1 if it is not.
-   */
-  virtual int setParameter(std::string name,
-			    std::string content,
-			    std::string unit);
+  Property(std::string name,
+	   set_metric_t set_metric,
+	   get_metric_t get_metric,
+	   Property const * const * ancestors);
 
-  virtual void setParameter(Gyoto::Property const &p,
-			    std::string const &name,
-			    std::string const &content,
-			    std::string const &unit);
+  Property const * find(std::string name) const;
 
 };
 
diff --git a/include/GyotoValue.h b/include/GyotoValue.h
new file mode 100644
index 0000000..d81ea6e
--- /dev/null
+++ b/include/GyotoValue.h
@@ -0,0 +1,70 @@
+/**
+ * \file GyotoObject.h
+ * \brief Introspectbale objects 
+ */
+
+/*
+    Copyright 2014 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 __GyotoValue_H_
+#define __GyotoValue_H_
+
+#include "GyotoConfig.h"
+#include "GyotoSmartPointer.h"
+#include <string>
+#include <vector>
+
+namespace Gyoto {
+  namespace Metric {class Generic;}
+}
+
+class Gyoto::Value {
+ public:
+  Value();
+  ~Value();
+
+  Value& operator=(Value const&);
+
+  double Double;
+  Value(double);
+  operator double() const;
+
+  bool Bool;
+  Value(bool);
+  operator bool() const;
+
+  long Long;
+  Value(long);
+  operator long() const;
+
+  std::string String;
+  Value(std::string);
+  operator std::string() const;
+
+  std::vector<double> VDouble;
+  Value(std::vector<double>);
+  operator std::vector<double>() const;
+
+  Gyoto::SmartPointer<Gyoto::Metric::Generic> Metric;
+  Value(Gyoto::SmartPointer<Gyoto::Metric::Generic>);
+  operator Gyoto::SmartPointer<Gyoto::Metric::Generic>();
+};
+
+#endif
diff --git a/lib/Astrobj.C b/lib/Astrobj.C
index 573edc3..1bd13f6 100644
--- a/lib/Astrobj.C
+++ b/lib/Astrobj.C
@@ -24,6 +24,7 @@
 #include "GyotoPhoton.h"
 #include "GyotoRegister.h"
 #include "GyotoFactoryMessenger.h"
+#include "GyotoProperty.h"
 
 // SYSTEM HEADERS
 #include <iostream>
@@ -48,8 +49,8 @@ GYOTO_PROPERTY_BOOL(Generic, RadiativeQ, NoRadiativeQ,
 GYOTO_PROPERTY_BOOL(Generic, Redshift, NoRedshift,
 		    redshift, &RadiativeQ);
 GYOTO_PROPERTY_DOUBLE_UNIT(Generic, RMax, rMax, &Redshift);
-GYOTO_PROPERTY_FINALIZE(Astrobj::Generic, &RMax);
-
+GYOTO_PROPERTY_METRIC(Generic, Metric, metric, &RMax);
+GYOTO_PROPERTY_FINALIZE(Generic, &::Metric);
 
 Generic::Generic(string kin) :
   SmartPointee(kin), gg_(NULL), rmax_(DBL_MAX), flag_radtransf_(0),
@@ -121,11 +122,6 @@ void Generic::rMax(double val, string const &unit) {
   rMax(Units::ToGeometrical(val, unit, gg_)); }
 
 #ifdef GYOTO_USE_XERCES
-void Generic::fillElement(FactoryMessenger *fmp) const {
-  fmp -> metric(gg_);
-  Object::fillElement(fmp);
-}
-
 void Generic::setParameters(FactoryMessenger *fmp) {
   if (fmp) metric(fmp->metric());
   Object::setParameters(fmp);
diff --git a/lib/KerrBL.C b/lib/KerrBL.C
index fb75163..509805b 100644
--- a/lib/KerrBL.C
+++ b/lib/KerrBL.C
@@ -22,6 +22,7 @@
 #include "GyotoKerrBL.h"
 #include "GyotoWorldline.h"
 #include "GyotoError.h"
+#include "GyotoProperty.h"
 
 #include <iostream>
 #include <cmath>
diff --git a/lib/KerrKS.C b/lib/KerrKS.C
index 5970a26..ba42cde 100644
--- a/lib/KerrKS.C
+++ b/lib/KerrKS.C
@@ -22,6 +22,7 @@
 #include "GyotoKerrKS.h"
 #include "GyotoWorldline.h"
 #include "GyotoError.h"
+#include "GyotoProperty.h"
 
 #include <iostream>
 #include <cmath>
diff --git a/lib/Makefile.am b/lib/Makefile.am
index bfa32f0..efe4546 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -14,11 +14,13 @@ library_include_HEADERS=$(top_srcdir)/include/*.h $(top_builddir)/include/*.h
 
 # MAIN LIBRARY
 lib_LTLIBRARIES = libgyoto at FEATURES@.la
-libgyoto at FEATURES@_la_SOURCES =  Astrobj.C Factory.C Register.C SmartPointer.C Utils.C Metric.C	\
+libgyoto at FEATURES@_la_SOURCES =  \
+	Value.C Property.C Object.C \
+	Astrobj.C Factory.C Register.C SmartPointer.C Utils.C Metric.C	\
 	WIP.C Worldline.C Photon.C Scenery.C			\
 	WorldlineIntegState.C Error.C Screen.C Spectrum.C		\
 	Spectrometer.C ComplexSpectrometer.C UniformSpectrometer.C \
-	ThinDisk.C Converters.C Functors.C Hooks.C Object.C
+	ThinDisk.C Converters.C Functors.C Hooks.C
 libgyoto at FEATURES@_la_LIBS = $(XERCESLDFLAGS)
 libgyoto at FEATURES@_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(VERSINFO)
 
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 86dbc67..f5bb0bb 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -165,12 +165,12 @@ libgyoto_stdplug_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_CXXFLAGS) $(CXXFLAGS) $(libgyoto_stdplug_la_LDFLAGS) \
 	$(LDFLAGS) -o $@
 libgyoto at FEATURES@_la_LIBADD =
-am_libgyoto at FEATURES@_la_OBJECTS = Astrobj.lo Factory.lo Register.lo \
-	SmartPointer.lo Utils.lo Metric.lo WIP.lo Worldline.lo \
-	Photon.lo Scenery.lo WorldlineIntegState.lo Error.lo Screen.lo \
-	Spectrum.lo Spectrometer.lo ComplexSpectrometer.lo \
-	UniformSpectrometer.lo ThinDisk.lo Converters.lo Functors.lo \
-	Hooks.lo Object.lo
+am_libgyoto at FEATURES@_la_OBJECTS = Value.lo Property.lo Object.lo \
+	Astrobj.lo Factory.lo Register.lo SmartPointer.lo Utils.lo \
+	Metric.lo WIP.lo Worldline.lo Photon.lo Scenery.lo \
+	WorldlineIntegState.lo Error.lo Screen.lo Spectrum.lo \
+	Spectrometer.lo ComplexSpectrometer.lo UniformSpectrometer.lo \
+	ThinDisk.lo Converters.lo Functors.lo Hooks.lo
 libgyoto at FEATURES@_la_OBJECTS = $(am_libgyoto at FEATURES@_la_OBJECTS)
 libgyoto at FEATURES@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
@@ -425,11 +425,13 @@ library_include_HEADERS = $(top_srcdir)/include/*.h $(top_builddir)/include/*.h
 
 # MAIN LIBRARY
 lib_LTLIBRARIES = libgyoto at FEATURES@.la
-libgyoto at FEATURES@_la_SOURCES = Astrobj.C Factory.C Register.C SmartPointer.C Utils.C Metric.C	\
+libgyoto at FEATURES@_la_SOURCES = \
+	Value.C Property.C Object.C \
+	Astrobj.C Factory.C Register.C SmartPointer.C Utils.C Metric.C	\
 	WIP.C Worldline.C Photon.C Scenery.C			\
 	WorldlineIntegState.C Error.C Screen.C Spectrum.C		\
 	Spectrometer.C ComplexSpectrometer.C UniformSpectrometer.C \
-	ThinDisk.C Converters.C Functors.C Hooks.C Object.C
+	ThinDisk.C Converters.C Functors.C Hooks.C
 
 libgyoto at FEATURES@_la_LIBS = $(XERCESLDFLAGS)
 libgyoto at FEATURES@_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(VERSINFO)
@@ -608,6 +610,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Photon.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolishDoughnut.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PowerLawSpectrum.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Property.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Register.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Scenery.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Screen.Plo at am__quote@
@@ -626,6 +629,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/UniformSpectrometer.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/UniformSphere.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Utils.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Value.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WIP.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Worldline.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WorldlineIntegState.Plo at am__quote@
diff --git a/lib/Metric.C b/lib/Metric.C
index bb21558..2986300 100644
--- a/lib/Metric.C
+++ b/lib/Metric.C
@@ -23,6 +23,7 @@
 #include "GyotoMetric.h"
 #include "GyotoFactoryMessenger.h"
 #include "GyotoConverters.h"
+#include "GyotoProperty.h"
 #include <cmath>
 #include <string>
 #include <sstream>
diff --git a/lib/Minkowski.C b/lib/Minkowski.C
index f9e87d3..c997400 100644
--- a/lib/Minkowski.C
+++ b/lib/Minkowski.C
@@ -21,6 +21,7 @@
 #include "GyotoFactoryMessenger.h"
 #include "GyotoMinkowski.h"
 #include "GyotoError.h"
+#include "GyotoProperty.h"
 #include <cmath>
 
 using namespace std ; 
diff --git a/lib/NumericalMetricLorene.C b/lib/NumericalMetricLorene.C
index 071e61b..32db31c 100644
--- a/lib/NumericalMetricLorene.C
+++ b/lib/NumericalMetricLorene.C
@@ -13,6 +13,7 @@ using namespace Lorene;
 #include "GyotoNumericalMetricLorene.h"
 #include "GyotoError.h"
 #include "GyotoFactoryMessenger.h"
+#include "GyotoProperty.h"
 
 //Std headers
 #include <iostream>
diff --git a/lib/Object.C b/lib/Object.C
index 8b68725..2090b79 100644
--- a/lib/Object.C
+++ b/lib/Object.C
@@ -1,6 +1,9 @@
 #include "GyotoObject.h"
+#include "GyotoProperty.h"
+#include "GyotoValue.h"
 #include "GyotoError.h"
 #include "GyotoFactoryMessenger.h"
+#include "GyotoMetric.h"
 
 #include <iostream>
 
@@ -9,28 +12,6 @@ using namespace Gyoto ;
 
 GYOTO_PROPERTY_FINALIZE(Object, NULL);
 
-/// Value
-
-Property::Value::Value() {}
-Property::Value::~Value() {}
-
-Property::Value::Value(double val) : Double(val) {}
-Property::Value::operator double() const {return Double;}
-
-Property::Value::Value(bool val) : Bool(val) {}
-Property::Value::operator bool() const {return Bool;}
-
-Property::Value::Value(long val) : Long(val) {}
-Property::Value::operator long() const {return Long;}
-
-Property::Value::Value(std::string val) : String(val) {}
-Property::Value::operator std::string() const {return String;}
-
-Property::Value::Value(std::vector<double> val) : VDouble(val) {}
-Property::Value::operator std::vector<double>() const {return VDouble;}
-
-/// Object
-
 Gyoto::Object::Object(std::string const &name):kind_(name) {}
 Gyoto::Object::Object():kind_("") {}
 Gyoto::Object::Object(Object const &o):kind_(o.kind_) {}
@@ -38,7 +19,7 @@ Gyoto::Object::~Object() {}
 
 
 void Object::set(Property const &p,
-		 Property::Value const &val,
+		 Value val,
 		 std::string const &unit) {
 
   if (p.type == Property::double_t) {
@@ -60,7 +41,7 @@ void Object::set(Property const &p,
 
 }
 
-void Object::set(Property const &p, Property::Value const &val) {
+void Object::set(Property const &p, Value val) {
 # define ___local_case(type)			\
   case Property::type##_t:			\
     {						\
@@ -83,13 +64,14 @@ void Object::set(Property const &p, Property::Value const &val) {
       (this->*set)(val);
     }
     break;
+    ___local_case(metric);
   default:
     throwError("Unimplemented Property type in Object::set");
   }
 # undef ___local_case
 }
 
-Property::Value Object::get(Property const &p,
+Value Object::get(Property const &p,
 			    std::string const &unit) const {
 
   if (p.type == Property::double_t) {
@@ -105,17 +87,17 @@ Property::Value Object::get(Property const &p,
   return get(p);
 }
 
-Property::Value Object::get(Property const &p) const {
+Value Object::get(Property const &p) const {
 # define ___local_case(type) \
   case Property::type##_t:     \
     {			     \
     Property::get_##type##_t get = p.getter.get_##type;	\
     if (!get) throwError("Can't get this Property");	\
-    val = (this->*get)();				\
+    val = Value((this->*get)());			\
     }							\
     break
 
-  Property::Value val;
+  Gyoto::Value val;
   switch (p.type) {
     ___local_case(bool);
     ___local_case(double);
@@ -129,6 +111,7 @@ Property::Value Object::get(Property const &p) const {
       val = (this->*get)();
     }
     break;
+    ___local_case(metric);
   default:
     throwError("Unimplemented Property type in Object::get");
   }
@@ -157,6 +140,9 @@ void Object::fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const
   case Property::vector_double_t:
     fmp->setParameter(name, get(p).VDouble);
     break;
+  case Property::metric_t:
+    fmp->metric(get(p));
+    break;
   default:
     throwError("Property type unimplemented in Object::fillProperty()");
   }
@@ -187,9 +173,16 @@ void Object::setParameters(Gyoto::FactoryMessenger *fmp)  {
 	// this entity
 	setParameter(name, content, unit);
       } else {
-	if (prop->type == Property::filename_t)
+	switch (prop->type) {
+	case Property::metric_t:
+	  set(*prop, fmp->metric());
+	  break;
+	case Property::filename_t:
 	  content = fmp->fullPath(content);
-	setParameter(*prop, name, content, unit);
+	  // no 'break;' here, we need to proceed
+	default:
+	  setParameter(*prop, name, content, unit);
+	}
       }
     }
   GYOTO_DEBUG << "Done processing parameters" << endl;
@@ -199,7 +192,7 @@ void Object::setParameters(Gyoto::FactoryMessenger *fmp)  {
 
 void Object::setParameter(Property const &p, string const &name,
 			  string const & content, string const & unit) {
-  Property::Value val;
+  Value val;
   switch (p.type) {
   case Property::bool_t:
     val = (name==p.name);
@@ -215,6 +208,8 @@ void Object::setParameter(Property const &p, string const &name,
   case Property::vector_double_t:
     val = FactoryMessenger::parseArray(content);
     break;
+  case Property::metric_t:
+    throwError("Metric can't be set using setParameter()");
   default:
     throwError("Property type unimplemented in Object::setParameter()");
   }
@@ -227,61 +222,3 @@ int Object::setParameter(string name, string content, string unit) {
   setParameter(*prop, name, content, unit);
   return 0;
 }
-
-//// Property
-
-Property::Property(string n, set_double_t set, get_double_t get,
-		   Property const * const * ancestors)
-  : name(n), type(double_t), parents(ancestors) {
-  setter.set_double=set;
-  getter.get_double=get;
-  setter_unit.set_double=NULL;
-  getter_unit.get_double=NULL;
-}
-
-Property::Property(string n, set_double_t set, get_double_t get,
-		   set_double_unit_t setu, get_double_unit_t getu,
-		   Property const * const * ancestors)
-  : name(n), type(double_t), parents(ancestors) {
-  setter.set_double=set;
-  getter.get_double=get;
-  setter_unit.set_double=setu;
-  getter_unit.get_double=getu;
-}
-
-Property::Property(string n, string nf, set_bool_t set, get_bool_t get,
-		   Property const * const * ancestors)
-  : name(n), name_false(nf), type(bool_t), parents(ancestors) {
-  setter.set_bool=set;
-  getter.get_bool=get;
-}
-
-Property::Property(string n, set_string_t set, get_string_t get,
-		   Property const * const * ancestors,
-		   bool is_filename)
-  : name(n), type(is_filename?filename_t:string_t), parents(ancestors) {
-  setter.set_string=set;
-  getter.get_string=get;
-}
-
-Property::Property(string n,
-		   set_vector_double_t set,
-		   get_vector_double_t get,
-		   Property const * const * ancestors)
-  : name(n), type(vector_double_t), parents(ancestors) {
-  setter.set_vdouble=set;
-  getter.get_vdouble=get;
-}
-
-Property const * Property::find(std::string n) const {
-  if (this == NULL) return NULL;
-  if (name == n || (type == bool_t && name_false == n)) return this;
-  if (parents == NULL) return NULL;
-  Property const * const * p ;
-  Property const * result = NULL;
-  for (p=parents;  *p != NULL; ++p) {
-    result = (*p)->find(n);
-    if (result) break;
-  }
-  return result; 
-}
diff --git a/lib/Property.C b/lib/Property.C
new file mode 100644
index 0000000..a4b54b3
--- /dev/null
+++ b/lib/Property.C
@@ -0,0 +1,69 @@
+#include "GyotoProperty.h"
+
+using namespace std ;
+using namespace Gyoto ;
+
+Property::Property(string n, set_double_t set, get_double_t get,
+		   Property const * const * ancestors)
+  : name(n), type(double_t), parents(ancestors) {
+  setter.set_double=set;
+  getter.get_double=get;
+  setter_unit.set_double=NULL;
+  getter_unit.get_double=NULL;
+}
+
+Property::Property(string n, set_double_t set, get_double_t get,
+		   set_double_unit_t setu, get_double_unit_t getu,
+		   Property const * const * ancestors)
+  : name(n), type(double_t), parents(ancestors) {
+  setter.set_double=set;
+  getter.get_double=get;
+  setter_unit.set_double=setu;
+  getter_unit.get_double=getu;
+}
+
+Property::Property(string n, string nf, set_bool_t set, get_bool_t get,
+		   Property const * const * ancestors)
+  : name(n), name_false(nf), type(bool_t), parents(ancestors) {
+  setter.set_bool=set;
+  getter.get_bool=get;
+}
+
+Property::Property(string n, set_string_t set, get_string_t get,
+		   Property const * const * ancestors,
+		   bool is_filename)
+  : name(n), type(is_filename?filename_t:string_t), parents(ancestors) {
+  setter.set_string=set;
+  getter.get_string=get;
+}
+
+Property::Property(string n,
+		   set_vector_double_t set,
+		   get_vector_double_t get,
+		   Property const * const * ancestors)
+  : name(n), type(vector_double_t), parents(ancestors) {
+  setter.set_vdouble=set;
+  getter.get_vdouble=get;
+}
+
+Property::Property(string n,
+		   set_metric_t set,
+		   get_metric_t get,
+		   Property const * const * ancestors)
+  : name(n), type(metric_t), parents(ancestors) {
+  setter.set_metric=set;
+  getter.get_metric=get;
+}
+
+Property const * Property::find(std::string n) const {
+  if (this == NULL) return NULL;
+  if (name == n || (type == bool_t && name_false == n)) return this;
+  if (parents == NULL) return NULL;
+  Property const * const * p ;
+  Property const * result = NULL;
+  for (p=parents;  *p != NULL; ++p) {
+    result = (*p)->find(n);
+    if (result) break;
+  }
+  return result; 
+}
diff --git a/lib/RotStar3_1.C b/lib/RotStar3_1.C
index 725f68a..7fa3135 100644
--- a/lib/RotStar3_1.C
+++ b/lib/RotStar3_1.C
@@ -31,6 +31,7 @@ using namespace Lorene;
 #include "GyotoRotStar3_1.h"
 #include "GyotoError.h"
 #include "GyotoFactoryMessenger.h"
+#include "GyotoProperty.h"
 
 #include <iostream>
 #include <cmath>
diff --git a/lib/StandardAstrobj.C b/lib/StandardAstrobj.C
index 1d8c399..83f5894 100644
--- a/lib/StandardAstrobj.C
+++ b/lib/StandardAstrobj.C
@@ -24,6 +24,7 @@
 #include "GyotoPhoton.h"
 #include "GyotoRegister.h"
 #include "GyotoFactoryMessenger.h"
+#include "GyotoProperty.h"
 
 // SYSTEM HEADERS
 #include <iostream>
diff --git a/lib/Value.C b/lib/Value.C
new file mode 100644
index 0000000..a34d88d
--- /dev/null
+++ b/lib/Value.C
@@ -0,0 +1,42 @@
+#include "GyotoValue.h"
+#include "GyotoMetric.h"
+#include <iostream>
+using namespace Gyoto ;
+using namespace std ;
+
+/// Value
+
+Value::Value() {}
+Value::~Value() {}
+
+Value::Value(double val) : Double(val) {}
+Value::operator double() const {return Double;}
+
+Value::Value(bool val) : Bool(val) {}
+Value::operator bool() const {return Bool;}
+
+Value::Value(long val) : Long(val) {}
+Value::operator long() const {return Long;}
+
+Value::Value(std::string val) : String(val) {}
+Value::operator std::string() const {return String;}
+
+Value::Value(std::vector<double> val) : VDouble(val) {}
+Value::operator std::vector<double>() const {return VDouble;}
+
+Value::Value(Gyoto::SmartPointer<Gyoto::Metric::Generic> p)
+  : Metric(p) {cerr << "In Value constructor: Metric==" << Metric() << endl;}
+Value::operator Gyoto::SmartPointer<Gyoto::Metric::Generic>()
+{ return Metric; }
+
+Value& Value::operator=(Value const &right) {
+# define ___local_case(member) member = right.member
+  ___local_case(Double);
+  ___local_case(Bool);
+  ___local_case(Long);
+  ___local_case(String);
+  ___local_case(VDouble);
+  ___local_case(Metric);
+  return *this;
+# undef ___local_case
+}
diff --git a/yorick/gyoto_utils.C b/yorick/gyoto_utils.C
index e285490..b039f03 100644
--- a/yorick/gyoto_utils.C
+++ b/yorick/gyoto_utils.C
@@ -17,8 +17,10 @@
     along with Gyoto.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <GyotoUtils.h>
-#include <GyotoRegister.h>
+#include "GyotoUtils.h"
+#include "GyotoRegister.h"
+#include "GyotoProperty.h"
+#include "GyotoValue.h"
 #include <yapi.h>
 #include <pstdlib.h>
 #include <cstring>
@@ -354,7 +356,7 @@ long int __ygyoto_var_idx(long id) {
 void ypush_property(Gyoto::SmartPointer<Gyoto::SmartPointee> ptr,
 		    Gyoto::Property const& p, int iarg,
 		    std::string name, std::string unit) {
-  Gyoto::Property::Value val;
+  Gyoto::Value val;
   if (p.type == Gyoto::Property::double_t)
     val = ptr->get(p, unit);
   else
@@ -380,6 +382,9 @@ void ypush_property(Gyoto::SmartPointer<Gyoto::SmartPointee> ptr,
       for (size_t i=0; i<n; ++i) buf[i]=vval[i];
     }
     break;
+  case Gyoto::Property::metric_t:
+    *ypush_Metric() = val.Metric;
+    break;
   default:
     y_error("Property type unimplemented in ypush_property()");
    }
@@ -388,7 +393,7 @@ void ypush_property(Gyoto::SmartPointer<Gyoto::SmartPointee> ptr,
 void yget_property(Gyoto::SmartPointer<Gyoto::SmartPointee> ptr,
 		   Gyoto::Property const& p, int iarg, std::string name,
 		   std::string unit) {
-  Gyoto::Property::Value val;
+  Gyoto::Value val;
   switch(p.type) {
   case Gyoto::Property::bool_t:
     {
@@ -412,6 +417,9 @@ void yget_property(Gyoto::SmartPointer<Gyoto::SmartPointee> ptr,
       val = vval;
     }
     break;
+  case Gyoto::Property::metric_t:
+    val = *yget_Metric(iarg);
+    break;
   default:
     y_error("Property type unimplemented in yget_property()");
    }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git



More information about the Debian-astro-commits mailing list