00001 ///////////////////////////////////////////////////////////////////////////////////////// 00002 /// \file inverse.h 00003 /// \brief Declaration of the SPARK::TInverse class 00004 /// 00005 ///////////////////////////////////////////////////////////////////////////////////////// 00006 /// \attention 00007 /// PORTIONS COPYRIGHT (C) 2003 AYRES SOWELL ASSOCIATES, INC. \n 00008 /// PORTIONS COPYRIGHT (C) 2003 THE REGENTS OF THE UNIVERSITY OF CALIFORNIA . 00009 /// PENDING APPROVAL BY THE US DEPARTMENT OF ENERGY. ALL RIGHTS RESERVED. 00010 /// 00011 ///////////////////////////////////////////////////////////////////////////////////////// 00012 /// \author Dimitri Curtil (LBNL/SRG) 00013 /// \date January 10, 2003 00014 ///////////////////////////////////////////////////////////////////////////////////////// 00015 00016 00017 #if !defined(__INVERSE_H__) 00018 #define __INVERSE_H__ 00019 00020 #include <memory> // for std::auto_ptr<> 00021 00022 #include "callback.h" 00023 #include "types.h" // for AtomicTypes 00024 #include "compat.h" // for CLASS_DECLSPEC 00025 00026 00027 00028 ///////////////////////////////////////////////////////////////////////////////////////// 00029 namespace SPARK { 00030 00031 ///////////////////////////////////////////////////////////////////////////////////// 00032 // Forward declaration 00033 ///////////////////////////////////////////////////////////////////////////////////// 00034 class TProblem; 00035 class TObject; 00036 class TInverseHandler; 00037 class inverse_adaptor; 00038 00039 00040 ///////////////////////////////////////////////////////////////////////////////////// 00041 /// \class TInverse 00042 /// \brief Class that defines the callbacks for an inverse. 00043 /// 00044 /// Also contains all instances as SPARK::TObject objects of an inverse, as well as the void* 00045 /// pointer to the static data. 00046 /// 00047 class CLASS_DECLSPEC TInverse { 00048 public: 00049 ///////////////////////////////////////////////////////////////////////////////// 00050 // Structors 00051 TInverse( 00052 unsigned handle, 00053 const char* name, 00054 const char* classname, 00055 const char* fileName, 00056 SPARK::AtomicTypes type, 00057 const TModifierCallback& predict, 00058 const TModifierCallback& evaluate, 00059 const TNonModifierCallback& construct, 00060 const TNonModifierCallback& destruct, 00061 const TNonModifierCallback& prepare_step, 00062 const TPredicateCallback& check_integration_step, 00063 const TNonModifierCallback& rollback, 00064 const TNonModifierCallback& commit, 00065 const TStaticNonModifierCallback& static_construct, 00066 const TStaticNonModifierCallback& static_destruct, 00067 const TStaticNonModifierCallback& static_prepare_step, 00068 const TStaticPredicateCallback& static_check_integration_step, 00069 const TStaticNonModifierCallback& static_rollback, 00070 const TStaticNonModifierCallback& static_commit 00071 ); 00072 ~TInverse() SPARK_NOT_THROWING; 00073 ///////////////////////////////////////////////////////////////////////////////// 00074 00075 00076 ///////////////////////////////////////////////////////////////////////////////// 00077 /// \name Access methods 00078 //@{ 00079 /// Returns unique inverse handle as specified in XML file 00080 unsigned GetHandle() const ; 00081 00082 /// Returns name of inverse as specified in XML file as <code>const char* </code> 00083 const char* GetName() const ; 00084 00085 /// Returns class name as specified in XML file as <code>const char* </code> 00086 const char* GetAtomicClassName() const; 00087 00088 /// Returns file name of atomic class where the inverse is declared as <code>const char* </code> 00089 const char* GetFileName() const ; 00090 00091 /// Returns the type of the inverse as SPARK::AtomicTypes 00092 SPARK::AtomicTypes GetAtomicType() const; 00093 00094 /// Returns the name of the currently active callback, Returns "" if none active! 00095 const char* GetActiveCallbackName() const; 00096 00097 /// Returns the number of TObject instances of this inverse 00098 unsigned GetNumObjects() const; 00099 00100 /// Returns instance idx as a SPARK::TObject pointer 00101 SPARK::TObject* GetObject(unsigned idx); 00102 00103 /// Returns pointer to SPARK::TProblem object this inverse belongs to 00104 const SPARK::TProblem* GetProblem() const; 00105 00106 /// Returns value of relative tolerance currently used by solver 00107 double GetTolerance() const ; 00108 //@} 00109 ///////////////////////////////////////////////////////////////////////////////// 00110 00111 00112 ///////////////////////////////////////////////////////////////////////////////// 00113 /// \name Data methods 00114 //@{ 00115 /// Returns static private data as <code>void* </code> 00116 void* GetStaticData() { return StaticData; } 00117 00118 /// Sets the static private data to \c address 00119 void SetStaticData(void* address) { StaticData = address; } 00120 //@} 00121 ///////////////////////////////////////////////////////////////////////////////// 00122 00123 00124 private: 00125 ///////////////////////////////////////////////////////////////////////////////// 00126 // Private Methods 00127 ///////////////////////////////////////////////////////////////////////////////// 00128 TInverse(); 00129 TInverse(const TInverse& ); // Copy constructor 00130 TInverse& operator=(const TInverse& ); 00131 00132 // Called internally by TObject's constructor to self-register itself 00133 unsigned RegisterInstance(SPARK::TObject* object); 00134 friend class SPARK::TObject; 00135 00136 00137 ///////////////////////////////////////////////////////////////////////////////// 00138 // Private Data 00139 ///////////////////////////////////////////////////////////////////////////////// 00140 const std::auto_ptr<SPARK::TInverseHandler> Handler; ///< Pimpl object 00141 void* StaticData; ///< void* pointer to hold static private data 00142 00143 friend class SPARK::inverse_adaptor; 00144 }; 00145 ///////////////////////////////////////////////////////////////////////////////////// 00146 00147 00148 }; // namespace SPARK 00149 ///////////////////////////////////////////////////////////////////////////////////////// 00150 00151 00152 #endif // __INVERSE_H__ 00153 00154