Doxygen update -> Added ThermoFactory

This commit is contained in:
Harry Moffat 2007-02-09 22:12:06 +00:00
parent 14862c28c1
commit 54daaf80c1
2 changed files with 103 additions and 70 deletions

View file

@ -1,5 +1,8 @@
/**
* @file ThermoFactory.cpp
*
* Definition of the %ThermoPhase factory base class.
* All known ThermoPhases to Cantera should be listed here.
*/
/*
@ -63,10 +66,10 @@ namespace Cantera {
cSurf, cEdge, cMetal, cStoichSubstance,
cPureFluid, cLatticeSolid, cLattice};
/**
/*
* This method returns a new instance of a subclass of ThermoPhase
*/
ThermoPhase* ThermoFactory::newThermoPhase(string model) {
ThermoPhase* ThermoFactory::newThermoPhase(std::string model) {
int ieos=-1;

View file

@ -1,5 +1,8 @@
/**
* @file ThermoFactory.h
*
* This file contains the definition for the factory
* class that can create know %ThermoPhase objects.
*/
/*
@ -20,81 +23,108 @@
namespace Cantera {
/*!
* @addtogroup thermoprops
*
* Standard %ThermoPhase objects may be instantiated by calling
* the main %Cantera factory class for %ThermoPhase objects; This class is called ThermoFactory.
*/
//@{
class UnknownThermoPhaseModel : public CanteraError {
public:
UnknownThermoPhaseModel(std::string proc, std::string thermoModel) :
CanteraError(proc, "Specified ThermoPhase model "
+ thermoModel +
" does not match any known type.") {}
virtual ~UnknownThermoPhaseModel() {}
};
/**
* Factory for thermodynamic property managers.
//! Specific error to be thrown if the type of Thermo mananger is unrecognized.
/*!
* This particular error class may be caught, if the application may have other
* models that the main Cantera appliation doesn't know about.
*/
class UnknownThermoPhaseModel : public CanteraError {
public:
//! Constructor
/*!
* @param proc Function name where the error occurred.
* @param thermoModel Sting name of ThermoPhase which didn't match
*/
class ThermoFactory {
UnknownThermoPhaseModel(std::string proc, std::string thermoModel) :
CanteraError(proc, "Specified ThermoPhase model "
+ thermoModel +
" does not match any known type.") {}
//! destructor
virtual ~UnknownThermoPhaseModel() {}
};
public:
//! Factory class for thermodynamic property managers.
/*!
* This class keeps a list of the known ThermoPhase classes, and is used
* to create new instances of these classes.
*/
class ThermoFactory {
static ThermoFactory* factory() {
if (!s_factory) s_factory = new ThermoFactory;
return s_factory;
}
public:
static void deleteFactory() {
if (s_factory) {
delete s_factory;
s_factory = 0;
}
}
/**
* Destructor doesn't do anything. We do not delete statically
* created single instance of this class here, because it would
* create an infinite loop if destructor is called for that
* single instance.
*/
virtual ~ThermoFactory() {
}
/**
* Create a new thermodynamic property manager.
* @param type the type to be created.
*/
//virtual ThermoPhase* newThermo(XML_Node& node, std::string id);
virtual ThermoPhase* newThermoPhase(std::string model);
private:
static ThermoFactory* s_factory;
ThermoFactory(){}
};
/**
* Create a new thermo manager instance.
*/
// inline ThermoPhase* newThermoMgr(XML_Node& root, std::string id,
// ThermoFactory* f=0) {
// if (f == 0) {
// f = ThermoFactory::factory();
// }
// ThermoPhase* therm = f->newThermo(root, id);
// return therm;
// }
/**
* Create a new thermo manager instance.
*/
inline ThermoPhase* newThermoPhase(std::string model,
ThermoFactory* f=0) {
if (f == 0) {
f = ThermoFactory::factory();
}
return f->newThermoPhase(model);
//! Static function that creates a static instance of the factor.
static ThermoFactory* factory() {
if (!s_factory) s_factory = new ThermoFactory;
return s_factory;
}
//! delete the static instance of this factory
static void deleteFactory() {
if (s_factory) {
delete s_factory;
s_factory = 0;
}
}
//! Destructor doesn't do anything.
/*!
* We do not delete statically
* created single instance of this class here, because it would
* create an infinite loop if destructor is called for that
* single instance.
*/
virtual ~ThermoFactory() { }
//! Create a new thermodynamic property manager.
/*!
* @param model String to look up the model against
*
* @return
* Returns a pointer to a new ThermoPhase instance matching the
* model string. Returns NULL if something went wrong.
* Throws an exception UnknownThermoPhaseModel if the string
* wasn't matched.
*/
virtual ThermoPhase* newThermoPhase(std::string model);
private:
//! static member of a single instance
static ThermoFactory* s_factory;
//! Private constructor prevents usage
ThermoFactory(){}
};
//! Create a new thermo manager instance.
/*!
* @param model String to look up the model against
* @param f ThermoFactor instance to use in matching the string
*
* @return
* Returns a pointer to a new ThermoPhase instance matching the
* model string. Returns NULL if something went wrong.
* Throws an exception UnknownThermoPhaseModel if the string
* wasn't matched.
*/
inline ThermoPhase* newThermoPhase(std::string model,
ThermoFactory* f=0) {
if (f == 0) {
f = ThermoFactory::factory();
}
return f->newThermoPhase(model);
}
//@}
}
#endif