Class: |
DimInfo |
Library: |
DIM |
|
Author: |
C. Gaspar |
|
Version: |
v1.0 |
Update :Thu Feb 11 15:52:46
1999 |
Descrition :
To be used by DIM clients - implements DIM service
subscription and reception
DimInfo constructors subscribe to DIM services.
DimInfo Services can be requested to be updated
when the contents change and/or at regular time intervals.
The services are received at startup, when the server updates
them or after a timeout limit if the parameter "time" is specified.
This gives the following possibilities:
- Receive the service at startup and then
- Receive the service only
when the server updates it
- no "time" parameter
- Receive the service
at regular time intervals (if the server doesn't update it) or
- Receive the service
at regular intervals and also when the server updates it
- some "time" parameter
- Receive the service
when the server updates it, but also after a timeout (to make sure the
server is alive)
- longish "time" parameter
Note: The parameter "time" is sent to the server.
It is the server that updates the services even on the time basis
Please refer to Usage for
examples.
Constructors :
Constructors for Services updated only by the
server
-
public DimInfo ( char * name, int nolink)
; Integer Service
-
public DimInfo ( char * name, float
nolink) ; Float Service
-
public DimInfo ( char * name, double
nolink) ; Double Service
-
public DimInfo ( char * name, short nolink) ;
Short Service
-
public DimInfo ( char * name, longlong nolink) ;
Longlong (64 bit) Service
-
public DimInfo ( char * name, char *
nolink) ; Character String Service
-
public DimInfo ( char * name, void *
nolink, int nolinksize) ; Structure (mix types) Service
Constructors for Services updated (also) on a time
basis
-
public DimInfo ( char * name, int time,
int nolink) ; Integer Service
-
public DimInfo ( char * name, int time,
float nolink) ; Float Service
-
public DimInfo ( char * name, int time,
double nolink) ; Double Service
-
public DimInfo ( char * name, int time, short nolink) ;
Short Service
-
public DimInfo ( char * name, int time, longlong nolink) ;
Longlong (64 bit) Service
-
public DimInfo ( char * name, int time,
char * nolink) ; Character String Service
-
public DimInfo ( char * name, int time,
void * nolink, int nolinksize) ; Structure (mix types) Service
Constructors for Services with
a Handler for multiple Services (without time)
-
public DimInfo ( char * name, int nolink,
DimInfoHandler * handler) ; Integer Service
-
public DimInfo ( char * name, float
nolink, DimInfoHandler * handler) ; Float Service
-
public DimInfo ( char * name, double
nolink, DimInfoHandler * handler) ; Double Service
-
public DimInfo ( char * name, short nolink, DimInfoHandler
* handler) ; Short Service
-
public DimInfo ( char * name, longlong nolink, DimInfoHandler
* handler) ; Longlong (64 bit) Service
-
public DimInfo ( char * name, char *
nolink, DimInfoHandler * handler) ; Character String Service
-
public DimInfo ( char * name, void *
nolink, int nolinksize, DimInfoHandler * handler) ; Structure (mix
types) Service
Constructors for Services with
a Handler for multiple Services (with time)
-
public DimInfo ( char * name, int time,
int nolink, DimInfoHandler * handler) ; Integer Service
-
public DimInfo ( char * name, int time,
float nolink, DimInfoHandler * handler) ; Float Service
-
public DimInfo ( char * name, int time,
double nolink, DimInfoHandler * handler) ; Double Service
-
public DimInfo ( char * name, int time, short nolink, DimInfoHandler
* handler) ; Short Service
-
public DimInfo ( char * name, int time, longlong nolink, DimInfoHandler
* handler) ; Longlong (64 bit) Service
-
public DimInfo ( char * name, int time,
char * nolink, DimInfoHandler * handler) ; Character String Service
-
public DimInfo ( char * name, int time,
void * nolink, int nolinksize, DimInfoHandler * handler) ; Structure
(mix types) Service
Destructors :
-
public ~ DimInfo ( ) ; Dim Service Destructor
Public Functions :
-
char* getName ( ) ; Get the Service Name
-
void* getData ( ) ; Get the Service Contents
-
int getInt ( ) ; Get Integer Service
Contents
-
float getFloat ( ) ; Get Float Service
Contents
-
double getDouble ( ) ; Get Double Service
Contents
-
short getShort ( ) ; get Short Service
Contents
-
longlong getLonglong ( ) ; get Longlong (64 bit) Service
Contents
-
char* getString ( ) ; Get String Service
Contents
-
int getSize ( ) ; Get the Service Size.
-
virtual void infoHandler
( ) ; To be overloaded if Handler specified
Usage :
DIM Client Services (DimInfo) can be used in several
ways:
- The user variable is of type DimInfo
Example
: The Service is received when the Server
updates it
main()
{
DimInfo runNumber("DELPHI/RUN_NUMBER",
-1);
while(1)
{
...
cout << runNumber.getInt() << endl;
}
}
Example : The Service is
received when the Server updates
it and every 30 seconds otherwise
main()
{
DimInfo runNumber("DELPHI/RUN_NUMBER",
30, -1);
while(1)
{
...
cout << runNumber.getInt() << endl;
}
}
Example
: The Service is received at regular intervals of 5 seconds (the
Server does not explicitly update it)
main()
{
DimInfo triggerRate("DELPHI/TRIGGER_RATE",
5, -1.0);
while(1)
{
...
cout << triggerRate.getFloat() << endl;
}
}
- Inheritance: The user class inherits from DimInfo
Example:
class RunNumber: public DimInfo
{
public:
// subscribe to service
with handler
RunNumber(): DimInfo("DELPHI/RUN_NUMBER",
-1) {}
void infoHandler( ) {cout
<< getInt() << endl;} // update handler
};
- A class subscribes
to many DimServices with only one handler
Example:
class RumVars : public DimClient // inheritance necessary because
a handler is to be used
{
DimInfo runNumber;
DimInfo runType;
public:
RunVars:
runNumber("DELPHI/RUN_NUMBER", -1, this), // subscribe with handler
runType("DELPHI/RUN_TYPE", "not available", this), // subscribe with handler
{}
void infoHandler( ) {
DimInfo *curr = getInfo() // get current DimInfo address
if(curr == &runNumber) { int run = curr->getInt( ) };
else { char *type = curr->getString( ) };
//etc.
}
};
Last update : 02/11/99 15:53:02 by MkHelp
1.1.0