Gyoto
GyotoSpectrum.h
Go to the documentation of this file.
1 
8 /*
9  Copyright 2011-2012 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 __GyotoSpectrum_H_
28 #define __GyotoSpectrum_H_
29 
30 #include "GyotoRegister.h"
31 
32 namespace Gyoto{
33  namespace Register { class Entry; }
34  class FactoryMessenger;
35 
37  namespace Spectrum {
38  class Generic;
39 
41 
51  Subcontractor_t(Gyoto::FactoryMessenger* fmp);
52 
62  (FactoryMessenger* fmp) {
63  SmartPointer<T> sp = new T();
64 #ifdef GYOTO_USE_XERCES
65  sp -> setParameters(fmp);
66 #endif
67  return sp;
68  }
69 
71 
82  void Register(std::string kind, Gyoto::Spectrum::Subcontractor_t* scp);
83 
85 
97  getSubcontractor(std::string name, int errmode=0);
98 
100 
105  extern Register::Entry* Register_;
106 
108 
112  void initRegister();
113  }
114 }
115 
116 #include <GyotoSmartPointer.h>
117 #include <string>
126  friend class Gyoto::SmartPointer<Gyoto::Spectrum::Generic>;
127  protected:
128  std::string kind_;
129 
130  public:
131  Generic(const std::string kind);
132  // Spectrum::Generic(const Spectrum::Generic &); ///< Copy constructor. Default is fine.
133  virtual Generic * clone() const;
134 
135  virtual ~Generic() ;
136 
137  const std::string kind() const;
138 
139  virtual double operator()(double nu) const =0;
141 
148  virtual double operator()(double nu, double opacity, double ds) const;
150 
159  virtual double integrate(double nu1, double nu2) ;
160 
172  virtual double integrate(double nu1, double nu2,
173  const Spectrum::Generic * opacity, double ds) ;
174 
175  virtual void setParameter(std::string name,
176  std::string content,
177  std::string unit) ;
179 
180 #ifdef GYOTO_USE_XERCES
181 
187  virtual void fillElement(FactoryMessenger *fmp) const ;
189 
208  virtual void setParameters(FactoryMessenger *fmp);
210 
211 #endif
212 };
213 
214 
215 #endif
const std::string kind() const
Get spectrum kind.
Pointers performing reference counting.
Definition: GyotoSmartPointer.h:51
Gyoto registers.
void Register(std::string kind, Gyoto::Spectrum::Subcontractor_t *scp)
Make a Spectrum kind known to the Factory.
Reference-counting pointers.
Gyoto::SmartPointer< Gyoto::Spectrum::Generic > Subcontractor_t(Gyoto::FactoryMessenger *fmp)
A function to build instances of a specific Spectrum::Generic sub-class.
Definition: GyotoSpectrum.h:51
virtual void setParameter(std::string name, std::string content, std::string unit)
Set any parameter by its name.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:42
virtual void fillElement(FactoryMessenger *fmp) const
called from Factory
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:79
std::string kind_
e.g. constants, blackbody...
Definition: GyotoSpectrum.h:128
Register::Entry * Register_
The Spectrum register.
Spectrum emitted by an Astrobj.
Definition: GyotoSpectrum.h:125
void initRegister()
Empty the Spectrum register.
virtual Generic * clone() const
Cloner.
SmartPointer< Spectrum::Generic > Subcontractor(FactoryMessenger *fmp)
Subcontractor template.
Definition: GyotoSpectrum.h:62
virtual void setParameters(FactoryMessenger *fmp)
Main loop in Subcontractor_t function.
virtual double integrate(double nu1, double nu2)
Integrate optically thick I_nu.
Gyoto::Spectrum::Subcontractor_t * getSubcontractor(std::string name, int errmode=0)
Query the Spectrum register.
Entry in a register (or a full register)
Definition: GyotoRegister.h:92