Gyoto
|
Base class for spectrometers. More...
#include <GyotoSpectrometer.h>
Public Member Functions | |
Generic () | |
Default constructor. More... | |
Generic (kind_t kind) | |
Constructor setting kind. More... | |
Generic (const Generic &) | |
Copy constructor. More... | |
virtual Generic * | clone () const =0 |
Clone an instance. More... | |
virtual | ~Generic () |
Destructor. More... | |
virtual kind_t | getKind () const |
Get kind_. More... | |
virtual void | setKind (kind_t) |
Set Generic::kind_. More... | |
virtual size_t | getNSamples () const |
Get Generic::nsamples_. | |
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... | |
virtual int | setParameter (std::string name, std::string content, std::string unit) |
Set parameter by name. More... | |
virtual void | setParameters (Gyoto::FactoryMessenger *fmp) |
Main loop in Subcontractor_t function. More... | |
virtual void | fillElement (FactoryMessenger *fmp) const |
Write out parameters to XML entities. More... | |
virtual void | hook (Listener *listener) |
Start listening. More... | |
virtual void | unhook (Listener *listener) |
Stop listening. More... | |
Public Attributes | |
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... | |
Protected Types | |
typedef Gyoto::SmartPointer < Gyoto::SmartPointee > | Subcontractor_t (Gyoto::FactoryMessenger *) |
A subcontractor builds an object upon order from the Factory. More... | |
Protected Member Functions | |
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 void | tellListeners () |
Call tell() on each hooked Listener. More... | |
Protected Attributes | |
kind_t | kind_ |
Spectrometer kind name. More... | |
Friends | |
class | Gyoto::SmartPointer< Gyoto::Spectrometer::Generic > |
Base class for spectrometers.
Example: class Gyoto::Spectrometer::Uniform
See Gyoto::Spectrometer for an introduction.
Generic inherits from Gyoto::SmartPointee so that it is possible to create a SmartPointer to a Spectrometer.
It also inherits from Gyoto::Hook::Teller. This allows a consistent implementation of Spectrometer::Complex (in particular). Any method which mutates a Spectrometer should call tellListeners().
|
inherited |
A subcontractor builds an object upon order from the Factory.
Various classes need to provide a subcontractor to be able to instanciate 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().
Gyoto::Spectrometer::Generic::Generic | ( | ) |
Default constructor.
Sets each member to 0.
Gyoto::Spectrometer::Generic::Generic | ( | kind_t | kind) |
Constructor setting kind.
Sets the other members to 0. This is usually the right constructor to use:
Always set kind to the adress of a static variable, not to a temporary. Usually your class should have a static member for that purpose:
Gyoto::Spectrometer::Generic::Generic | ( | const Generic & | ) |
Copy constructor.
Takes care of (deep) copying all the members known to the base class.
|
virtual |
Destructor.
Takes care of deleting the arrays (if the pointers are not NULL).
|
pure virtual |
Clone an instance.
Use this to get a deep copy of an instance;
Most implementations will use the copy constructor:
Implemented in Gyoto::Spectrometer::Complex, and Gyoto::Spectrometer::Uniform.
|
virtual |
Write out parameters to XML entities.
Spectrometers implementations should impement fillElement to save their parameters to XML and call the Spectrometer::fillElement(fmp) for the shared properties.
This is mainly used by the Yorick plug-in to print out any sort of GYOTO objects and to save them to XML files.
Reimplemented in Gyoto::Spectrometer::Complex, and Gyoto::Spectrometer::Uniform.
|
virtual |
Copy Generic::boundaries_, converting to unit.
data | an array of Generic::nboundaries_ doubles to fill with result |
unit | a string |
|
virtual |
Get kind_.
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.
|
virtual |
Copy Generic::midpoints_, converting to unit.
data | an array of Generic::nsamples_ doubles to fill with result |
unit | a string |
|
virtual |
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 |
|
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 |
|
virtual |
Set Generic::kind_.
This should rarely be used as the Generic::kind_ attribute usually is set in the constructor and doesn't change after that.
Always set to the adress of a static variable, not to a temporary. Usually your class should have a static member for that purpose:
Reimplemented in Gyoto::Spectrometer::Uniform.
|
virtual |
Set parameter by name.
Assume MyKind is a subclass of Spectrometer::Generic which has two members (a string StringMember and a double DoubleMember):
If MyKind is not a direct subclass of Generic, it should call the corresponding setParameter() implementation instead of Generic::setParameter().
name | XML name of the parameter |
content | string representation of the value |
unit | string representation of the unit |
Reimplemented in Gyoto::Spectrometer::Uniform.
|
virtual |
Main loop in Subcontractor_t function.
The Subcontractor_t function for each Spectrometer kind should look somewhat like this (templated as Gyoto::Spectrometer::Subcontractor<MyKind>):
Each spectrometer kind should implement setParameter(string name, string content, string unit) to interpret the individual XML elements. setParameters() can be overloaded in case the specific Spectrometer class needs low level access to the FactoryMessenger. See Gyoto::Astrobj::UniformSphere::setParameters().
Reimplemented in Gyoto::Spectrometer::Complex, and Gyoto::Spectrometer::Uniform.
|
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 |
double* Gyoto::Spectrometer::Generic::boundaries_ |
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.
size_t* Gyoto::Spectrometer::Generic::chanind_ |
Indices in boundaries_.
Array of size 2*nsamples_
|
protected |
Spectrometer kind name.
The content is not copied. kind_ should be set (as a parameter to the Generic() constructor or using setKind()) to the adress of a static variable holding the name. This allows checking the kind using pointer comparison rather than string comparison.
double* Gyoto::Spectrometer::Generic::midpoints_ |
Effective frequency (in Hz) of each spectral channel.
Array of size nsamples_
double* Gyoto::Spectrometer::Generic::widths_ |
Width of each channel.
Array of size nsamples_ (in Hz)