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  class FactoryMessenger;
35  namespace Spectrum {
36  class Generic;
37 #if defined GYOTO_USE_XERCES
38 
40 
51 
62  SmartPointer<T> sp = new T();
63  sp -> setParameters(fmp);
64  return sp;
65  }
66 
68 
79  void Register(std::string kind, Gyoto::Spectrum::Subcontractor_t* scp);
80 
82 
94  getSubcontractor(std::string name, int errmode=0);
95 
97 
102  extern Register::Entry* Register_;
103 
105 
109  void initRegister();
110 #endif
111  }
112 }
113 
114 #include <GyotoSmartPointer.h>
115 #include <string>
124  friend class Gyoto::SmartPointer<Gyoto::Spectrum::Generic>;
125  protected:
126  std::string kind_;
127 
128  public:
129  Generic(const std::string kind);
130  // Spectrum::Generic(const Spectrum::Generic &); ///< Copy constructor. Default is fine.
131  virtual Generic * clone() const;
132 
133  virtual ~Generic() ;
134 
135  const std::string getKind() const;
136 
137  virtual double operator()(double nu) const =0;
139 
146  virtual double operator()(double nu, double opacity, double ds) const;
148 
157  virtual double integrate(double nu1, double nu2) ;
158 
170  virtual double integrate(double nu1, double nu2,
171  const Spectrum::Generic * opacity, double ds) ;
172 
173 #ifdef GYOTO_USE_XERCES
174 
180  virtual void fillElement(FactoryMessenger *fmp) const ;
182  virtual void setParameter(std::string name,
183  std::string content,
184  std::string unit) ;
186 
205  virtual void setParameters(FactoryMessenger *fmp);
207 
208 #endif
209 };
210 
211 
212 #endif
Gyoto registers.
void Register(std::string kind, Gyoto::Spectrum::Subcontractor_t *scp)
Make a Spectrum kind known to the Factory.
Reference-counting pointers.
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:91
const std::string getKind() const
Get spectrum kind.
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:50
virtual void setParameter(std::string name, std::string content, std::string unit)
To be called by fillElement()
virtual void fillElement(FactoryMessenger *fmp) const
called from Factory
Pointers performing reference counting.
Definition: GyotoSmartPointer.h:51
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:79
std::string kind_
e.g. constants, blackbody...
Definition: GyotoSpectrum.h:126
Register::Entry * Register_
The Spectrum register.
Spectrum emitted by an Astrobj.
Definition: GyotoSpectrum.h:123
void initRegister()
Empty the Spectrum register.
virtual Generic * clone() const
Cloner.
SmartPointer< Spectrum::Generic > Subcontractor(FactoryMessenger *fmp)
Subcontractor template.
Definition: GyotoSpectrum.h:61
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:95