Gyoto
|
Complex spectrometer object. More...
#include <GyotoComplexSpectrometer.h>
Public Types | |
typedef Gyoto::SmartPointer< Gyoto::SmartPointee > | Subcontractor_t(Gyoto::FactoryMessenger *, std::vector< std::string > const &) |
A subcontractor builds an object upon order from the Factory. More... | |
Public Member Functions | |
Complex () | |
Default constructor. | |
Complex (const Complex &) | |
Copy constructor. | |
virtual Complex * | clone () const |
Clone an instance. More... | |
virtual | ~Complex () |
Destructor. More... | |
void | append (Gyoto::SmartPointer< Gyoto::Spectrometer::Generic > element) |
Add element at the end of the array. More... | |
void | remove (size_t i) |
Remove i-th element from the array. | |
size_t | getCardinal () const |
Get the number of elements in the array. | |
virtual void | tell (Gyoto::Hook::Teller *msg) |
This is how a Teller tells. More... | |
virtual void | fillElement (FactoryMessenger *fmp) const |
Fill in the XML entity. More... | |
virtual void | setParameters (FactoryMessenger *fmp) |
Main loop in the (templated) subcontractor. More... | |
Gyoto::SmartPointer< Gyoto::Spectrometer::Generic > & | operator[] (size_t i) |
Retrieve i-th element. More... | |
Gyoto::SmartPointer< Gyoto::Spectrometer::Generic > const & | operator[] (size_t i) const |
Retrieve a const version of the i-th element. | |
virtual Property const * | getProperties () const |
Get list of properties. More... | |
virtual kind_t | kindid () const |
Get kindid_. More... | |
virtual void | kindid (kind_t) |
Set Generic::kindid_. More... | |
virtual size_t | nSamples () const |
Get Generic::nsamples_. More... | |
virtual size_t | getNBoundaries () const |
Get Generic::nboundaries_. | |
virtual double const * | getMidpoints () const |
Get Generic::midpoints_. | |
virtual void | getMidpoints (double data[], std::string unit) |
Copy Generic::midpoints_, converting to unit. More... | |
virtual void | getChannelBoundaries (double data[], std::string unit) |
Copy Generic::boundaries_, converting to unit. More... | |
virtual double const * | getChannelBoundaries () const |
Get Generic::boundaries_. | |
virtual size_t const * | getChannelIndices () const |
Get Generic::chanind_. | |
virtual double const * | getWidths () const |
Get Generic::widths_. | |
virtual void | getWidths (double data[], std::string unit) |
Copy Generic::widths_, converting to unit. More... | |
void | incRefCount () |
Increment the reference counter. Warning: Don't mess with the counter. | |
int | decRefCount () |
Decrement the reference counter and return current value. Warning: Don't mess with the counter. | |
int | getRefCount () |
Get the current number of references. | |
virtual bool | isThreadSafe () const |
Whether this class is thread-safe. More... | |
void | set (Property const &p, Value val) |
Set Value of a Property. | |
void | set (Property const &p, Value val, std::string const &unit) |
Set Value (expressed in unit) of a Property. | |
void | set (std::string const &pname, Value val) |
Set Value of a Property. | |
void | set (std::string const &pname, Value val, std::string const &unit) |
Set Value (expressed in unit) of a Property. | |
Value | get (Property const &p) const |
Get Value of a Property. | |
Value | get (std::string const &pname) const |
Get Value of a Property. | |
Value | get (Property const &p, std::string const &unit) const |
Get Value of a Property, converted to unit. | |
Value | get (std::string const &pname, std::string const &unit) const |
Get Value of a Property, converted to unit. | |
Property const * | property (std::string const pname) const |
Find property by name. More... | |
virtual void | fillProperty (Gyoto::FactoryMessenger *fmp, Property const &p) const |
Output a single Property to XML. More... | |
virtual int | setParameter (std::string name, std::string content, std::string unit) |
Set parameter by name. More... | |
virtual void | setParameter (Gyoto::Property const &p, std::string const &name, std::string const &content, std::string const &unit) |
Set parameter by Property (and name) More... | |
std::string | describeProperty (Gyoto::Property const &p) const |
Format desrciption for a property. More... | |
void | help () const |
Print (to stdout) some help on this class. More... | |
virtual void | hook (Listener *listener) |
Start listening. More... | |
virtual void | unhook (Listener *listener) |
Stop listening. More... | |
Public Attributes | |
GYOTO_OBJECT_THREAD_SAFETY | |
size_t | nsamples_ |
Number of spectral elements. | |
size_t | nboundaries_ |
Size of the boundaries_ array. | |
double * | boundaries_ |
Frequency (in Hz) at the boundaries of the spectral channels. More... | |
size_t * | chanind_ |
Indices in boundaries_. More... | |
double * | midpoints_ |
Effective frequency (in Hz) of each spectral channel. More... | |
double * | widths_ |
Width of each channel. More... | |
Static Public Attributes | |
static kind_t const | Kind |
"Complex" More... | |
static GYOTO_OBJECT Property const | properties [] |
Protected Member Functions | |
virtual void | tellListeners () |
Call tell() on each hooked Listener. More... | |
Protected Attributes | |
size_t | cardinal_ |
Number of subspectrometers. More... | |
Gyoto::SmartPointer< Gyoto::Spectrometer::Generic > * | elements_ |
Actual array of SmartPointer<Spectrometer::Generic> objects. | |
kind_t | kindid_ |
Spectrometer kind ID. More... | |
std::string | kind_ |
The "kind" that is output in the XML entity. More... | |
std::vector< std::string > | plugins_ |
The plug-ins that needs to be loaded to access this instance's class. More... | |
Private Attributes | |
int | refCount |
Reference counter. | |
pthread_mutex_t | mutex_ |
A mutex. More... | |
ListenerItem * | listeners_ |
Linked list of Listener items. | |
Friends | |
class | Gyoto::SmartPointer< Gyoto::Spectrometer::Complex > |
Complex spectrometer object.
A Gyoto::Spectrometer::Generic whic contain several Gyoto::Spectrometer::Generic instances. It is essentially a SmartPointer<Spectrometer::Generic> array, which some methods arround. Indeed, the operator[](size_t i) method is implemented to retrieve the i-th element.
In an XML description, the <Spectrometer> section is unique, its kind is "Complex". Each sub-spectrometer then appears as a <SubSpectrometer> subsection. For instance, to compute 10 channels ovr the K infrared band plus 10 channels in the high energy domain:
|
inherited |
A subcontractor builds an object upon order from the Factory.
Various classes need to provide a subcontractor to be able to instantiate themselves upon order from the Factory. A subcontractor is a function (often a static member function) which accepts a pointer to a FactoryMessenger as unique parameter, communicates with the Factory using this messenger to read an XML description of the object to build, and returns this objet. SmartPointee::Subcontractor_t* is just generic enough a typedef to cast to and from other subcontractor types: Astrobj::Subcontractor_t, Metric::Subcontractor_t, Spectrum::Subcontractor_t. A subcontractor needs to be registered using the relevant Register() function: Astrobj::Register(), Metric::Register(), Spectrum::Register().
|
virtual |
Destructor.
Frees every SmartPointer<Spectrometer::Generic> before freed the array itself.
void Gyoto::Spectrometer::Complex::append | ( | Gyoto::SmartPointer< Gyoto::Spectrometer::Generic > | element | ) |
Add element at the end of the array.
If the Spectrometer::Complex itself does not have a metric already assigned, it takes it from the new element. Else, it sets the metric in the new element to its own. This ensures that all elements use the same metric (this heuristic is not entirely fool-proof, it's safer to set the metric directly in the Spectrometer::Complex).
|
virtual |
Clone an instance.
Use this to get a deep copy of an instance;
Most implementations will use the copy constructor:
Implements Gyoto::Spectrometer::Generic.
|
inherited |
Format desrciption for a property.
Returns a string containing the name(s) and type of the property, as well as whether it supports unit.
|
virtual |
|
virtualinherited |
Output a single Property to XML.
The base implementation decides what to do based on the p.type. The format matches how setParameters() an setParameter() would interpret the XML descition.
Overriding this method should be avoided, but makes sense in some cases (for instance Screen::fillProperty() selects a different unit for Distance based on its magnitude, so that stellar sizes are expressed in solar radii while smaller sizes can be expressed in meters and larger sizes in parsecs).
Overriding implementation should fall-back on calling the implementation in the direct parent class:
Reimplemented in Gyoto::Scenery, Gyoto::Astrobj::DirectionalDisk, Gyoto::Astrobj::Disk3D, Gyoto::Astrobj::EquatorialHotSpot, Gyoto::Astrobj::NeutronStarModelAtmosphere, Gyoto::Astrobj::PatternDisk, Gyoto::Astrobj::PolishDoughnut, Gyoto::Screen, Gyoto::Astrobj::Star, Gyoto::Spectrometer::Uniform, and Gyoto::Astrobj::XillverReflection.
|
virtualinherited |
Copy Generic::boundaries_, converting to unit.
data | an array of Generic::nboundaries_ doubles to fill with result |
unit | a string |
|
virtualinherited |
Copy Generic::midpoints_, converting to unit.
data | an array of Generic::nsamples_ doubles to fill with result |
unit | a string |
|
virtualinherited |
Get list of properties.
This method is declared automatically by the GYOTO_OBJECT macro and defined automatically by the GYOTO_PROPERTY_END macro.
Reimplemented from Gyoto::Object.
Reimplemented in Gyoto::Spectrometer::Uniform.
|
virtualinherited |
Copy Generic::widths_, converting to unit.
Think carefully before using: widths are often used to convert spectral flux density to flux. If flux density is per Herz, you don't need to convert widths.
data | an array of Generic::nboundaries_ doubles to fill with result |
unit | a string |
|
inherited |
Print (to stdout) some help on this class.
Describe all properties that this instance supports.
|
virtualinherited |
Start listening.
Use from a Hook::Listener object method:
where "this" is a Listener and "teller" is a Teller.
Use unhook() later to stop listening to a given Teller.
listener | pointer to the new listener |
|
virtualinherited |
Whether this class is thread-safe.
Return True if this object is thread-safe, i.e. if an instance and its clone can be used in parallel threads (in the context of Scenery::raytrace()). Known objects which are not thread-safe include Lorene metrics and everything from the Python plug-in.
The default implementation considers that the class itself is thread safe and recurses into the declared properties to check whether they are safe too. Classes that abide to the Object/Property paradigm and are themselves thread-safe have nothing special to do.
Objects that clone children in their copy constructor that are not declared as properties must take these children into account.
Classes that are never thread-safe must declare it. It acn be easily done using GYOTO_OBJECT_THREAD_SAFETY in the class declaration and GYOTO_PROPERTY_THREAD_UNSAFE in the class definition.
|
virtualinherited |
Get kindid_.
You can check whether the Spectrometer sp is of a given kind MyKind with something like:
See Uniform::WaveKind, Uniform::WaveLogKind, Uniform::FreqKind, Uniform::FreqLogKind and Complex::Kind.
Reimplemented in Gyoto::Spectrometer::Uniform.
|
virtualinherited |
Set Generic::kindid_.
This should rarely be used as the Generic::kindid_ attribute usually is set in the constructor and doesn't change after that.
Always set to the address of a static variable, not to a temporary. Usually your class should have a static member for that purpose:
Reimplemented in Gyoto::Spectrometer::Uniform, and Gyoto::Spectrometer::Uniform.
|
virtualinherited |
Get Generic::nsamples_.
Reimplemented in Gyoto::Spectrometer::Uniform.
Gyoto::SmartPointer< Gyoto::Spectrometer::Generic > & Gyoto::Spectrometer::Complex::operator[] | ( | size_t | i | ) |
Retrieve i-th element.
This should work as expected:
|
inherited |
|
virtualinherited |
Set parameter by Property (and name)
This function is used when parsing an XML description, if Property (p) of this name is found (i.e. either p.name or p.name_false is equal to name). Implementation should fall-back on calling the direct's parent implementation:
p | Property that matches name (p.name == name or p.name_false == name) |
name | XML name of the parameter (XML entity) |
content | string representation of the value |
unit | string representation of the unit |
Reimplemented in Gyoto::Astrobj::PolishDoughnut.
|
virtualinherited |
Set parameter by name.
This function is used when parsing an XML description, if no Property of this name is found. Overriding implementation should fall-back on calling the direct's parent implementation:
name | XML name of the parameter (XML entity). This may have a path component, e.g. "Astrobj::Radius", in which case a property named "Astrobj" will be sought in the current object, and setParameter will be called recusrively on this Astrobj with Radius as name. |
content | string representation of the value |
unit | string representation of the unit |
Reimplemented in Gyoto::Astrobj::EquatorialHotSpot, Gyoto::Metric::KerrKS, Gyoto::Astrobj::Star, and Gyoto::Metric::RotStar3_1.
|
virtual |
Main loop in the (templated) subcontractor.
In the case of Spectrometer::Complex, the setParameter() API is not sufficient: setParameters() needs access to the FactoryMessenger to instantiate children for the SubSpectrometers.
Reimplemented from Gyoto::Object.
|
virtual |
This is how a Teller tells.
A teller will basically call listener->tell(this).
msg | Teller* the Teller who is telling... Useful if the Listener listens to several Tellers. |
Reimplemented from Gyoto::Hook::Listener.
|
protectedvirtualinherited |
Call tell() on each hooked Listener.
Whenever a Teller mutates, it should warn any Listener hooked to it using tellListeners().
|
virtualinherited |
Stop listening.
Use from a Hook::Listener object method:
where "this" is a Listener, "teller" is a Teller, and "this" has called teller->hook(this) previously.
listener | pointer to the listener |
|
inherited |
Frequency (in Hz) at the boundaries of the spectral channels.
Array of size nboundaries_
Spectral channel i extends from
to
. Channels may or may not be contiguous or ordered.
|
protected |
Number of subspectrometers.
Size of elements_.
|
inherited |
Indices in boundaries_.
Array of size 2*nsamples_
|
static |
"Complex"
Use this static member attribute to check whether a Spectrometer object spectro is of kind Complex:
|
protectedinherited |
The "kind" that is output in the XML entity.
E.g. for an Astrobj, fillElement() will ensure
is written.
|
protectedinherited |
Spectrometer kind ID.
The content is not copied. kindid_ should be set (as a parameter to the Generic() constructor or using kindid()) to the address of a static variable holding the name. This allows checking the kind using pointer comparison rather than string comparison.
|
inherited |
Effective frequency (in Hz) of each spectral channel.
Array of size nsamples_
|
privateinherited |
A mutex.
When compiled with libpthread
|
protectedinherited |
The plug-ins that needs to be loaded to access this instance's class.
E.g. for an Astrobj, fillElement() will ensure
is written.
|
inherited |
Width of each channel.
Array of size nsamples_ (in Hz)