// // File: LocalMMInterfaceCPP.h // 8/8/98, db created, DRAFT! // // This file defines the interface to local megamodules written // in C++. Local megamodules, often helper modules, are not // distributed, and there exists exactly one instance of each // local megamodule for each megaprogram. Therefore no clientID // is needed in the protocol. Local megamodules are called directly // by the megaprogram, are linked into the CSRT, and run in the // same thread as the CSRT. There is no distribution system between // the megaprogram and the local megamodule. // // enum ChaimsInvokStatus {NOT_DONE=0, DONE=1, ERROR=2}; #include "ChaimsAttrValList.h"; class virtual LocalMMInterfaceCPP { public: void SETUP (); // Prepare the megamodule for all the other calls. long INVOKE (char* methodName, ChaimsAttrValList * list); // IN methodName: name of the method to be invoked. // IN list: list of name-value pairs (invocation-specific // parameters for this invocation. // OUT long: callID by which this invocation can be referenced // later on until it gets terminated public ChaimsInvokStatus EXAMINE(long callID); // IN callID: reference of the invocation to be investigated // OUT ChaimsInvokStatus: status of this invocation void ESTIMATE(String methodName, ChaimsAttrValList * list) ; // IN methodName: name of the method for which an estimate is // asked for // IN, OUT list: list of name-value pairs containing the // characteristics asked for.Valid names so far are // "time", "fee" and "datavolume". For complete list of // parameters of ESTIMATE and for their units and default-values // see overview of protocols. void GETPARAM(ChaimsAttrValList * list); // IN, OUT list: list of name-value pairs. For input the values // are empty, and the names contain the names of // parameters and global variables available in this // megamodule (for valid names see repository). For // output, the values then contain the current settings // for the calling megaprogram. If no settings // have been made yet, default values are returned. void EXTRACT(long callID, ChaimsAttrValList * list); // IN callID: invocation from which we want the results // IN, OUT list: list of name-value pairs. For input, the values // are empty and the names tell the megamodule which // results are requested. For output, the values are then // filled with the appropriate results. If the invocation // has not yet been done, the values may contain garbage. void SETPARAM(ChaimsAttrValList * list); // IN list: list of name-value pairs containing the parameters of // global variables that should be preset. // This specification overrides general // default-settings and will be used by INVOKE's whenever // no invocation specific values are given. void TERMINATE(long callID) ; // IN callID: reference of invocation that is no longer needed. void TERMINATEALL (); // All invocations can be aborted. The megamodule can no longer be // accessed unless a new SETUP call is issued. } /* the following header file is copied here in order to help understanding above interface .. not yet up-to-date!!! class ChaimsAttrValList { //ChaimsAttrValList is a list of AttrValPair. private: AttrValPair * startlist; AttrValPair * lastelement; //Also, the member next of the last //element has always to be NULL AttrValPair * current; int lengthlist; public: ChaimsAttrValList(); ~ChaimsAttrValList(); int getLength ( ); addPair(AttrValPair *newpair); addPair( char * name, char * blob, int valuelength) ; AttrValPair* getFirst(); AttrValPair* getNext() ; //Returns the element coming next after //last one being read either with getFirst or getNext. //If we are the end of the list, it returns the last element, //even if that one has been read already. int testEnd(); //yields true, when all elements have been read // or when the list does not contain any elements at all } class AttrValPair { //AttrValPair contains a pointer to a name and a pointer to a blob. //No deep copy for name and blob. private: char* name; //name of the parameter as specified in repository ASN1OCTET* blob; //blob, which contains an encoded Gentype. //ASN1OCTET is an unsigned char. int bloblength; //length of the blob (number of bytes), because //blob is not necessarily 0-terminated next * AttrValPair; // pointer to the following pair friend class ChaimsAttrValList; public: AttrValPair(char* name, ASN1OCTET* blob, int bloblength); AttrValPair(char* name, char* blob, int bloblength) ; AttrValPair(char* name) ; //to be used when no or empty blob ~AttrValPair(); //Should the destructor deallocate memory or not? //As AttrValPair only points to some sequences of chars or //bytes, we cannot know if somebody still uses it. In most //cases they will be in use. //Having a deep copy instead of shallow copy in the //constructor? void setName(char* newname) ; void setValue(ASN1OCTET* newblob, int bloblength) ; //Should we first test if current blob is empty and otherwise //free the memory? Probably not... char* getName() ; int getValue(ASN1OCTET** value) ; //returns a pointer to the blob (encoded Gentype) in value //returns the length of the blob int getValueLength() ; int setValue(ASN1C_GenType * ptrgentype); //Takes as argument a pointer to a C++-gentype. //The gentype gets encoded into a blob and stored in the value. //returnvalue: 1: everything okay // 0: encoding went wrong (no valid gentype) //setBlob does not delete the gentype pointed to by prtgentype, //this has to be done by the user of setBlob. int getValueAsGentype(ASN1C_GenType **ptrgentype) ; // allocates a gentype, converts the blob to a gentype and // returns in ptrgentype a pointer to this gentype, // returns 1 if conversion went all right, otherwise 0 } */