// Read the documentation to learn more about C++ code generator // versioning. // %X% %Q% %Z% %W% #ifndef XSMODELFUNCTION_H #define XSMODELFUNCTION_H 1 // xsTypes #include // Error #include // ComponentInfo #include #ifdef INITPACKAGE # include #else # include #endif #include // invalid exception #include #include class MixUtility; typedef std::map > ParInfoContainer; class XSModelFunction { public: class NoSuchComponent : public YellowAlert //## Inherits: %3FBA6F620269 { public: NoSuchComponent(); protected: private: private: //## implementation }; virtual ~XSModelFunction() = 0; virtual void operator () (const RealArray& energyArray, const RealArray& params, int spectrumNumber, RealArray& fluxArray, RealArray& fluxErrArray, const string& initString) const = 0; virtual void operator () (const EnergyPointer& energyArray, const std::vector& params, GroupFluxContainer& fluxArrays, GroupFluxContainer& fluxErrArrays, MixUtility* mixGenerator, const string& modelName) const = 0; virtual MixUtility* getUtilityObject() const =0; static void updateComponentList (const string& modelDatFile, bool isStandard = false); static void printComponentList (std::ostream& s, const string& name = ""); static std::vector nameCache (const string& fullName // Full name is the expression representing a model typed // by the user. Only its first two characters are used // here. // Full name resolution in the case of duplicate names // is deferred to the fullMatch function. ); static ComponentInfo fullMatch (const string& fullName); static NameCacheType& nameCache (); static void nameCache (const string& shortName, const ComponentInfo& value); static ParInfoContainer& parInfoCache(); static NameCacheType::iterator exactMatch (const string& fullName); public: protected: XSModelFunction(); XSModelFunction(const XSModelFunction &right); private: XSModelFunction & operator=(const XSModelFunction &right); private: //## implementation // Data Members for Associations static NameCacheType s_nameCache; // Originally added just to hold parameter information strings for // user-defined Python models, since these are not stored in a // model.dat file. In the future this container may possibly be expanded to // contain ALL models' parameter strings so that Component::read() // won't have to continually retrieve them from the model.dat file. static ParInfoContainer s_parInfoCache; }; // Interface for calling model calculation functions template class XSCall : public XSModelFunction //## Inherits: %3E319B420391 { public: XSCall(const XSCall< T > &right); XSCall (T* generator); virtual ~XSCall(); virtual void operator () (const RealArray& energyArray, const RealArray& params, int spectrumNumber, RealArray& fluxArray, RealArray& fluxErrArray, const string& initString = string()) const; virtual void operator () (const EnergyPointer& energyArray, const std::vector& parameterValues, GroupFluxContainer& fluxArrays, GroupFluxContainer& fluxErrArrays, MixUtility* mixGenerator = 0, const string& modelName = string()) const; // More complicated models (ie. mix) may need to create MixUtility objects. // For everything else, the default implementation of this function returns NULL. // Note that the MixUtility type isn't defined until a higher level library. virtual MixUtility* getUtilityObject() const; T* generator () const; void generator (T* value); protected: private: XSCall(); XSCall< T > & operator=(const XSCall< T > &right); private: //## implementation // Data Members for Class Attributes T* m_generator; }; // Class XSModelFunction::NoSuchComponent // Class XSModelFunction inline XSModelFunction::XSModelFunction() { } inline XSModelFunction::XSModelFunction(const XSModelFunction &right) { } inline NameCacheType& XSModelFunction::nameCache () { return s_nameCache; } inline void XSModelFunction::nameCache (const string& shortName, const ComponentInfo& value) { s_nameCache.insert(NameCacheType::value_type(shortName,value)); } inline ParInfoContainer& XSModelFunction::parInfoCache() { return s_parInfoCache; } // Parameterized Class XSCall template MixUtility* XSCall::getUtilityObject() const { return 0; } template inline T* XSCall::generator () const { return m_generator; } template inline void XSCall::generator (T* value) { m_generator = value; } // Parameterized Class XSCall template XSCall::XSCall(const XSCall &right) : XSModelFunction(right), m_generator(right.m_generator) // default non-owning - shallow copy // (assume it's a function pointer) { } template XSCall::XSCall (T* generator) : m_generator(generator) { } template XSCall::~XSCall() { } template void XSCall::operator () (const RealArray& energyArray, const RealArray& params, int spectrumNumber, RealArray& fluxArray, RealArray& fluxErrArray, const string& initString) const { throw RedAlert("Model function is missing due to specialized template build error (1)."); } template void XSCall::operator () (const EnergyPointer& energyArray, const std::vector& parameterValues, GroupFluxContainer& fluxArrays, GroupFluxContainer& fluxErrArrays, MixUtility* mixGenerator, const string& modelName) const { throw RedAlert("Model function is missing due to specialized template build error (2)."); } template <> void XSCall::operator() (const RealArray& energyArray, const RealArray& params, int spectrumNumber, RealArray& fluxArray, RealArray& fluxErrArray, const string& initString) const; template <> void XSCall::operator() (const RealArray& energyArray, const RealArray& params, int spectrumNumber, RealArray& fluxArray, RealArray& fluxErrArray, const string& initString) const; template <> void XSCall::operator() (const RealArray& energyArray, const RealArray& params, int spectrumNumber, RealArray& fluxArray, RealArray& fluxErrArray, const string& initString) const; template <> void XSCall::operator() (const RealArray& energyArray, const RealArray& params, int spectrumNumber, RealArray& fluxArray, RealArray& fluxErrArray, const string& initString) const; template <> void XSCall::operator() (const EnergyPointer& energyArray, const std::vector& parameterValues, GroupFluxContainer& flux, GroupFluxContainer& fluxError, MixUtility* mixGenerator, const string& modelName) const; template <> void XSCall::operator() (const EnergyPointer& energyArray, const std::vector& parameterValues, GroupFluxContainer& flux, GroupFluxContainer& fluxError, MixUtility* mixGenerator, const string& modelName) const; template <> void XSCall::operator() (const RealArray& energyArray, const RealArray& params, int spectrumNumber, RealArray& fluxArray, RealArray& fluxErrArray, const string& initString) const; template <> XSCall::~XSCall(); template <> XSCall::XSCall(const XSCall &right); #endif