[Debian-astro-commits] [gyoto] 132/221: Implement Astrobj, Spectrometer and Screen as possible Value and Property. Finish converting Screen.

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:40 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 8d94ccd9491ad00037c3353045675a9f704d856d
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Sun Dec 7 18:21:06 2014 +0100

    Implement Astrobj, Spectrometer and Screen as possible Value and Property. Finish converting Screen.
---
 include/GyotoProperty.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++-
 include/GyotoScreen.h   |  1 -
 include/GyotoValue.h    | 15 +++++++++++++
 lib/Object.C            | 32 ++++++++++++++++++++++++++
 lib/Property.C          | 42 +++++++++++++---------------------
 lib/Screen.C            | 10 +--------
 lib/Value.C             | 21 +++++++++++++++++
 yorick/gyoto_utils.C    | 19 ++++++++++++++++
 8 files changed, 162 insertions(+), 38 deletions(-)

diff --git a/include/GyotoProperty.h b/include/GyotoProperty.h
index c2b7f57..caf5eb6 100644
--- a/include/GyotoProperty.h
+++ b/include/GyotoProperty.h
@@ -34,7 +34,10 @@ namespace Gyoto {
   class Object;
   class Property;
   namespace Metric { class Generic; }
+  namespace Astrobj { class Generic; }
   namespace Spectrum { class Generic; }
+  namespace Spectrometer { class Generic; }
+  class Screen;
   template <class T> class SmartPointer;
 }
 
@@ -130,6 +133,20 @@ namespace Gyoto {
    (Gyoto::Property::set_metric_t)&class::fname,			\
    (Gyoto::Property::get_metric_t)&class::fname),
 
+/// Define a Property of type Gyoto::Screen
+#define GYOTO_PROPERTY_SCREEN(class, name, fname)			\
+  Gyoto::Property							\
+  (#name,								\
+   (Gyoto::Property::set_screen_t)&class::fname,			\
+   (Gyoto::Property::get_screen_t)&class::fname),
+
+/// Define a Property of type Gyoto::Astrobj::Generic
+#define GYOTO_PROPERTY_ASTROBJ(class, name, fname)			\
+  Gyoto::Property							\
+  (#name,								\
+   (Gyoto::Property::set_astrobj_t)&class::fname,			\
+   (Gyoto::Property::get_astrobj_t)&class::fname),
+
 /// Define a Property of type Gyoto::Spectrum::Generic
 #define GYOTO_PROPERTY_SPECTRUM(class, name, fname)			\
   Gyoto::Property							\
@@ -137,6 +154,13 @@ namespace Gyoto {
      (Gyoto::Property::set_spectrum_t)&class::fname,			\
      (Gyoto::Property::get_spectrum_t)&class::fname),
 
+/// Define a Property of type Gyoto::Spectrometer::Generic
+#define GYOTO_PROPERTY_SPECTROMETER(class, name, fname)			\
+  Gyoto::Property							\
+  (#name,								\
+   (Gyoto::Property::set_spectrometer_t)&class::fname,			\
+   (Gyoto::Property::get_spectrometer_t)&class::fname),
+
 /// Define class::properties and class::getProperties() 
 #define GYOTO_PROPERTY_END(class, next)				\
   Property(next)};							\
@@ -154,7 +178,8 @@ class Gyoto::Property
  public:
   enum type_e {double_t, long_t, unsigned_long_t, bool_t,
 	       string_t, filename_t,
-	       vector_double_t, metric_t, spectrum_t, empty_t};
+	       vector_double_t, metric_t, screen_t, astrobj_t, spectrum_t, spectrometer_t,
+	       empty_t};
   std::string name;
   std::string name_false;
   int type;
@@ -183,11 +208,26 @@ class Gyoto::Property
   typedef Gyoto::SmartPointer<Gyoto::Metric::Generic>
     (Object::* get_metric_t)() const;
 
+  typedef void (Object::* set_screen_t)
+    (Gyoto::SmartPointer<Gyoto::Screen>);
+  typedef Gyoto::SmartPointer<Gyoto::Screen>
+    (Object::* get_screen_t)() const;
+
+  typedef void (Object::* set_astrobj_t)
+    (Gyoto::SmartPointer<Gyoto::Astrobj::Generic>);
+  typedef Gyoto::SmartPointer<Gyoto::Astrobj::Generic>
+    (Object::* get_astrobj_t)() const;
+
   typedef void (Object::* set_spectrum_t)
     (Gyoto::SmartPointer<Gyoto::Spectrum::Generic>);
   typedef Gyoto::SmartPointer<Gyoto::Spectrum::Generic>
     (Object::* get_spectrum_t)() const;
 
+  typedef void (Object::* set_spectrometer_t)
+    (Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>);
+  typedef Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>
+    (Object::* get_spectrometer_t)() const;
+
   union setter_t {
     set_double_t set_double;
     set_long_t set_long;
@@ -196,7 +236,10 @@ class Gyoto::Property
     set_string_t set_string;
     set_vector_double_t set_vdouble;
     set_metric_t set_metric;
+    set_screen_t set_screen;
+    set_astrobj_t set_astrobj;
     set_spectrum_t set_spectrum;
+    set_spectrometer_t set_spectrometer;
   };
   union getter_t {
     get_double_t get_double;
@@ -206,7 +249,10 @@ class Gyoto::Property
     get_string_t get_string;
     get_vector_double_t get_vdouble;
     get_metric_t get_metric;
+    get_screen_t get_screen;
+    get_astrobj_t get_astrobj;
     get_spectrum_t get_spectrum;
+    get_spectrometer_t get_spectrometer;
   };
   union setter_unit_t {
     set_double_unit_t set_double;
@@ -270,9 +316,21 @@ class Gyoto::Property
 	   get_metric_t get_metric);
 
   Property(std::string name,
+	   set_screen_t set_screen,
+	   get_screen_t get_screen);
+
+  Property(std::string name,
+	   set_astrobj_t set_astrobj,
+	   get_astrobj_t get_astrobj);
+
+  Property(std::string name,
 	   set_spectrum_t set_spectrum,
 	   get_spectrum_t get_spectrum);
 
+  Property(std::string name,
+	   set_spectrometer_t set_spectrometer,
+	   get_spectrometer_t get_spectrometer);
+
   Property const * find(std::string name) const;
 
 };
diff --git a/include/GyotoScreen.h b/include/GyotoScreen.h
index 11020fa..8bed6ec 100644
--- a/include/GyotoScreen.h
+++ b/include/GyotoScreen.h
@@ -588,7 +588,6 @@ class Gyoto::Screen
  public:
   void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const;
 
-    void fillElement(FactoryMessenger *fmp); ///< called from Factory
     /// Instanciate a Screen from XML entity 
     static   SmartPointer<Screen> Subcontractor(FactoryMessenger* fmp);
 #endif
diff --git a/include/GyotoValue.h b/include/GyotoValue.h
index e1a25f1..fb0c57a 100644
--- a/include/GyotoValue.h
+++ b/include/GyotoValue.h
@@ -34,7 +34,10 @@
 namespace Gyoto {
   class Value;
   namespace Metric {class Generic;}
+  namespace Astrobj {class Generic;}
   namespace Spectrum {class Generic;}
+  namespace Spectrometer {class Generic;}
+  class Screen;
 }
 
 class Gyoto::Value {
@@ -72,9 +75,21 @@ class Gyoto::Value {
   Value(Gyoto::SmartPointer<Gyoto::Metric::Generic>);
   operator Gyoto::SmartPointer<Gyoto::Metric::Generic>();
 
+  Gyoto::SmartPointer<Gyoto::Astrobj::Generic> Astrobj;
+  Value(Gyoto::SmartPointer<Gyoto::Astrobj::Generic>);
+  operator Gyoto::SmartPointer<Gyoto::Astrobj::Generic>();
+
   Gyoto::SmartPointer<Gyoto::Spectrum::Generic> Spectrum;
   Value(Gyoto::SmartPointer<Gyoto::Spectrum::Generic>);
   operator Gyoto::SmartPointer<Gyoto::Spectrum::Generic>();
+
+  Gyoto::SmartPointer<Gyoto::Spectrometer::Generic> Spectrometer;
+  Value(Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>);
+  operator Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>();
+
+  Gyoto::SmartPointer<Gyoto::Screen> Screen;
+  Value(Gyoto::SmartPointer<Gyoto::Screen>);
+  operator Gyoto::SmartPointer<Gyoto::Screen>();
 };
 
 #endif
diff --git a/lib/Object.C b/lib/Object.C
index 4127478..a2e2431 100644
--- a/lib/Object.C
+++ b/lib/Object.C
@@ -4,7 +4,10 @@
 #include "GyotoError.h"
 #include "GyotoFactoryMessenger.h"
 #include "GyotoMetric.h"
+#include "GyotoAstrobj.h"
 #include "GyotoSpectrum.h"
+#include "GyotoSpectrometer.h"
+#include "GyotoScreen.h"
 
 #include <iostream>
 #include <cstdlib>
@@ -100,7 +103,10 @@ void Object::set(Property const &p, Value val) {
     }
     break;
     ___local_case(metric);
+    ___local_case(astrobj);
     ___local_case(spectrum);
+    ___local_case(spectrometer);
+    ___local_case(screen);
   default:
     throwError("Unimplemented Property type in Object::set");
   }
@@ -158,7 +164,10 @@ Value Object::get(Property const &p) const {
     }
     break;
     ___local_case(metric);
+    ___local_case(astrobj);
     ___local_case(spectrum);
+    ___local_case(spectrometer);
+    ___local_case(screen);
   default:
     throwError("Unimplemented Property type in Object::get");
   }
@@ -208,11 +217,22 @@ void Object::fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const
   case Property::metric_t:
     fmp->metric(get(p));
     break;
+  case Property::astrobj_t:
+    fmp->astrobj(get(p));
+    break;
+  case Property::screen_t:
+    fmp->screen(get(p));
+    break;
   case Property::spectrum_t:
     childfmp = fmp -> makeChild ( name );
     get(p).Spectrum -> fillElement(childfmp);
     delete childfmp;
     break;
+  case Property::spectrometer_t:
+    childfmp = fmp -> makeChild ( name );
+    get(p).Spectrometer -> fillElement(childfmp);
+    delete childfmp;
+    break;
   default:
     throwError("Property type unimplemented in Object::fillProperty()");
   }
@@ -249,12 +269,24 @@ void Object::setParameters(Gyoto::FactoryMessenger *fmp)  {
 	case Property::metric_t:
 	  set(*prop, fmp->metric());
 	  break;
+	case Property::astrobj_t:
+	  set(*prop, fmp->astrobj());
+	  break;
+	case Property::screen_t:
+	  set(*prop, fmp->screen());
+	  break;
 	case Property::spectrum_t:
 	  content = fmp -> getAttribute("kind");
 	  child = fmp -> getChild();
 	  set(*prop, (*Spectrum::getSubcontractor(content))(child) );
 	  delete child;
 	  break;
+	case Property::spectrometer_t:
+	  content = fmp -> getAttribute("kind");
+	  child = fmp -> getChild();
+	  set(*prop, (*Spectrometer::getSubcontractor(content))(child) );
+	  delete child;
+	  break;
 	case Property::filename_t:
 	  content = fmp->fullPath(content);
 	  // no 'break;' here, we need to proceed
diff --git a/lib/Property.C b/lib/Property.C
index d005008..e1daf58 100644
--- a/lib/Property.C
+++ b/lib/Property.C
@@ -6,18 +6,22 @@ using namespace Gyoto ;
 Property::Property(Property const * const ancestors)
   : name(""), type(empty_t), parent(ancestors) {}
 
-Property::Property(string n, set_long_t set, get_long_t get)
-  : name(n), type(long_t), parent(NULL) {
-  setter.set_long=set;
-  getter.get_long=get;
-}
+#define GYOTO_LOCAL(T)							\
+  Property::Property(string n, set_##T##_t set, get_##T##_t get)	\
+    : name(n), type(T##_t), parent(NULL) {				\
+    setter.set_##T=set;							\
+    getter.get_##T=get;							\
+  }
 
-Property::Property(string n,
-		   set_unsigned_long_t set, get_unsigned_long_t get)
-  : name(n), type(unsigned_long_t), parent(NULL) {
-  setter.set_unsigned_long=set;
-  getter.get_unsigned_long=get;
-}
+GYOTO_LOCAL(long)
+GYOTO_LOCAL(unsigned_long)
+GYOTO_LOCAL(metric)
+GYOTO_LOCAL(spectrum)
+GYOTO_LOCAL(astrobj)
+GYOTO_LOCAL(screen)
+GYOTO_LOCAL(spectrometer)
+
+#undef GYOTO_LOCAL
 
 Property::Property(string n, set_double_t set, get_double_t get)
   : name(n), type(double_t), parent(NULL) {
@@ -71,22 +75,6 @@ Property::Property(string n,
   getter_unit.get_vdouble=getu;
 }
 
-Property::Property(string n,
-		   set_metric_t set,
-		   get_metric_t get)
-  : name(n), type(metric_t), parent(NULL) {
-  setter.set_metric=set;
-  getter.get_metric=get;
-}
-
-Property::Property(string n,
-		   set_spectrum_t set,
-		   get_spectrum_t get)
-  : name(n), type(spectrum_t), parent(NULL) {
-  setter.set_spectrum=set;
-  getter.get_spectrum=get;
-}
-
 Property const * Property::find(std::string n) const {
   if (type == empty_t) return parent;
   if (name == n || (type == bool_t && name_false == n)) return this;
diff --git a/lib/Screen.C b/lib/Screen.C
index 47c4a97..5096ed4 100644
--- a/lib/Screen.C
+++ b/lib/Screen.C
@@ -47,6 +47,7 @@ using namespace Gyoto;
 #include "GyotoProperty.h"
 GYOTO_PROPERTY_START(Screen)
 GYOTO_PROPERTY_METRIC(Screen, Metric, metric)
+GYOTO_PROPERTY_SPECTROMETER(Screen, Spectrometer, spectrometer)
 GYOTO_PROPERTY_DOUBLE_UNIT(Screen, Time, time)
 GYOTO_PROPERTY_DOUBLE_UNIT(Screen, FieldOfView, fieldOfView)
 GYOTO_PROPERTY_DOUBLE_UNIT(Screen, PALN, PALN)
@@ -1215,15 +1216,6 @@ void Screen::fillProperty(Gyoto::FactoryMessenger *fmp,
   else Object::fillProperty(fmp, p);
 }
 
-void Screen::fillElement(FactoryMessenger *fmp) {
-  FactoryMessenger* child = NULL;
-  Object::fillElement(fmp);
-  if (spectro_) {
-    child = fmp -> makeChild("Spectrometer");
-    spectro_ -> fillElement(child) ;
-    delete child; child = NULL;
-  }
-}
 
 SmartPointer<Screen> Screen::Subcontractor(FactoryMessenger* fmp) {
   string name="", content="", unit="", tunit="", aunit="", dunit="";
diff --git a/lib/Value.C b/lib/Value.C
index 172fa54..ecd421c 100644
--- a/lib/Value.C
+++ b/lib/Value.C
@@ -1,6 +1,9 @@
 #include "GyotoValue.h"
 #include "GyotoMetric.h"
+#include "GyotoAstrobj.h"
 #include "GyotoSpectrum.h"
+#include "GyotoSpectrometer.h"
+#include "GyotoScreen.h"
 #include <iostream>
 using namespace Gyoto ;
 using namespace std ;
@@ -33,11 +36,26 @@ Value::Value(Gyoto::SmartPointer<Gyoto::Metric::Generic> p)
 Value::operator Gyoto::SmartPointer<Gyoto::Metric::Generic>()
 { return Metric; }
 
+Value::Value(Gyoto::SmartPointer<Gyoto::Astrobj::Generic> p)
+  : Astrobj(p) {}
+Value::operator Gyoto::SmartPointer<Gyoto::Astrobj::Generic>()
+{ return Astrobj; }
+
 Value::Value(Gyoto::SmartPointer<Gyoto::Spectrum::Generic> p)
   : Spectrum(p) {}
 Value::operator Gyoto::SmartPointer<Gyoto::Spectrum::Generic>()
 { return Spectrum; }
 
+Value::Value(Gyoto::SmartPointer<Gyoto::Spectrometer::Generic> p)
+  : Spectrometer(p) {}
+Value::operator Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>()
+{ return Spectrometer; }
+
+Value::Value(Gyoto::SmartPointer<Gyoto::Screen> p)
+  : Screen(p) {}
+Value::operator Gyoto::SmartPointer<Gyoto::Screen>()
+{ return Screen; }
+
 Value& Value::operator=(Value const &right) {
 # define ___local_case(member) member = right.member
   ___local_case(Double);
@@ -47,7 +65,10 @@ Value& Value::operator=(Value const &right) {
   ___local_case(String);
   ___local_case(VDouble);
   ___local_case(Metric);
+  ___local_case(Astrobj);
   ___local_case(Spectrum);
+  ___local_case(Spectrometer);
+  ___local_case(Screen);
   return *this;
 # undef ___local_case
 }
diff --git a/yorick/gyoto_utils.C b/yorick/gyoto_utils.C
index 14813d5..2e24ce8 100644
--- a/yorick/gyoto_utils.C
+++ b/yorick/gyoto_utils.C
@@ -26,6 +26,7 @@
 #include "GyotoAstrobj.h"
 #include "GyotoSpectrum.h"
 #include "GyotoSpectrometer.h"
+#include "GyotoScreen.h"
 #include <yapi.h>
 #include <pstdlib.h>
 #include <cstring>
@@ -411,9 +412,18 @@ void ypush_property(Gyoto::SmartPointer<Gyoto::SmartPointee> ptr,
   case Gyoto::Property::metric_t:
     *ypush_Metric() = val.Metric;
     break;
+  case Gyoto::Property::astrobj_t:
+    *ypush_Astrobj() = val.Astrobj;
+    break;
   case Gyoto::Property::spectrum_t:
     *ypush_Spectrum() = val.Spectrum;
     break;
+  case Gyoto::Property::spectrometer_t:
+    *ypush_Spectrometer() = val.Spectrometer;
+    break;
+  case Gyoto::Property::screen_t:
+    *ypush_Screen() = val.Screen;
+    break;
   default:
     y_error("Property type unimplemented in ypush_property()");
    }
@@ -469,9 +479,18 @@ void yget_property(Gyoto::SmartPointer<Gyoto::SmartPointee> ptr,
   case Gyoto::Property::metric_t:
     val = *yget_Metric(iarg);
     break;
+  case Gyoto::Property::astrobj_t:
+    val = *yget_Astrobj(iarg);
+    break;
   case Gyoto::Property::spectrum_t:
     val = *yget_Spectrum(iarg);
     break;
+  case Gyoto::Property::spectrometer_t:
+    val = *yget_Spectrometer(iarg);
+    break;
+  case Gyoto::Property::screen_t:
+    val = *yget_Screen(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