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 Register { class Entry; }
51  class FactoryMessenger;
52  namespace Spectrometer {
70  class Generic;
71 
84  typedef char const * kind_t;
85 
95  Subcontractor_t(Gyoto::FactoryMessenger*);
97 
111  int errmode = 0);
112 
123  (FactoryMessenger* fmp) {
124  SmartPointer<T> spectro = new T();
125 #ifdef GYOTO_USE_XERCES
126  if (fmp) spectro -> setParameters(fmp);
127 #endif
128  return spectro;
129  }
130 
139 
145  void initRegister();
146 
166  void Register(std::string name, Gyoto::Spectrometer::Subcontractor_t* scp);
167 
168  }
169 }
170 
172 : protected Gyoto::SmartPointee,
173  public Gyoto::Hook::Teller
174 {
175  friend class Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>;
176  protected:
186  public:
189 
205  double* boundaries_;
206 
213 
219  double* midpoints_;
220 
226  double* widths_;
227 
228  public:
234  Generic();
235 
256  Generic(kind_t kind);
257 
263  Generic(const Generic& ) ;
264 
278  virtual Generic * clone() const =0;
279 
285  virtual ~Generic();
286 
301  virtual kind_t kind() const ;
302 
323  virtual void kind(kind_t) ;
324 
325  virtual size_t nSamples() const ;
326  virtual size_t getNBoundaries() const ;
327  virtual double const * getMidpoints() const ;
328 
333  virtual void getMidpoints( double data[], std::string unit);
339  virtual void getChannelBoundaries( double data[], std::string unit);
340  virtual double const * getChannelBoundaries() const ;
341  virtual size_t const * getChannelIndices() const ;
342  virtual double const * getWidths() const ;
343 
353  virtual void getWidths( double data[], std::string unit);
354 
380  virtual int setParameter(std::string name,
381  std::string content,
382  std::string unit);
383 #ifdef GYOTO_USE_XERCES
384 
385 
409  virtual void setParameters(Gyoto::FactoryMessenger *fmp) ;
410 
421  virtual void fillElement(FactoryMessenger *fmp) const ;
422 
423 #endif
424 };
425 
426 
427 #endif
virtual Generic * clone() const =0
Clone an instance.
Pointers performing reference counting.
Definition: GyotoSmartPointer.h:51
double * boundaries_
Frequency (in Hz) at the boundaries of the spectral channels.
Definition: GyotoSpectrometer.h:205
virtual size_t const * getChannelIndices() const
Get Generic::chanind_.
virtual double const * getMidpoints() const
Get Generic::midpoints_.
Gyoto registers.
Gyoto::Spectrometer::Subcontractor_t * getSubcontractor(std::string name, int errmode=0)
Query the Spectrometer register.
size_t * chanind_
Indices in boundaries_.
Definition: GyotoSpectrometer.h:212
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 .
Definition: GyotoConfig.h:305
virtual void fillElement(FactoryMessenger *fmp) const
Write out parameters to XML entities.
char const * kind_t
Type for Spectrometer kind.
Definition: GyotoSpectrometer.h:70
kind_t kind_
Spectrometer kind name.
Definition: GyotoSpectrometer.h:185
virtual double const * getWidths() const
Get Generic::widths_.
Gyoto ubiquitous macros and typedefs.
size_t nboundaries_
Size of the boundaries_ array.
Definition: GyotoSpectrometer.h:188
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:42
virtual size_t getNBoundaries() const
Get Generic::nboundaries_.
SmartPointer< Spectrometer::Generic > Subcontractor(FactoryMessenger *fmp)
A template for Subcontractor_t functions.
Definition: GyotoSpectrometer.h:123
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:226
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:95
virtual double const * getChannelBoundaries() const
Get Generic::boundaries_.
double * midpoints_
Effective frequency (in Hz) of each spectral channel.
Definition: GyotoSpectrometer.h:219
virtual size_t nSamples() const
Get Generic::nsamples_.
virtual kind_t kind() const
Get kind_.
Listen to me and I'll warn you when I change.
Definition: GyotoHooks.h:82
Base class for spectrometers.
Definition: GyotoSpectrometer.h:171
size_t nsamples_
Number of spectral elements.
Definition: GyotoSpectrometer.h:187
Entry in a register (or a full register)
Definition: GyotoRegister.h:92