Actual source code: object.h

  1: #ifndef __PETSc_Object_h__

  4: #include "petsc.h"
  5: #if defined(PETSC_HAVE_STDLIB_H)
  6: #include <stdlib.h>
  7: #endif

  9: // #include "esi/ESI.h"
 10: #define ESI_NO_COMPLEX
 11: #include "esi/basicTypes.h"
 12: #include "esi/ordinalTraits.h"
 13: #include "esi/scalarTraits.h"
 14: #include "esi/Argv.h"
 15: #include "esi/Object.h"
 16: #include "esi/MPI_traits.h"

 18: #if defined(PETSC_HAVE_CCA)
 19: #include "cca.h"
 20: #endif

 22: namespace esi{namespace petsc{

 24: /**=========================================================================**/
 25: class Object : public virtual esi::Object
 26: #if defined(PETSC_HAVE_CCA)
 27:              , public virtual gov::cca::Port, public virtual gov::cca::Component
 28: #endif
 29: {
 30:   public:

 32:     // Constructor.
 33:     Object()               {comm = 0; pobject = 0; refcnt = 1;};

 35:     // Destructor.
 36:     virtual ~Object(void) {};


 39:     //  Interface for esi::Object  ---------------

 41:     virtual esi::ErrorCode setRunTimeModel(const char * name,void * comm);
 42:     virtual esi::ErrorCode getRunTimeModel(const char * name,void * & comm);
 43:     virtual esi::ErrorCode getRunTimeModelsSupported(esi::Argv * list);

 45:     virtual esi::ErrorCode getInterface(const char* name, void*& iface);
 46:     virtual esi::ErrorCode getInterfacesSupported(esi::Argv * list);

 48:     virtual esi::ErrorCode addReference() ;
 49:     virtual esi::ErrorCode deleteReference() ;


 52:     // Interface for gov::cca::Component
 53: #if defined(PETSC_HAVE_CCA)
 54:     virtual void setServices(gov::cca::Services *);
 55: #endif

 57:   protected:
 58:     MPI_Comm    comm;
 59:     PetscObject pobject;
 60:     int         refcnt;
 61: };

 63: }}

 65: #if defined(PETSC_HAVE_CCA)
 66: namespace gov{namespace cca{namespace petsc{
 67: class Services  {
 68:   public:
 69:     /** obligatory virtual destructor */
 70:     virtual ~Services (void){}

 72:     /** Creates a PortInfo to be used in subsequent
 73:           calls to describe a Port. The arguments given are copied, not kept.
 74:           properties is an even length list (argv) of key/value pairs 
 75:           terminated by a NULL key. Note that names of Ports in a 
 76:           component are not distinct for used and provided ports. 
 77:           Standard properties: (UNADOPTED, extensible list)
 78:                 gov.cca.port.minConnections (int >= 0; default 0)
 79:                 gov.cca.port.maxConnections (int >= 1, default 1)
 80:                 gov.cca.port.proxyAllowed   (true,false; default false)
 81:       */
 82:     virtual PortInfo *  createPortInfo(CONST char *name, CONST char *type, CONST char** properties){};

 84:       /**  Fetch a port from the framework. Normally this means a uses port.
 85:       If no uses port is connected and a provided port of the name requested
 86:       is available, the component will be handed back that port.
 87:        Returns NULL if no provided port or uses port connection matches name.
 88:        @see Services.java; UNADOPTED C++ definition of "an error occurs".
 89:    */
 90:     virtual Port *getPort(CONST char *name){};

 92:       /** Free's the port indicated by the instance name for modification
 93:           by the component's containing framework.  After this call the
 94:           port will not be valid for use until getPort() is called
 95:           again.*/
 96:     virtual void releasePort(CONST char *name){};

 98:       /** Notifies the framework that a port described by PortInfo
 99:           may be used by this component. The portinfo is obtained 
100:       from createPortInfo. Returns nonzero if there is an error
101:       in registering, such as bad PortInfo or already registered.
102:        @see Services.java; UNADOPTED C++ definition of "an error occurs".
103:       */
104:     virtual int registerUsesPort(PortInfo *name_and_type){};

106:       /** Notify the framework that a Port, previously
107:           registered by this component, is no longer desired.
108:           Returns nonzero if the port is still in use, ignoring
109:           the unregister request.
110:        @see Services.java; UNADOPTED C++ definition of "an error occurs".
111:        */
112:     virtual int unregisterUsesPort(CONST char *name){};

114:       /** Exports a Port implemented by this component to the framework.  
115:           This Port is now available for the framework to
116:           connect to other components. The PortInfo is obtained 
117:       from createPortInfo. Returns nonzero if addProvidesPort fails,
118:       for example, because that name is already provided.
119:        @see Services.java; UNADOPTED C++ definition of "an error occurs". */
120:     virtual int addProvidesPort(Port *inPort, PortInfo *name){};

122:       /** Notifies the framework that a previously exported Port is no longer 
123:           available for use. */
124:     virtual void removeProvidesPort(CONST char *name){};
125: };

127: }}}
128: #endif

130: #endif