VPSSMgrFactory.h

Go to the documentation of this file.
00001 /**
00002  *  @file VPSSMgrFactory.h
00003  *    Header for factory to build instances of classes that manage the
00004  *    standard-state thermodynamic properties of a set of species 
00005  *    (see \ref mgrpdssthermocalc and class \link Cantera::VPSSMgrFactory VPSSMgrFactory\endlink);
00006  */
00007 
00008 /*
00009  * $Revision: 279 $
00010  * $Date: 2009-12-05 14:08:43 -0500 (Sat, 05 Dec 2009) $
00011  */
00012 
00013 /*
00014  * Copywrite (2006) Sandia Corporation. Under the terms of
00015  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
00016  * U.S. Government retains certain rights in this software.
00017  */
00018 
00019 #ifndef VPSSSPECIESTHERMO_FACTORY_H
00020 #define VPSSSPECIESTHERMO_FACTORY_H
00021 
00022 #include "SpeciesThermo.h"
00023 #include "ctexceptions.h"
00024 #include "FactoryBase.h"
00025 #include "VPSSMgr.h"
00026 
00027 namespace Cantera {
00028 
00029   class XML_Node;
00030   class VPStandardStateTP;
00031  
00032   //! Throw a named error for an unknown or missing vpss species thermo model.
00033   /*!
00034    *
00035    * @ingroup mgrpdssthermocalc
00036    */
00037   class UnknownVPSSMgrModel: public CanteraError {
00038   public:
00039     //! Constructor
00040     /*!
00041      * @param proc                    Function name error occurred.
00042      * @param VPSSMgrModel            Unrecognized species thermo calculator name
00043      */
00044     UnknownVPSSMgrModel(std::string proc,
00045                         std::string VPSSMgrModel) :
00046       CanteraError(proc,  "Specified VPSSMgr model "   
00047                    + VPSSMgrModel + 
00048                    " does not match any known type.") {}
00049     //! destructor
00050     virtual ~UnknownVPSSMgrModel() throw() {}
00051   };
00052   
00053   //! Factory to build instances of classes that manage the
00054   //! standard-state thermodynamic properties of a set of species.
00055   /*!
00056    *  This class is responsible for making the decision concerning
00057    *  which derivative of VPSSMgr object to use.
00058    *  The VPSSMgr object is used to calculate 
00059    *  thermodynamic functions for the standard state.
00060    *  It queries the database of species to understand what
00061    *  the requirements are for the submodels for all of the
00062    *  species in the phase. Then, it picks the derived VPSSMgr
00063    *  object to use and passes it back to the calling routine.
00064    *  It doesn't load any data into the derived
00065    *  VPSSMgr object. 
00066    *
00067    *  Making the choice of VPSSMgr types is the only
00068    *  thing this class does.
00069    *
00070    * This class is implemented as a singleton -- one in which
00071    * only one instance is needed.  The recommended way to access
00072    * the factory is to call this static method, which
00073    * instantiates the class if it is the first call, but
00074    * otherwise simply returns the pointer to the existing
00075    * instance.
00076    *
00077    * @ingroup mgrpdssthermocalc
00078    */
00079   class VPSSMgrFactory : public FactoryBase {
00080 
00081   public:
00082 
00083     //! Static method to return an instance of this class
00084     /*!
00085      * This class is implemented as a singleton -- one in which
00086      * only one instance is needed.  The recommended way to access
00087      * the factory is to call this static method, which
00088      * instantiates the class if it is the first call, but
00089      * otherwise simply returns the pointer to the existing
00090      * instance.
00091      */
00092     static VPSSMgrFactory* factory() {
00093 #if defined(THREAD_SAFE_CANTERA)
00094       boost::mutex::scoped_lock lock(vpss_species_thermo_mutex);
00095 #endif
00096       if (!s_factory) s_factory = new VPSSMgrFactory;
00097       return s_factory;
00098     }
00099 
00100     //! Delete static instance of this class
00101     /*!
00102      * If it is necessary to explicitly delete the factory before
00103      * the process terminates (for example, when checking for
00104      * memory leaks) then this method can be called to delete it.
00105      */
00106     void deleteFactory();
00107         
00108     //! Destructor
00109     /*!
00110      * Doesn't do anything. We do not delete statically
00111      * created single instance of this class here, because it would
00112      * create an infinite loop if destructor is called for that
00113      * single instance.
00114      */
00115     virtual ~VPSSMgrFactory();
00116 
00117     //! String conversion to an enumType
00118     /*!
00119      *  This routine is a string conversion. The string is obtained from the
00120      *  standardState model attribute and converted to a  VPSSMgr_enumType
00121      *  type.
00122      *
00123      * @param ssModel  String representing the VPSSMGr object
00124      */
00125     virtual VPSSMgr_enumType
00126     VPSSMgr_StringConversion(std::string ssModel) const;
00127 
00128     //! Create a new species variable pressure standard state calculator
00129     /*!
00130      * @param type    The enumerated type of the standard state calculator
00131      * @param vp_ptr  Variable pressure standard state ThermoPhase object
00132      *                that will be the owner.
00133      */ 
00134     virtual VPSSMgr* newVPSSMgr(VPSSMgr_enumType type, VPStandardStateTP *vp_ptr);
00135 
00136     //! Create a new species property manager for a group of species
00137     /*!
00138      * This routine will look through species nodes. It will discover what
00139      * each species needs for its species property managers. Then,
00140      * it will malloc and return the proper species property manager to use.
00141      *
00142      * @param vp_ptr         Variable pressure standard state ThermoPhase object
00143      *                       that will be the owner.
00144      * @param phaseNode_ptr  Pointer to the ThermoPhase phase XML Node
00145      * @param spDataNodeList Vector of XML_Nodes, each of which is a species XML Node.
00146      *                       There are m_kk of these.
00147      *
00148      *  @return              Returns a pointer to a newly malloced species property
00149      *                       manager object.
00150      */ 
00151     virtual VPSSMgr* newVPSSMgr(VPStandardStateTP *vp_ptr, 
00152                                 XML_Node* phaseNode_ptr, 
00153                                 std::vector<XML_Node *> & spDataNodeList);
00154 
00155   private:
00156 
00157     //! pointer to the sole instance of this class
00158     static VPSSMgrFactory* s_factory;
00159 
00160 #if defined(THREAD_SAFE_CANTERA)
00161     //! Decl of the static mutex variable that locks the 
00162     //! %VPSSMgr factory singelton
00163     static boost::mutex vpss_species_thermo_mutex;
00164 #endif
00165 
00166     //! Constructor. This is made private, so that only the static
00167     //! method factory() can instantiate the class.
00168     VPSSMgrFactory(){}
00169   };
00170 
00171 
00172   ////////////////////// Convenience functions ////////////////////
00173   //
00174   //  These functions allow using a different factory class that
00175   //  derives from SpeciesThermoFactory.
00176   //
00177   //////////////////////////////////////////////////////////////////
00178 
00179 
00180   //! Create a new species thermo manager instance, by specifying
00181   //! the type and (optionally) a pointer to the factory to use to create it.
00182   /*!
00183    * This utility program  will look through species nodes. It will discover what
00184    * each species needs for its species property managers. Then,
00185    * it will malloc and return the proper species property manager to use.
00186    *
00187    *  These functions allow using a different factory class that
00188    *  derives from SpeciesThermoFactory.
00189    *
00190    * @param type         Species thermo type.
00191    * @param vp_ptr       Variable pressure standard state ThermoPhase object
00192    *                     that will be the owner.
00193    * @param f            Pointer to a SpeciesThermoFactory. optional parameter. 
00194    *                    Defautls to NULL.
00195    */
00196   VPSSMgr* newVPSSMgr(VPSSMgr_enumType type, 
00197                       VPStandardStateTP *vp_ptr, VPSSMgrFactory* f=0);
00198 
00199   //! Function to return VPSSMgr manager
00200   /*!
00201    * This utility program  will look through species nodes. It will discover what
00202    * each species needs for its species property managers. Then,
00203    * it will alloc and return the proper species property manager to use.
00204    *
00205    *  These functions allow using a different factory class that
00206    *  derives from SpeciesThermoFactory.
00207    *
00208    * @param vp_ptr       Variable pressure standard state ThermoPhase object
00209    *                     that will be the owner.
00210    * @param phaseNode_ptr  Pointer to the ThermoPhase phase XML Node
00211    *
00212    * @param spDataNodeList This vector contains a list
00213    *                       of species XML nodes that will be in the phase
00214    *
00215    * @param f            Pointer to a SpeciesThermoFactory. optional parameter. 
00216    *                    Defautls to NULL.
00217    */
00218   VPSSMgr* newVPSSMgr(VPStandardStateTP *vp_ptr,
00219                       XML_Node* phaseNode_ptr,
00220                       std::vector<XML_Node *> & spDataNodeList,
00221                       VPSSMgrFactory* f=0);
00222 
00223 }
00224 
00225 #endif
00226 
00227 
Generated by  doxygen 1.6.3