Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

object.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////////////////
00002 /// \file  object.h
00003 /// \brief Declaration of the SPARK::TObject 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 12, 2003
00014 /////////////////////////////////////////////////////////////////////////////////////////
00015 
00016 
00017 
00018 #if !defined(__OBJECT_H__)
00019 #define __OBJECT_H__
00020 
00021 #include <memory>      // for std::auto_ptr<>
00022 
00023 #include "callback.h"  // for SPARK::TArgument and SPARK::TTarget classes
00024 #include "compat.h"    // for CLASS_DECLSPEC
00025 
00026 
00027 /////////////////////////////////////////////////////////////////////////////////////////
00028 namespace SPARK {
00029 
00030 
00031         /////////////////////////////////////////////////////////////////////////////////////
00032         // Forward declaration
00033         /////////////////////////////////////////////////////////////////////////////////////
00034         class TProblem;
00035         class TComponent;
00036         class TInverse;
00037         class TObjectHandler;
00038         class object_adaptor;
00039     class const_object_adaptor;
00040 
00041 
00042         /////////////////////////////////////////////////////////////////////////////////////
00043         /// \class TObject
00044         /// \brief Class used to represent an instance of an inverse.
00045         ///
00046         /// \note Static callbacks do not require argument lists
00047         ///
00048         class CLASS_DECLSPEC TObject {
00049         public:
00050                 /////////////////////////////////////////////////////////////////////////////////
00051                 // Structors
00052                 TObject(
00053                         unsigned handle,
00054                         const char* name, SPARK::TInverse* instance, 
00055                         unsigned numTargets, SPARK::TTarget targets[],
00056                         // Args list for instance callbacks
00057                         unsigned numArgs_Predict, SPARK::TArgument args_Predict[],
00058                         unsigned numArgs_Evaluate, SPARK::TArgument args_Evaluate[],
00059                         unsigned numArgs_Construct, SPARK::TArgument args_Construct[],
00060                         unsigned numArgs_Destruct, SPARK::TArgument args_Destruct[],
00061                         unsigned numArgs_PrepareStep, SPARK::TArgument args_PrepareStep[],
00062                         unsigned numArgs_CheckIntegrationStep, SPARK::TArgument args_CheckIntegrationStep[],
00063                         unsigned numArgs_Rollback, SPARK::TArgument args_Rollback[],
00064                         unsigned numArgs_Commit, SPARK::TArgument args_Commit[] );
00065                 ~TObject() SPARK_NOT_THROWING;
00066 
00067 
00068                 /////////////////////////////////////////////////////////////////////////////////
00069                 /// \name Access methods
00070                 //@{
00071                 /// Returns unique handle as specified in XML file 
00072                 unsigned GetHandle() const { return Handle; }
00073                 
00074                 /// Returns unique inverse handle set by SPARK::TInverse object for each instance
00075                 unsigned GetInstanceHandle() const { return InstanceHandle; }
00076 
00077                 /// Returns name of object as specified in XML file as <code>const char* </code>
00078                 const char* GetName() const;
00079 
00080                 /// Returns the name of the currently active callback, Returns "" if none active!
00081                 const char* GetActiveCallbackName() const;
00082                 
00083                 /// Returns name of SPARK::TInverse this object is an instance of 
00084                 SPARK::TInverse* GetInverse() ;
00085                 const SPARK::TInverse* GetInverse() const ;
00086 
00087                 /// Returns pointer to SPARK::TProblem object this object belongs to
00088                 const SPARK::TProblem* GetProblem() const;
00089                 
00090                 /// Returns pointer to SPARK::TComponent object this object belongs to
00091                 const SPARK::TComponent* GetComponent() const;
00092 
00093                 /// Returns value of relative tolerance curently used by solver
00094                 double GetTolerance() const ;
00095                 //@}
00096                 /////////////////////////////////////////////////////////////////////////////////
00097 
00098 
00099                 /////////////////////////////////////////////////////////////////////////////////
00100                 /// \name Data methods
00101                 //@{
00102                 /// Returns private data associated with this instance as <code>void* </code>
00103                 void* GetData() { return Data; }
00104                 
00105                 /// Sets the private data to \c address
00106                 void SetData(void* address) { Data = address; }
00107 
00108                 //@}
00109                 /////////////////////////////////////////////////////////////////////////////////
00110                 
00111         private:
00112                 /////////////////////////////////////////////////////////////////////////////////
00113                 // Private Methods
00114                 /////////////////////////////////////////////////////////////////////////////////
00115                 TObject();
00116                 TObject(const TObject& );
00117                 TObject& operator=(const TObject& );
00118 
00119 
00120                 /////////////////////////////////////////////////////////////////////////////////
00121                 // Private Data
00122                 /////////////////////////////////////////////////////////////////////////////////
00123                 unsigned                                   Handle;           ///< global unsique handle specified in XML file
00124                 unsigned                                   InstanceHandle;   ///< unique identifier within TInverse* Instance
00125         const std::auto_ptr<SPARK::TObjectHandler> Handler;          ///< Pimpl object
00126                 void*                                      Data;             ///< Pointer to private data as void*
00127 
00128                 friend class SPARK::object_adaptor;
00129         friend class SPARK::const_object_adaptor;
00130         };
00131         /////////////////////////////////////////////////////////////////////////////////////
00132 
00133 
00134 }; // namespace SPARK
00135 /////////////////////////////////////////////////////////////////////////////////////////
00136 
00137 
00138 #endif //__OBJECT_H__
00139 
00140 
00141 


Generated on 5 Nov 2003 for VisualSPARK 2.01