Gyoto
GyotoPython.h
Go to the documentation of this file.
1 /*
2  Copyright 2015-2016, 2022 Thibaut Paumard
3 
4  This file is part of Gyoto.
5 
6  Gyoto is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Gyoto is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
89 #ifndef __GyotoPython_H_
90 #define __GyotoPython_H_
91 #include <GyotoSpectrum.h>
92 #include <GyotoMetric.h>
93 #include <GyotoStandardAstrobj.h>
94 #include <GyotoThinDisk.h>
95 #include <GyotoProperty.h>
96 #include <GyotoValue.h>
97 #include <GyotoScreen.h>
98 #include <GyotoFactoryMessenger.h>
99 #include <Python.h>
100 
101 namespace Gyoto {
107  namespace Python {
108  class GILGuard;
109  class Base;
110  template <class O> class Object;
112  PyObject * PyObject_FromGyotoValue(const Gyoto::Value&);
113 
115  PyObject * PyInstance_GetMethod(PyObject* pInstance, const char *name);
116 
118  PyObject * PyImport_Gyoto();
119 
121  void PyInstance_SetThis(PyObject * pInstance,
122  PyObject * pNew,
123  void * ptr);
124 
126  bool PyCallable_HasVarArg(PyObject * pMethod);
127 
129  PyObject * PyModule_NewFromPythonCode(const char * code);
130 
132  PyObject * pGyotoMetric() ;
134  PyObject * pGyotoScreen() ;
136  PyObject * pGyotoAstrobj() ;
138  PyObject * pGyotoSpectrum() ;
140  PyObject * pGyotoSpectrometer() ;
142  PyObject * pGyotoStandardAstrobj() ;
144  PyObject * pGyotoThinDisk() ;
145  }
146  namespace Spectrum {
147  class Python;
148  }
149  namespace Metric {
150  class Python;
151  }
152  namespace Astrobj {
157  namespace Python {
158  class Standard;
159  class ThinDisk;
160  }
161  }
162 }
163 
199 public:
201  GILGuard();
202 
204 
207  ~GILGuard();
208 
210  void track(PyObject*& obj);
211 
212  // Delete copy constructor and assignment operator to prevent misuse
213  GILGuard(const GILGuard&) = delete;
214  GILGuard& operator=(const GILGuard&) = delete;
215 
216 private:
218  PyGILState_STATE gstate_;
220  std::vector<PyObject**> tracked_objects_;
221 };
222 
259  protected:
266  std::string module_;
267 
272  std::string inline_module_;
273 
279  std::string class_;
280 
288  std::vector<double> parameters_;
289 
293  PyObject * pModule_;
294 
298  PyObject * pInstance_;
299 
303  PyObject * pProperties_;
304 
308  PyObject * pSet_;
309 
313  PyObject * pGet_;
314 
315  public:
316  Base();
317  Base(const Base&);
318  ~Base();
319 
320  virtual std::string module() const ;
321  virtual std::string inlineModule() const ;
322 
331  virtual void module(const std::string&);
332 
341  virtual void inlineModule(const std::string&);
342 
350  virtual void instance(PyObject * pinstance);
351 
353  virtual std::string klass() const ;
354 
368  virtual void klass(const std::string& c);
369 
371  virtual std::vector<double> parameters() const;
378  virtual void parameters(const std::vector<double>&);
379 
380  virtual bool hasPythonProperty(std::string const &key) const ;
381  virtual void setPythonProperty(std::string const &key, Value val);
382  virtual void setPythonProperty(std::string const &key, Value val, std::string const &unit);
383  virtual Value getPythonProperty(std::string const &key) const;
384  virtual Value getPythonProperty(std::string const &key, std::string const &unit) const;
385  virtual Gyoto::Property::type_e pythonPropertyType(std::string const &key) const;
386 
387 
388  /* Helper methods */
390 
398 
405  virtual void detachInstance();
406 
408 
415  virtual void attachInstance(PyObject *instance);
416 
418 
421  PyObject * instantiateClass(std::string &klass) const;
422 
423 };
424 
431 template <class O>
433  : public O, public Gyoto::Python::Base
434 {
435 public:
436  Object() : O(), Gyoto::Python::Base() {}
437  Object(const Object& o) : O(o), Base(o) {}
438  virtual ~Object() {};
439 
440  using O::set;
441 
442  virtual bool knowsProperty(const std::string &name) const {
443  return (O::property(name) || hasPythonProperty(name));
444  }
445 
446  virtual void set(std::string const &key, Value val) {
447  GYOTO_DEBUG_EXPR(key);
448  GYOTO_DEBUG_EXPR(val.type);
449  if (hasPythonProperty(key)) {
450  GYOTO_DEBUG << "Python key " << key << " exists" << std::endl;
451  setPythonProperty(key, val);
452  } else {
453  GYOTO_DEBUG << "Python key " << key << " does not exist" << std::endl;
454  O::set(key, val);
455  }
456  }
457 
458  virtual void set(std::string const &key, Value val, std::string const &unit) {
459  GYOTO_DEBUG_EXPR(key);
460  GYOTO_DEBUG_EXPR(val.type);
461  if (hasPythonProperty(key)) {
462  GYOTO_DEBUG << "Python key " << key << " exists" << std::endl;
463  setPythonProperty(key, val, unit);
464  } else {
465  GYOTO_DEBUG << "Python key " << key << " does not exist" << std::endl;
466  O::set(key, val, unit);
467  }
468  }
469 
470  virtual void set(Property const &p, Value val){
471  std::string key=p.name;
472  GYOTO_DEBUG_EXPR(key);
473  if (!hasPythonProperty(key)) {
474  GYOTO_DEBUG << "calling Generic::set" << std::endl;
475  O::set(p, val);
476  return;
477  }
478  setPythonProperty(key, val);
479  }
480 
481  virtual void set(Property const &p, Value val, std::string const &unit) {
482  GYOTO_DEBUG_EXPR(p.name);
483  if (hasPythonProperty(p.name)) {
484  GYOTO_DEBUG << "Python key " << p.name << " exists" << std::endl;
485  if (unit!="") GYOTO_ERROR("units not implemented");
486  setPythonProperty(p.name, val);
487  } else {
488  GYOTO_DEBUG << "Python key " << p.name << " does not exist" << std::endl;
489  O::set(p, val, unit);
490  }
491  }
492 
493  using O::get;
494 
495  virtual Value get(std::string const &key) const {
496  GYOTO_DEBUG_EXPR(key);
497  if (!hasPythonProperty(key)) {
498  GYOTO_DEBUG << "calling Generic::get" << std::endl;
499  return O::get(key);
500  }
501  return getPythonProperty(key);
502  }
503 
504  virtual Value get(std::string const &key, std::string const &unit) const {
505  GYOTO_DEBUG_EXPR(key);
506  if (!hasPythonProperty(key)) {
507  GYOTO_DEBUG << "calling Generic::get" << std::endl;
508  return O::get(key, unit);
509  }
510  return getPythonProperty(key, unit);
511  }
512 
513  Value get(Property const &p,
514  std::string const &unit) const {
515  if (!hasPythonProperty(p.name)) {
516  GYOTO_DEBUG << "calling Generic::get" << std::endl;
517  return O::get(p, unit);
518  }
519  return getPythonProperty(p.name);
520  }
521 
522  Value get(Property const &p) const {
523  if (!hasPythonProperty(p.name)) {
524  GYOTO_DEBUG << "calling Generic::get" << std::endl;
525  return O::get(p);
526  }
527  return getPythonProperty(p.name);
528  }
529 
530  using O::setParameter;
531 
532  virtual int setParameter(std::string name, std::string content, std::string unit) {
533  GYOTO_DEBUG_EXPR(name);
534  GYOTO_DEBUG_EXPR(content);
535  GYOTO_DEBUG_EXPR(unit);
536  if (hasPythonProperty(name)) {
537  Property p(NULL);
538  p.name=name;
539  p.type=pythonPropertyType(name);
540  GYOTO_DEBUG << "Calling setParameter(p, name, content, unit)" << std::endl;
541  setParameter(p, name, content, unit);
542  return 0;
543  }
544  return O::setParameter(name, content, unit);
545  }
546 
547 
548  virtual void fillProperty(Gyoto::FactoryMessenger *fmp,
549  Property const &p) const {
550  if ((p.name == "Instance") ||
551  (p.name == "Module" && module_=="") ||
552  (p.name == "InlineModule" && inline_module_=="")) {
553  GYOTO_DEBUG << "skipping " << p.name << std::endl;
554  return;
555  } else O::fillProperty(fmp, p);
556  }
557 
558  virtual void fillElement(Gyoto::FactoryMessenger *fmp) const {
559  GYOTO_DEBUG << "filling C++ properties" << std::endl;
560  O::fillElement(fmp);
561  GYOTO_DEBUG << "filling Python properties" << std::endl;
562  if (pProperties_) {
563  Py_ssize_t pos=0;
564  PyObject *pKey, *pVal;
565  while (PyDict_Next(pProperties_, &pos, &pKey, &pVal)) {
566  if (!PyUnicode_Check(pKey)) GYOTO_ERROR("key is not a UNICODE string");
567  std::string key=PyUnicode_AsUTF8(pKey);
568  if (PyDict_Check(pVal)) pVal=PyDict_GetItemString(pVal, "type");
569  if (!pVal) GYOTO_ERROR("could not get type for property "+key);
570  if (!PyUnicode_Check(pVal)) GYOTO_ERROR("type is not a UNICODE string");
571  std::string stype=PyUnicode_AsUTF8(pVal);
572  GYOTO_DEBUG << "creating XML element for Python property "
573  << key << " of type " << stype << std::endl;
575  const Property p (key, type);
576  this->fillProperty(fmp, p);
577  }
578  }
579  }
580 
581  void setParameters(Gyoto::FactoryMessenger *fmp) {
582  std::string name="", content="", unit="";
583  FactoryMessenger * child = NULL;
584  if (fmp) {
585  // add xml file directory to sys.path
586  std::string xmldir = fmp->fullPath("");
587  if (xmldir.size()) {
588  GYOTO_DEBUG << "adding '"+xmldir+"' to sys.path" << std::endl;
589  // retrieve sys.path
590  PyObject* sysPath = PySys_GetObject("path");
591  if (!sysPath) {
592  PyErr_Print();
593  return;
594  }
595  // create Python variable around xmldir variable
596  PyObject* pyPath = PyUnicode_FromString(xmldir.c_str());
597  // check whether xmldir is already in sys.path
598  Py_ssize_t pathSize = PyList_Size(sysPath);
599  bool found = false;
600  for (Py_ssize_t i = 0; i < pathSize; ++i) {
601  PyObject* item = PyList_GetItem(sysPath, i);
602  if (PyUnicode_Compare(item, pyPath) == 0) {
603  found = true;
604  break;
605  }
606  // if not, prepend it
607  if (!found) {
608  PyList_Insert(sysPath, 0, pyPath);
609  }
610  // clean memory
611  Py_DECREF(pyPath);
612  }
613  }
614  // loop on parameters
615  while (fmp->getNextParameter(&name, &content, &unit)) {
616  GYOTO_DEBUG << "Setting '" << name << "' to '" << content
617  << "' (unit='"<<unit<<"')" << std::endl;
618  const Property * prop =NULL;
619  bool need_delete= false;
620  if (hasPythonProperty(name)) {
621  need_delete=true;
622  prop = new Property(name, pythonPropertyType(name));
623  } else {
624  need_delete=false;
625  prop = this->property(name);
626  }
627  if (!prop) {;
628  GYOTO_DEBUG << "'" << name << "' not found, calling setParameter()"
629  << std::endl;
630  // The specific setParameter() implementation may well know
631  // this entity
632  setParameter(name, content, unit);
633  } else {
634  GYOTO_DEBUG << "'" << name << "' found "<< std::endl;
635  std::vector<std::string> plugins;
636  switch (prop->type) {
637  case Property::metric_t:
638  set(*prop, fmp->metric());
639  break;
640  case Property::astrobj_t:
641  set(*prop, fmp->astrobj());
642  break;
643  case Property::screen_t:
644  set(*prop, fmp->screen());
645  break;
647  content = fmp -> getAttribute("kind");
648  child = fmp -> getChild();
649  plugins = Gyoto::split(fmp -> getAttribute("plugin"), ",");
650  set(*prop, (*Spectrum::getSubcontractor(content, plugins))(child, plugins) );
651  delete child;
652  break;
654  content = fmp -> getAttribute("kind");
655  child = fmp -> getChild();
656  plugins = Gyoto::split(fmp -> getAttribute("plugin"), ",");
657  set(*prop, (*Spectrometer::getSubcontractor(content, plugins))(child, plugins) );
658  delete child;
659  break;
661  content = fmp->fullPath(content);
662  [[fallthrough]]; // no 'break;' here, we need to proceed
663  default:
664  setParameter(*prop, name, content, unit);
665  break;
666  }
667  }
668  if (need_delete) delete prop;
669  }
670  }
671  GYOTO_DEBUG << "Done processing parameters" << std::endl;
672  }
673 };
674 
689  : public Gyoto::Python::Object<Gyoto::Spectrum::Generic>
690 {
692  protected:
693 
700  PyObject * pCall_;
701 
705  PyObject * pIntegrate_;
706 
725 
726  public:
727  GYOTO_OBJECT;
729 
730  Python();
731 
732  Python(const Python&);
733 
734  virtual Python * clone() const;
735 
736  ~Python();
737 
738  // For some reason we need to implement the bunch although only one
739  // is non-trivial
740  virtual std::string module() const ;
741  virtual void module(const std::string&);
742  virtual std::string inlineModule() const ;
743  virtual void inlineModule(const std::string&);
744  virtual std::string klass() const ;
745  virtual void klass(const std::string&);
747 
749 
752  virtual size_t instance() const ;
753  virtual void instance(size_t address);
754  virtual void detachInstance();
755  virtual void attachInstance(PyObject *instance);
756  virtual std::vector<double> parameters() const;
757  virtual void parameters(const std::vector<double>&);
758 
759  virtual double operator()(double nu) const;
760  virtual double operator()(double nu, double opacity, double ds) const;
761 
762  virtual double integrate(double nu1, double nu2) ;
763 
764 };
765 
766 
786  : public Gyoto::Python::Object<Gyoto::Metric::Generic>
787 {
789 
790  private:
791  // Variables to cache Python objects:
795  PyObject * pGmunu_;
796 
800  PyObject * pChristoffel_;
801 
805  PyObject * pGetRmb_;
806 
810  PyObject * pGetRms_;
811 
815  PyObject * pGetSpecificAngularMomentum_;
816 
820  PyObject * pGetPotential_;
821 
825  PyObject * pIsStopCondition_;
826 
830  PyObject * pCircularVelocity_;
831 
832  public:
833  GYOTO_OBJECT;
835  Python();
836  Python(const Python&);
837  ~Python();
838  virtual Python* clone() const ;
839 
840  // Accessors for the Gyoto::Property members:
841  // Those are mere wrappers arround Generic::coordKind(), useful for
842  // declaring a boolen property using the macro GYOTO_PROPERTY_BOOL:
843  void spherical(bool);
844  bool spherical() const;
845  virtual std::string module() const ;
846  virtual void module(const std::string&);
847  virtual std::string inlineModule() const ;
848  virtual void inlineModule(const std::string&);
849  virtual std::string klass() const ;
850  virtual void klass(const std::string&);
852 
854 
857  virtual size_t instance() const ;
858  virtual void instance(size_t address);
859  virtual void detachInstance();
860  virtual void attachInstance(PyObject *instance);
861  virtual std::vector<double> parameters() const;
862  virtual void parameters(const std::vector<double>&);
864  virtual void mass(double m);
865 
866  // The minimal Gyoto::Metric API:
867  void gmunu(double g[4][4], const double * x) const ;
868  int christoffel(double dst[4][4][4], const double * x) const ;
869 
870  // Little more
871  double getRmb() const;
872  double getRms() const;
873  double getSpecificAngularMomentum(double rr) const;
874  double getPotential(double const pos[4], double l_cst) const;
875  int isStopCondition(double const coord[8]) const;
876  void circularVelocity(double const pos[4], double vel[4],
877  double dir=1.) const ;
878 
879 };
880 
891  : public Gyoto::Python::Object<Gyoto::Astrobj::Standard>
892 {
894 
895  private:
896  PyObject *pEmission_, *pIntegrateEmission_, *pTransmission_, *pCall_,
897  *pGetVelocity_, *pGiveDelta_;
898  bool pEmission_overloaded_, pIntegrateEmission_overloaded_;
899 
900  public:
901  GYOTO_OBJECT;
903 
904  /* Birth and Death*/
905  Standard();
906  Standard(const Standard&);
907  ~Standard();
908  Standard* clone() const;
909 
910  /* Astrobj::Generic API */
911  virtual double emission(double nu_em, double dsem, state_t const &coord_ph,
912  double const coord_obj[8]=NULL) const ;
913 
914  virtual void emission(double Inu[], double const nu_em[], size_t nbnu,
915  double dsem, state_t const &coord_ph,
916  double const coord_obj[8]=NULL) const ;
917 
918  virtual double integrateEmission(double nu1, double nu2, double dsem,
919  state_t const &c_ph, double const c_obj[8]=NULL) const;
920 
921  virtual void integrateEmission(double * I, double const * boundaries,
922  size_t const * chaninds, size_t nbnu,
923  double dsem, state_t const &cph, double const *co) const;
924 
925  virtual double transmission(double nuem, double dsem, state_t const &cph, double const *co) const ;
926 
927  /* Astrobj::Standard API */
928  virtual double operator()(double const coord[4]) ;
929  virtual void getVelocity(double const pos[4], double vel[4]) ;
930  virtual double giveDelta(double coord[8]);
931 
932  /* Python::Base */
933  virtual std::string module() const ;
934  virtual void module(const std::string&);
935  virtual std::string inlineModule() const ;
936  virtual void inlineModule(const std::string&);
937  virtual std::string klass() const ;
938  virtual void klass(const std::string& c);
940 
942 
945  virtual size_t instance() const ;
946  virtual void instance(size_t address);
947  virtual void detachInstance();
948  virtual void attachInstance(PyObject *instance);
949  virtual std::vector<double> parameters() const;
950  virtual void parameters(const std::vector<double>&);
951  virtual double criticalValue() const ;
952  virtual void criticalValue(double) ;
953 
954 };
955 
966  : public Gyoto::Python::Object<Gyoto::Astrobj::ThinDisk>
967 {
969 
970  private:
971  PyObject *pEmission_, *pIntegrateEmission_, *pTransmission_, *pCall_,
972  *pGetVelocity_, *pGiveDelta_;
973  bool pEmission_overloaded_, pIntegrateEmission_overloaded_;
974 
975  public:
976  GYOTO_OBJECT;
978 
979  /* Birth and Death*/
980  ThinDisk();
981  ThinDisk(const ThinDisk&);
982  ~ThinDisk();
983  ThinDisk* clone() const;
984 
985  /* Astrobj::Generic API */
986  virtual double emission(double nu_em, double dsem, state_t const &coord_ph,
987  double const coord_obj[8]=NULL) const ;
988 
989  virtual void emission(double Inu[], double const nu_em[], size_t nbnu,
990  double dsem, state_t const &coord_ph,
991  double const coord_obj[8]=NULL) const ;
992 
993  virtual double integrateEmission(double nu1, double nu2, double dsem,
994  state_t const &c_ph, double const c_obj[8]=NULL) const;
995 
996  virtual void integrateEmission(double * I, double const * boundaries,
997  size_t const * chaninds, size_t nbnu,
998  double dsem, state_t const &cph, double const *co) const;
999 
1000  virtual double transmission(double nuem, double dsem, state_t const &cph ,double const *co) const ;
1001 
1002  /* Astrobj::ThinDisk API */
1003  virtual double operator()(double const coord[4]) ;
1004  virtual void getVelocity(double const pos[4], double vel[4]) ;
1005 
1006  /* Python::Base */
1007  virtual std::string module() const ;
1008  virtual void module(const std::string&);
1009  virtual std::string inlineModule() const ;
1010  virtual void inlineModule(const std::string&);
1011  virtual std::string klass() const ;
1012  virtual void klass(const std::string&);
1014 
1016 
1019  virtual size_t instance() const ;
1020  virtual void instance(size_t address);
1021  virtual void detachInstance();
1022  virtual void attachInstance(PyObject *instance);
1023  virtual std::vector<double> parameters() const;
1024  virtual void parameters(const std::vector<double>&);
1025 
1026 };
1027 
1028 
1029 #endif
virtual void instance(PyObject *pinstance)
Set pInstance_.
virtual size_t instance() const
Retrieve pInstance_.
int getNextParameter(std::string *name, std::string *content, std::string *unit=NULL)
Get name and value of next parameter.
PyObject * pGyotoMetric()
Get reference to the Metric constructor in the gyoto Python extension.
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:84
PyObject * pGyotoAstrobj()
Get reference to the Astrobj constructor in the gyoto Python extension.
void track(PyObject *&obj)
Add a PyObject* to the list of tracked objects.
virtual double integrate(double nu1, double nu2)
Integrate optically thick I_nu.
SmartPointer< Astrobj::Generic > astrobj()
Build and get the Astrobj described in this XML file.
PyObject * pGyotoSpectrometer()
Get reference to the Spectrometer constructor in the gyoto Python extension.
double mass() const
Get mass used in unitLength()
PyObject * pModule_
Reference to the python module once it has been loaded.
Definition: GyotoPython.h:293
std::string class_
Name of the Python class that we want to expose.
Definition: GyotoPython.h:279
Type is std::string and holds a file name.
Definition: GyotoProperty.h:638
virtual void attachInstance(PyObject *instance)
Attach pInstance_ and cached method pointers.
PyObject * pGyotoThinDisk()
Get reference to the ThinDisk constructor in the gyoto Python extension.
virtual void attachInstance(PyObject *instance)
Attach pInstance_ and cached method pointers.
void PyInstance_SetThis(PyObject *pInstance, PyObject *pNew, void *ptr)
Set "this" attribute in instance.
#define GYOTO_OBJECT_THREAD_SAFETY
Declare virtual bool isThreadSafe() const.
Definition: GyotoObject.h:99
virtual std::string klass() const
Retrieve class_.
Introspectable properties.
GILGuard()
Constructor: Acquires the GIL.
#define GYOTO_DEBUG
Display debug message (in debug mode)
Definition: GyotoDefs.h:367
#define size_t
If not defined in <sys/types.h>.
Definition: GyotoConfig.h:424
Factory / SmartPointee::Subcontractor_t interface.
PyObject * pInstance_
Reference to the python instance once it has been instantiated.
Definition: GyotoPython.h:298
Type is Gyoto::SmartPointer<Gyoto::Metric::Generic>
Definition: GyotoProperty.h:644
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
PyObject * pGyotoSpectrum()
Get reference to the Spectrum constructor in the gyoto Python extension.
PyObject * pGyotoScreen()
Get reference to the Screen constructor in the gyoto Python extension.
virtual void detachInstance()
Detach pInstance_ and cached method pointers.
SmartPointer< Screen > screen()
Build and get the Screen described in this XML file.
std::string fullPath(const std::string &relpath) const
Transform path into full path specification.
std::string module_
Name of the Python module that holds the class.
Definition: GyotoPython.h:266
#define GYOTO_ERROR(msg)
Throw a Gyoto::Error nicely.
Definition: GyotoError.h:196
Astronomical objects defined bya a potential/distance.
PyObject * instantiateClass(std::string &klass) const
Creates an instance of class klass in module module_.
PyObject * pCall_
Reference to ___call__.
Definition: GyotoPython.h:700
virtual std::string inlineModule() const
Return inline_module_.
#define GYOTO_DEBUG_EXPR(a)
Output expression value in debug mode.
Definition: GyotoDefs.h:280
PyGILState_STATE gstate_
The GIL state guarded by this GILGuard.
Definition: GyotoPython.h:218
std::string inline_module_
Python source code for module that holds the class.
Definition: GyotoPython.h:272
PyObject * pGet_
Reference to the (optional) Get method.
Definition: GyotoPython.h:313
std::vector< PyObject ** > tracked_objects_
Stores pointers to PyObject* variables.
Definition: GyotoPython.h:220
Gyoto::Spectrometer::Subcontractor_t * getSubcontractor(std::string name, std::vector< std::string > &plugins, int errmode=0)
Query the Spectrometer register Spectrometer::Register_.
PyObject * PyImport_Gyoto()
Return reference to the gyoto module, or NULL.
Base class for metric description.
virtual std::string module() const
Return module_.
type_e
Possible type of a Property instance.
Definition: GyotoProperty.h:616
Type is Gyoto::SmartPointer<Gyoto::Spectrum::Generic>
Definition: GyotoProperty.h:650
void checkModuleForSingleClass()
Look for single class in pModule_.
Metric coded in Python.
Definition: GyotoPython.h:785
Coding a Gyoto::Astrobj::Standard in Python.
Definition: GyotoPython.h:890
virtual std::vector< double > parameters() const
Retrieve parameters_.
bool pCall_overloaded_
Whether call is overloaded.
Definition: GyotoPython.h:724
virtual void detachInstance()
Detach pInstance_ and cached method pointers.
Geometrically thin disks and rings.
Spectrum of a simple object (e.g. Star)
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:46
~GILGuard()
Destructor.
Type is Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>
Definition: GyotoProperty.h:652
PyObject * pIntegrate_
Reference to the (optional) integrate method.
Definition: GyotoPython.h:705
PyObject * PyInstance_GetMethod(PyObject *pInstance, const char *name)
Return new reference to method, or NULL if method not found.
virtual Python * clone() const
Cloner.
Manage the GIL and free pointers on error.
Definition: GyotoPython.h:198
Pointers performing reference counting.
Definition: GyotoProperty.h:45
static type_e typeFromString(std::string stype)
Get Property::type_e value from name.
Type is Gyoto::SmartPointer<Gyoto::Astrobj::Generic>
Definition: GyotoProperty.h:648
Gyoto::Spectrum::Subcontractor_t * getSubcontractor(std::string name, std::vector< std::string > &plugins, int errmode=0)
Query the Spectrum register Spectrum::Register_.
Coding a Gyoto::Astrobj::ThinDisk in Python.
Definition: GyotoPython.h:965
virtual std::string inlineModule() const
Return inline_module_.
SmartPointer< Metric::Generic > metric()
Build and get the Metric described in this XML file.
Container for the value of a Property.
Definition: GyotoValue.h:60
std::vector< std::string > split(std::string const &src, std::string const &delim)
Split string.
Loader for Python classes implementing the Spectrum interface.
Definition: GyotoPython.h:688
virtual std::vector< double > parameters() const
Retrieve parameters_.
PyObject * pSet_
Reference to the (optional) Set method.
Definition: GyotoPython.h:308
virtual std::string module() const
Return module_.
Object with properties.
Definition: GyotoObject.h:151
Base class for classes in the Python plug-in.
Definition: GyotoPython.h:258
Description of the observer screen.
virtual std::string klass() const
Retrieve class_.
PyObject * PyObject_FromGyotoValue(const Gyoto::Value &)
Convert Gyoto Value to Python Object.
Type is Gyoto::SmartPointer<Gyoto::Screen::Generic>
Definition: GyotoProperty.h:646
Class template to implement parts of the Gyoto::Object API.
Definition: GyotoPython.h:110
PyObject * pGyotoStandardAstrobj()
Get reference to the StandardAstrobj constructor in the gyoto Python extension.
bool PyCallable_HasVarArg(PyObject *pMethod)
Check whether method accepts the varargs argument.
PyObject * pProperties_
Reference to the properties member.
Definition: GyotoPython.h:303
PyObject * PyModule_NewFromPythonCode(const char *code)
Create module from Python source code in a C string.
std::vector< double > parameters_
Parameters that this class needs.
Definition: GyotoPython.h:288
Introspectable value.