Gyoto
GyotoSpectrometer.h
Go to the documentation of this file.
1 
8 /*
9  Copyright 2011, 2013 Thibaut Paumard
10 
11  This file is part of Gyoto.
12 
13  Gyoto is free software: you can redistribute it and/or modify
14  it under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  Gyoto is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 #ifndef __GyotoSpectrometer_H_
28 #define __GyotoSpectrometer_H_
29 
30 #include <GyotoDefs.h>
31 #include <GyotoSmartPointer.h>
32 #include <GyotoRegister.h>
33 #include <GyotoHooks.h>
34 #include <string>
35 
49 namespace Gyoto{
50  namespace Spectrometer {
68  class Generic;
69 
82  typedef char const * kind_t;
83 
84 #if defined GYOTO_USE_XERCES
85 
96 
110  int errmode = 1);
111 
123  SmartPointer<T> spectro = new T();
124  if (fmp) spectro -> setParameters(fmp);
125  return spectro;
126  }
127 
136 
142  void initRegister();
143 
163  void Register(std::string name, Gyoto::Spectrometer::Subcontractor_t* scp);
164 #endif
165 
166  }
167 }
168 
170 : protected Gyoto::SmartPointee,
171  public Gyoto::Hook::Teller
172 {
173  friend class Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>;
174  protected:
184  public:
187 
203  double* boundaries_;
204 
211 
217  double* midpoints_;
218 
224  double* widths_;
225 
226  public:
232  Generic();
233 
254  Generic(kind_t kind);
255 
261  Generic(const Generic& ) ;
262 
276  virtual Generic * clone() const =0;
277 
283  virtual ~Generic();
284 
299  virtual kind_t getKind() const ;
300 
321  virtual void setKind(kind_t) ;
322 
323  virtual size_t getNSamples() const ;
324  virtual size_t getNBoundaries() const ;
325  virtual double const * getMidpoints() const ;
326 
331  virtual void getMidpoints( double data[], std::string unit);
337  virtual void getChannelBoundaries( double data[], std::string unit);
338  virtual double const * getChannelBoundaries() const ;
339  virtual size_t const * getChannelIndices() const ;
340  virtual double const * getWidths() const ;
341 
351  virtual void getWidths( double data[], std::string unit);
352 
378  virtual int setParameter(std::string name,
379  std::string content,
380  std::string unit);
381 #ifdef GYOTO_USE_XERCES
382 
383 
407  virtual void setParameters(Gyoto::FactoryMessenger *fmp) ;
408 
419  virtual void fillElement(FactoryMessenger *fmp) const ;
420 
421 #endif
422 };
423 
424 
425 #endif
virtual Generic * clone() const =0
Clone an instance.
double * boundaries_
Frequency (in Hz) at the boundaries of the spectral channels.
Definition: GyotoSpectrometer.h:203
virtual size_t const * getChannelIndices() const
Get Generic::chanind_.
virtual double const * getMidpoints() const
Get Generic::midpoints_.
Gyoto registers.
size_t * chanind_
Indices in boundaries_.
Definition: GyotoSpectrometer.h:210
Tellers tell Listeners when they mutate.
virtual int setParameter(std::string name, std::string content, std::string unit)
Set parameter by name.
Reference-counting pointers.
void Register(std::string name, Gyoto::Spectrometer::Subcontractor_t *scp)
Register a new Spectrometer kind.
#define size_t
If not defined in <sys/types.h>.
Definition: GyotoConfig.h:293
virtual void fillElement(FactoryMessenger *fmp) const
Write out parameters to XML entities.
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:91
char const * kind_t
Type for Spectrometer kind.
Definition: GyotoSpectrometer.h:68
virtual size_t getNSamples() const
Get Generic::nsamples_.
kind_t kind_
Spectrometer kind name.
Definition: GyotoSpectrometer.h:183
virtual double const * getWidths() const
Get Generic::widths_.
Gyoto ubiquitous macros and typedefs.
size_t nboundaries_
Size of the boundaries_ array.
Definition: GyotoSpectrometer.h:186
Gyoto::Spectrometer::Subcontractor_t * getSubcontractor(std::string name, int errmode=1)
Query the Spectrometer register.
virtual kind_t getKind() const
Get kind_.
virtual void setKind(kind_t)
Set Generic::kind_.
virtual size_t getNBoundaries() const
Get Generic::nboundaries_.
SmartPointer< Spectrometer::Generic > Subcontractor(FactoryMessenger *fmp)
A template for Subcontractor_t functions.
Definition: GyotoSpectrometer.h:122
Pointers performing reference counting.
Definition: GyotoSmartPointer.h:51
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:79
virtual void setParameters(Gyoto::FactoryMessenger *fmp)
Main loop in Subcontractor_t function.
double * widths_
Width of each channel.
Definition: GyotoSpectrometer.h:224
void initRegister()
Initialize the Spectrometer register This must be called once. It initializes Register_ and registers...
Gyoto::Register::Entry * Register_
The Spectrometer register.
SmartPointer< Gyoto::Spectrometer::Generic > Subcontractor_t(Gyoto::FactoryMessenger *)
A function to build instances of a specific Astrobj::Generic sub-class.
Definition: GyotoSpectrometer.h:94
virtual double const * getChannelBoundaries() const
Get Generic::boundaries_.
double * midpoints_
Effective frequency (in Hz) of each spectral channel.
Definition: GyotoSpectrometer.h:217
Listen to me and I'll warn you when I change.
Definition: GyotoHooks.h:82
Base class for spectrometers.
Definition: GyotoSpectrometer.h:169
size_t nsamples_
Number of spectral elements.
Definition: GyotoSpectrometer.h:185
Entry in a register (or a full register)
Definition: GyotoRegister.h:95