cdev-1.7.2n
This commit is contained in:
@@ -0,0 +1,235 @@
|
||||
#ifndef _VAR_STRING_HASH_H_
|
||||
#define _VAR_STRING_HASH_H_ 1
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
class StringHashNode
|
||||
{
|
||||
friend class StringHash;
|
||||
friend class StringHashIterator;
|
||||
|
||||
private:
|
||||
int copyKeyFlag;
|
||||
char * hashString;
|
||||
void * hashData;
|
||||
StringHashNode * next;
|
||||
|
||||
StringHashNode ( char * HashString, void * HashData, int copyKey=1);
|
||||
~StringHashNode ( void );
|
||||
};
|
||||
|
||||
|
||||
class StringHash
|
||||
{
|
||||
friend class StringHashIterator;
|
||||
|
||||
private:
|
||||
int tableSize;
|
||||
int copyKeyFlag;
|
||||
StringHashNode ** nodes;
|
||||
|
||||
public:
|
||||
StringHash (int copyKey = 1, int TableSize = 255 );
|
||||
~StringHash ( void );
|
||||
|
||||
inline unsigned int stringHash ( char * hashString );
|
||||
|
||||
inline void insert ( char * hashString, void * hashData );
|
||||
inline void remove ( char * hashString );
|
||||
inline void * find ( char * hashString );
|
||||
};
|
||||
|
||||
|
||||
class StringHashIterator
|
||||
{
|
||||
private:
|
||||
StringHash * hashTbl;
|
||||
StringHashNode * node;
|
||||
int idx;
|
||||
|
||||
public:
|
||||
StringHashIterator( StringHash * HashTbl );
|
||||
~StringHashIterator( void );
|
||||
|
||||
inline void * first ( void );
|
||||
inline void * operator ++ ( void );
|
||||
inline void * operator ++ ( int x );
|
||||
inline char * key ( void );
|
||||
inline void * data ( void );
|
||||
};
|
||||
|
||||
|
||||
inline StringHashNode::StringHashNode ( char * HashString, void * HashData, int copyKey )
|
||||
: next(NULL), copyKeyFlag(copyKey)
|
||||
{
|
||||
if(copyKeyFlag) hashString = strdup(HashString);
|
||||
else hashString = HashString;
|
||||
hashData = HashData;
|
||||
}
|
||||
|
||||
|
||||
inline StringHashNode::~StringHashNode ( void )
|
||||
{
|
||||
if(copyKeyFlag) delete hashString;
|
||||
}
|
||||
|
||||
|
||||
inline StringHash::StringHash ( int copyKey, int TableSize )
|
||||
: copyKeyFlag(copyKey), tableSize (TableSize)
|
||||
{
|
||||
nodes = new StringHashNode * [tableSize];
|
||||
memset(nodes, 0, sizeof(StringHashNode *) * tableSize );
|
||||
}
|
||||
|
||||
|
||||
inline StringHash::~StringHash ( void )
|
||||
{
|
||||
for(int i=0; i<tableSize; i++)
|
||||
{
|
||||
while(nodes[i]!=NULL)
|
||||
{
|
||||
StringHashNode * node = nodes[i];
|
||||
nodes[i] = node->next;
|
||||
delete node;
|
||||
}
|
||||
}
|
||||
delete nodes;
|
||||
}
|
||||
|
||||
inline unsigned int StringHash::stringHash ( char * hashString )
|
||||
{
|
||||
unsigned int hash = 0, g;
|
||||
|
||||
for (int i = 0; hashString[i] != '\0'; i++)
|
||||
{
|
||||
hash = (hash << 4) + hashString[i];
|
||||
if (g = hash & 0xf0000000)
|
||||
{
|
||||
hash ^= g >> 24;
|
||||
hash ^= g;
|
||||
}
|
||||
}
|
||||
return (hash % tableSize);
|
||||
}
|
||||
|
||||
inline void StringHash::insert (char * hashString, void * hashData )
|
||||
{
|
||||
unsigned int idx = stringHash(hashString);
|
||||
StringHashNode * prev = NULL, * node = nodes[idx];
|
||||
StringHashNode * newNode = new StringHashNode(hashString, hashData, copyKeyFlag);
|
||||
|
||||
while(node!=NULL && strcmp(node->hashString, hashString))
|
||||
{
|
||||
prev = node;
|
||||
node = prev->next;
|
||||
}
|
||||
if(node!=NULL)
|
||||
{
|
||||
newNode->next = node->next;
|
||||
delete node;
|
||||
}
|
||||
if(prev!=NULL) prev->next = newNode;
|
||||
else nodes[idx] = newNode;
|
||||
}
|
||||
|
||||
inline void StringHash::remove ( char * hashString )
|
||||
{
|
||||
unsigned int idx = stringHash(hashString);
|
||||
StringHashNode * prev = NULL, * node = nodes[idx];
|
||||
while(node!=NULL && strcmp(node->hashString, hashString))
|
||||
{
|
||||
prev = node;
|
||||
node = prev->next;
|
||||
}
|
||||
if(node!=NULL)
|
||||
{
|
||||
if(prev!=NULL) prev->next = node->next;
|
||||
else nodes[idx] = node->next;
|
||||
delete node;
|
||||
}
|
||||
}
|
||||
|
||||
inline void * StringHash::find ( char * hashString )
|
||||
{
|
||||
unsigned int idx = stringHash(hashString);
|
||||
StringHashNode * prev = NULL, * node = nodes[idx];
|
||||
while(node!=NULL && strcmp(node->hashString, hashString))
|
||||
{
|
||||
prev = node;
|
||||
node = prev->next;
|
||||
}
|
||||
return node!=NULL?node->hashData:NULL;
|
||||
}
|
||||
|
||||
|
||||
inline StringHashIterator::StringHashIterator(StringHash * HashTbl)
|
||||
: hashTbl(HashTbl), idx(0), node(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
inline StringHashIterator::~StringHashIterator( void )
|
||||
{
|
||||
}
|
||||
|
||||
inline void * StringHashIterator::first ( void )
|
||||
{
|
||||
if(hashTbl!=NULL)
|
||||
{
|
||||
for(idx = 0; idx<hashTbl->tableSize &&
|
||||
(node = hashTbl->nodes[idx])==NULL; idx++);
|
||||
}
|
||||
else node = NULL;
|
||||
return (node!=NULL)?node->hashData:NULL;
|
||||
}
|
||||
|
||||
inline void * StringHashIterator::operator ++ ( void )
|
||||
{
|
||||
if(hashTbl!=NULL)
|
||||
{
|
||||
if(node==NULL) first();
|
||||
else if(node->next!=NULL) node = node->next;
|
||||
else
|
||||
{
|
||||
node = NULL;
|
||||
do {
|
||||
idx++;
|
||||
} while(idx<hashTbl->tableSize &&
|
||||
(node = hashTbl->nodes[idx])==NULL);
|
||||
}
|
||||
}
|
||||
else node = NULL;
|
||||
return (node!=NULL)?node->hashData:NULL;
|
||||
}
|
||||
|
||||
inline void * StringHashIterator::operator ++ ( int x )
|
||||
{
|
||||
if(hashTbl!=NULL && x==0)
|
||||
{
|
||||
if(node==NULL) first();
|
||||
else if(node->next!=NULL) node = node->next;
|
||||
else
|
||||
{
|
||||
node = NULL;
|
||||
do {
|
||||
idx++;
|
||||
} while(idx<hashTbl->tableSize &&
|
||||
(node = hashTbl->nodes[idx])==NULL);
|
||||
}
|
||||
}
|
||||
else node = NULL;
|
||||
return (node!=NULL)?node->hashData:NULL;
|
||||
}
|
||||
|
||||
inline char * StringHashIterator::key ( void )
|
||||
{
|
||||
return (node!=NULL)?node->hashString:(char *)NULL;
|
||||
}
|
||||
|
||||
inline void * StringHashIterator::data ( void )
|
||||
{
|
||||
return (node!=NULL)?node->hashData:NULL;
|
||||
}
|
||||
|
||||
#endif /* _VAR_STRING_HASH_H_ */
|
||||
+393
@@ -0,0 +1,393 @@
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*
|
||||
* Description:
|
||||
* C public interface for CDEV
|
||||
*
|
||||
* Authors: Danjin Wu & Jie Chen
|
||||
*
|
||||
* Revision History:
|
||||
* cdev.h,v
|
||||
* Revision 1.3 1997/08/27 18:24:18 chen
|
||||
* include cdevVersion.h
|
||||
*
|
||||
* Revision 1.2 1996/03/22 17:56:51 chen
|
||||
* add cdevFdChangedCallback
|
||||
*
|
||||
* Revision 1.1 1995/12/14 19:09:16 chen
|
||||
* cdev C interface for C programs
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef _CDEV_CBINDING_H
|
||||
#define _CDEV_CBINDING_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cdevVersion.h>
|
||||
#include <cdevErrCode.h>
|
||||
#include <cdevSpec.h>
|
||||
|
||||
typedef long cdev_data_t;
|
||||
typedef long cdev_request_t;
|
||||
typedef long cdev_system_t;
|
||||
typedef long cdev_group_t;
|
||||
|
||||
/*************************************************************************
|
||||
* User error reporting function *
|
||||
*************************************************************************/
|
||||
typedef void (*cdevErrHandler) (int severity,
|
||||
char* text,
|
||||
cdev_request_t req);
|
||||
|
||||
/*************************************************************************
|
||||
* User fd changed callback function *
|
||||
*************************************************************************/
|
||||
typedef void (*cdevFdChangedCallback) (int fd,
|
||||
int opened,
|
||||
void* arg);
|
||||
|
||||
/**************************************************************************
|
||||
* User callback function *
|
||||
*************************************************************************/
|
||||
typedef void (*cdevCbkFunc) (int status,
|
||||
void* userarg,
|
||||
cdev_request_t req,
|
||||
cdev_data_t data);
|
||||
|
||||
typedef struct _cbk_t_
|
||||
{
|
||||
cdevCbkFunc func;
|
||||
void* arg;
|
||||
/* the following element is not for public use */
|
||||
void* cxxpart;
|
||||
}cdev_cbk, *cdev_cbk_t;
|
||||
|
||||
/**************************************************************************
|
||||
* HPUX C call C++ convention *
|
||||
* User must call this before any other routines to *
|
||||
* Initialize all static objects *
|
||||
**************************************************************************/
|
||||
#ifdef __hpux
|
||||
#define CDEV_INIT() (_main () )
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
* CDEV supported data types inside cdev_data_t *
|
||||
**************************************************************************/
|
||||
#define CDEV_BYTE_ 0 /* unsigned character */
|
||||
#define CDEV_INT_16 1 /* 16 bits integer */
|
||||
#define CDEV_UINT_16 2 /* unsigned 16 bits integer */
|
||||
#define CDEV_INT_32 3 /* 32 bits integer */
|
||||
#define CDEV_UINT_32 4 /* unsigned 32 bits integer */
|
||||
#define CDEV_FLT 5 /* float */
|
||||
#define CDEV_DBL 6 /* double */
|
||||
#define CDEV_STR 7 /* character string */
|
||||
#define CDEV_TS 8 /* structured time stamp with sec and nsec */
|
||||
#define CDEV_INVALID_TYPE 9 /* not belongs to any type above */
|
||||
|
||||
#define CDEV_IMMEDIATE 0 /* cdev group exection immediately */
|
||||
#define CDEV_DEFERRED 1 /* cdev group exection deferred */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
* C interface for cdev_data_t *
|
||||
*************************************************************************/
|
||||
|
||||
/* create and allocate for cdev_data_t */
|
||||
extern CDEVAPI int cdevDataAllocate (cdev_data_t *id);
|
||||
|
||||
/* free memory associated with cdev_data_t */
|
||||
extern CDEVAPI void cdevDataFree (cdev_data_t id);
|
||||
|
||||
/* convert a character string tag to an integer tag */
|
||||
extern CDEVAPI int cdevDataTagC2I (char *tag, int *tagid);
|
||||
|
||||
/* convert an integer tag to a character string tag. */
|
||||
/* the return tag is a pointer to internal char string. */
|
||||
/* do not free the tag !!! */
|
||||
extern CDEVAPI int cdevDataTagI2C (int tagid, char **tag);
|
||||
|
||||
/* insert an new tag to cdev_data_t data */
|
||||
extern CDEVAPI void cdevDataInsertTag (int tagid, char *tag);
|
||||
|
||||
/* insert a new data with data type 'type' pointed by data */
|
||||
extern CDEVAPI int cdevDataInsert (cdev_data_t id, int tagid,
|
||||
int type, void *data);
|
||||
|
||||
/* insert an array of data into cdev_data_t */
|
||||
extern CDEVAPI int cdevDataInsertArray (cdev_data_t id, int tagid,
|
||||
int type, void *data,
|
||||
size_t len, size_t ndim);
|
||||
|
||||
/* retrieve data with tag 'tagid' to memory pointed by 'data' */
|
||||
extern CDEVAPI int cdevDataGet (cdev_data_t id, int tagid,
|
||||
int type, void *data);
|
||||
|
||||
/* return the memory address of data with tag 'tagid' */
|
||||
extern CDEVAPI int cdevDataFind (cdev_data_t id, int tagid, void **data);
|
||||
|
||||
/* return data type associated with tag 'tagid' */
|
||||
extern CDEVAPI int cdevDataGetType (cdev_data_t id, int tagid, int *type);
|
||||
|
||||
/* return dimention information with tag 'tagid' */
|
||||
extern CDEVAPI int cdevDataGetDim (cdev_data_t id, int tagid, size_t *dim);
|
||||
|
||||
/* get number of elements associated with tag 'tagid' */
|
||||
extern CDEVAPI int cdevDataGetElems (cdev_data_t id, int tagid, size_t *elems);
|
||||
|
||||
/* get information about where to start/end inside the multiple */
|
||||
/* dimentional array of data for this tag 'tagid' */
|
||||
extern CDEVAPI int cdevDataGetBounds (cdev_data_t id, int tagid,
|
||||
size_t *bounds, size_t bsize);
|
||||
|
||||
/* set information about where to start/end inside the multiple */
|
||||
/* dimentional array of data for this tag 'tagid' */
|
||||
extern CDEVAPI int cdevDataSetBounds (cdev_data_t id, int tagid,
|
||||
size_t *bounds, size_t bsize);
|
||||
|
||||
/* remove all data inside cdev_data_t 'id' */
|
||||
extern CDEVAPI void cdevDataRemoveAll (cdev_data_t id);
|
||||
|
||||
/* remove a single data item from a cdev_data_t with tag 'tagid' */
|
||||
extern CDEVAPI void cdevDataRemove (cdev_data_t id, int tagid);
|
||||
|
||||
/* change tag associated with a data item from 'tagid' to 'newtagid' */
|
||||
extern CDEVAPI int cdevDataChangeTag (cdev_data_t id, int tagid, int newtagid);
|
||||
|
||||
/* print out ASCII representation of all internal data of 'id' */
|
||||
#ifdef _WIN32
|
||||
extern CDEVAPI void cdevDataAsciiDump (cdev_data_t id);
|
||||
#else
|
||||
extern CDEVAPI void cdevDataAsciiDump (cdev_data_t id, FILE *fp);
|
||||
#endif
|
||||
|
||||
/* copy cdev_data_t from 'from' to 'to' */
|
||||
extern CDEVAPI void cdevDataCopy (cdev_data_t from, cdev_data_t *to);
|
||||
|
||||
/*************************************************************************
|
||||
* C interface for setting up user callback routines *
|
||||
************************************************************************/
|
||||
|
||||
/* create cdev_cbk_t structure with 'func' and 'arg' */
|
||||
extern CDEVAPI int cdevCbkAllocate (cdevCbkFunc func, void* arg, cdev_cbk_t* id);
|
||||
|
||||
/* destroy/free cdev_cbk_t structure pointed by id */
|
||||
extern CDEVAPI void cdevCbkFree (cdev_cbk_t id);
|
||||
|
||||
/************************************************************************
|
||||
* C interface for cdev global system *
|
||||
***********************************************************************/
|
||||
|
||||
/* get a handle on the default system, do not use it now :-) */
|
||||
extern CDEVAPI int cdevDefaultSystem (cdev_system_t* sys);
|
||||
|
||||
/* return all file descriptors inside the cdev. caller provide */
|
||||
/* buffer for fds and intial value of numFds should be the buffer */
|
||||
/* size. e.g. int fds[10], numFds = 10, cdevGetFds (fds, &numFds) */
|
||||
/* If success, numFds has real number of fd */
|
||||
extern CDEVAPI int cdevGetFds (int fds[], int* numFds);
|
||||
|
||||
/* add a callback function which will be called when file */
|
||||
/* descriptors monitored by the system closed/opend */
|
||||
/* Note: service dependent. Underlying cdevService must provide */
|
||||
/* some mechanism to notify the system (see caService) */
|
||||
extern CDEVAPI int addFdChangedCallback (cdevFdChangedCallback cbk, void* arg);
|
||||
|
||||
/* flush out all network requests */
|
||||
extern CDEVAPI int cdevFlush (void);
|
||||
|
||||
/* wait for network requests to come back for upto 'seconds' */
|
||||
/* long. If seconds = 0.0, wait forever */
|
||||
extern CDEVAPI int cdevPend (double seconds);
|
||||
|
||||
/* poll the network to see whether there are outstanding I/O */
|
||||
/* events on all communication channels. */
|
||||
extern CDEVAPI int cdevPoll (void);
|
||||
|
||||
/* turn automatic error reporting mechanism on: system error */
|
||||
/* reporting function will be in charge */
|
||||
extern CDEVAPI int cdevAutoErrorOn (void);
|
||||
|
||||
/* turn automatic error reporting mechanism off: user error */
|
||||
/* reporting function will be in charge (if there is one) */
|
||||
extern CDEVAPI int cdevAutoErrorOff (void);
|
||||
|
||||
/* set error reporting threshold. check cdev_error_code.h to see */
|
||||
/* all available threshold values. */
|
||||
extern CDEVAPI void cdevSetThreshold (int errorThreshold);
|
||||
|
||||
/* set your own error reporting function. If func = 0, default */
|
||||
/* system error reporting function will be used */
|
||||
extern CDEVAPI void cdevSetErrorHandler (cdevErrHandler func);
|
||||
|
||||
/* printf like error reporting interface */
|
||||
extern CDEVAPI int cdevReportError (int severity, char* name,
|
||||
cdev_request_t req, char* format, ...);
|
||||
|
||||
/**********************************************************************
|
||||
* cdev high level I/O operations *
|
||||
*********************************************************************/
|
||||
|
||||
/* synchronous send with device/msg pair + out/in data */
|
||||
extern CDEVAPI int cdevSend (char* device, char* msg,
|
||||
cdev_data_t out, cdev_data_t result);
|
||||
|
||||
/* asynchronous send with device/msg pair + out/in data */
|
||||
/* caller has to use synchronization mechanism to retrieve */
|
||||
/* result by cdevGroupPend or cdevPend methods */
|
||||
extern CDEVAPI int cdevSendNoBlock (char* device, char* msg,
|
||||
cdev_data_t out, cdev_data_t result);
|
||||
|
||||
/* asynchronous send with device/msg pair + out data and a */
|
||||
/* user provided callback. */
|
||||
/* caller has to use synchronization mechanism to retrieve */
|
||||
/* result by cdevGroupPend or cdevPend methods */
|
||||
extern CDEVAPI int cdevSendCallback (char* device, char* msg,
|
||||
cdev_data_t out, cdev_cbk_t cbk);
|
||||
|
||||
/* get context associcated with a device 'device' */
|
||||
extern CDEVAPI int cdevGetContext (char* device, cdev_data_t* data);
|
||||
|
||||
/* set context for the device 'device' */
|
||||
extern CDEVAPI int cdevSetContext (char* device, cdev_data_t data);
|
||||
|
||||
/* set private data for device 'device' */
|
||||
extern CDEVAPI int cdevSetPrivate (char* device, void* data);
|
||||
|
||||
/* get private data associated with this 'device' */
|
||||
extern CDEVAPI int cdevGetPrivate (char* device, void** data);
|
||||
|
||||
/*********************************************************************
|
||||
* Efficient cdev I/O handle routines *
|
||||
********************************************************************/
|
||||
|
||||
/* Create/Allocate cdev_request_t object */
|
||||
extern CDEVAPI int cdevRequestAllocate (char* device, char* msg,
|
||||
cdev_request_t* id);
|
||||
|
||||
/* Destroy/Free a cdev_request_t object */
|
||||
extern CDEVAPI void cdevRequestFree (cdev_request_t id);
|
||||
|
||||
/* synchronous send by a cdev_request_t object */
|
||||
extern CDEVAPI int cdevRequestSend (cdev_request_t id,
|
||||
cdev_data_t out,
|
||||
cdev_data_t result);
|
||||
|
||||
/* asynchronous send. user has use synchronization routines */
|
||||
/* such as cdevGroupPend or cdevPend etc to get result */
|
||||
extern CDEVAPI int cdevRequestSendNoBlock (cdev_request_t id,
|
||||
cdev_data_t out,
|
||||
cdev_data_t result);
|
||||
|
||||
/* asynchronous send with callback. user has use synchronization */
|
||||
/* routines such as cdevGroupPend or cdevPend etc to get result */
|
||||
extern CDEVAPI int cdevRequestSendCallback(cdev_request_t id,
|
||||
cdev_data_t out,
|
||||
cdev_cbk_t cbk);
|
||||
|
||||
/* get current communication state of cdev_request_t. e.g. */
|
||||
/* connected or disconnected */
|
||||
extern CDEVAPI int cdevRequestState (cdev_request_t id);
|
||||
|
||||
/* get access right of this cdev_request_t. e.g. readonly */
|
||||
extern CDEVAPI int cdevRequestAccess (cdev_request_t id);
|
||||
|
||||
/* get device name associated with this cdev_request_t. caller */
|
||||
/* has control of memory of 'device'. */
|
||||
/* e.g. char *device; cdevRequestDevice (id, &device); */
|
||||
/* free (device); */
|
||||
extern CDEVAPI int cdevRequestDevice (cdev_request_t id, char** device);
|
||||
|
||||
/* get message associated with this cdev_request_t. caller */
|
||||
/* has control of memory of 'msg'. */
|
||||
/* e.g. char *msg; cdevRequestMessage (id, &msg); */
|
||||
/* free (msg); */
|
||||
extern CDEVAPI int cdevRequestMessage (cdev_request_t id, char** msg);
|
||||
|
||||
/* get context associated with this request. caller has */
|
||||
/* control of memory of return 'cxt'. */
|
||||
/* e.g. cdev_data_t data; cdevRequestGetContext (id, &data); */
|
||||
/* cdevDataFree (data); */
|
||||
extern CDEVAPI int cdevRequestGetContext (cdev_request_t id, cdev_data_t* cxt);
|
||||
|
||||
/* set context for this I/O request */
|
||||
extern CDEVAPI int cdevRequestSetContext (cdev_request_t id, cdev_data_t cxt);
|
||||
|
||||
/* get private data associated with this request. returned */
|
||||
/* data is just a pointer */
|
||||
extern CDEVAPI int cdevRequestGetPrivate (cdev_request_t id, void** data);
|
||||
|
||||
/* set private data to this request */
|
||||
extern CDEVAPI int cdevRequestSetPrivate (cdev_request_t id, void* data);
|
||||
|
||||
/********************************************************************
|
||||
* cdev group routines useful for synchronization of multiple *
|
||||
* asynchronous I/O requests *
|
||||
*******************************************************************/
|
||||
|
||||
/* create/allocate a new cdev group */
|
||||
extern CDEVAPI int cdevGroupAllocate (cdev_group_t* id);
|
||||
|
||||
/* destroy/free a cdev group */
|
||||
extern CDEVAPI void cdevGroupFree (cdev_group_t id);
|
||||
|
||||
/* start a cdev group, all I/O requests will be registered */
|
||||
/* this group */
|
||||
extern CDEVAPI int cdevGroupStart (cdev_group_t id);
|
||||
|
||||
/* end a cdev group */
|
||||
extern CDEVAPI int cdevGroupEnd (cdev_group_t id);
|
||||
|
||||
/* poll the network to see whether there are outstanding */
|
||||
/* I/O events pending for this group */
|
||||
extern CDEVAPI int cdevGroupPoll (cdev_group_t id);
|
||||
|
||||
/* wait for all I/O requests upto 'seconds'. If seconds = 0.0 */
|
||||
/* wait until all I/O requests of this group have come back */
|
||||
extern CDEVAPI int cdevGroupPend (cdev_group_t id, double seconds);
|
||||
|
||||
/* flush all I/O requests */
|
||||
extern CDEVAPI int cdevGroupFlush (cdev_group_t id);
|
||||
|
||||
/* check whether all I/O requests inside this group have come */
|
||||
/* back. return 1: yes, return 0: no */
|
||||
extern CDEVAPI int cdevGroupAllFinished (cdev_group_t id);
|
||||
|
||||
/* check all I/O requests status inside the group. caller */
|
||||
/* provide large enough integer buffer and initial size of */
|
||||
/* buffer. It returns with real number of I/O requests and */
|
||||
/* status[i] = 0 stands for a finished I/O, status[i] = 1 */
|
||||
/* stands for a unfinished I/O. */
|
||||
/* e.g. int status[100], nstatus = 100; */
|
||||
/* cdevGroupStatus (id, status, &nstatus); */
|
||||
/* for (i = 0; i < nstatus; i++) */
|
||||
/* if (status[i] == 0) do something */
|
||||
extern CDEVAPI int cdevGroupStatus (cdev_group_t id,
|
||||
int status[], int* nstatus);
|
||||
|
||||
/* do not buffer I/O requests. send them out immediatly. */
|
||||
/* This is the default mode */
|
||||
extern CDEVAPI int cdevGroupExecImmediate (cdev_group_t id);
|
||||
|
||||
/* defer execution of all I/O requests inside the group until */
|
||||
/* cdevGroup flush is called */
|
||||
extern CDEVAPI int cdevGroupExecDeferred (cdev_group_t id);
|
||||
|
||||
/* return the execution mode of this group */
|
||||
extern CDEVAPI int cdevGroupExecutionMode (cdev_group_t id, int* mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,154 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevAccount classes: These classes provide the basic functionality
|
||||
// for CDEV accounting.
|
||||
//
|
||||
// Author: Walt Akers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _CDEV_ACCOUNT_H_
|
||||
#define _CDEV_ACCOUNT_H_ 1
|
||||
|
||||
#include <cdevSystem.h>
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevAccountRecord :
|
||||
// * The cdevAccountRecord class is used to store information about a single
|
||||
// * CDEV application. This class contains the mechanisms necessary to write
|
||||
// * this information to a disk file and then read entries back in sequentially
|
||||
// *****************************************************************************
|
||||
class cdevAccountRecord
|
||||
{
|
||||
public:
|
||||
enum {MAX_TEMP_BUF=4096};
|
||||
|
||||
cdevAccountRecord ( void );
|
||||
~cdevAccountRecord ( void );
|
||||
|
||||
void reset ( void );
|
||||
int streamIn ( FILE * fp );
|
||||
int streamIn ( int fd );
|
||||
char * streamIn ( char * ptr );
|
||||
int streamOut ( FILE * fp );
|
||||
int streamOut ( int fd );
|
||||
|
||||
void asciiDump ( FILE * fp = stdout );
|
||||
|
||||
cdevAccountRecord * getNext ( void );
|
||||
void setNext ( cdevAccountRecord * Next );
|
||||
|
||||
pid_t getProcessID ( void );
|
||||
void setProcessID ( pid_t ProcessID );
|
||||
char * getStartTime ( void );
|
||||
void setStartTime ( time_t StartTime );
|
||||
char * getAppName ( void );
|
||||
void setAppName ( char * AppName );
|
||||
char ** getArguments ( void );
|
||||
void setArguments ( char ** args, int nArgs);
|
||||
char * getUserName ( void );
|
||||
void setUserName ( char * UserName );
|
||||
char * getHostName ( void );
|
||||
void setHostName ( char * HostName );
|
||||
char * getSystemName ( void );
|
||||
void setSystemName ( char * OSName );
|
||||
char * getSystemRelease ( void );
|
||||
void setSystemRelease ( char * OSRelease );
|
||||
char * getCDEVVersion ( void );
|
||||
void setCDEVVersion ( char * CDEVVersion );
|
||||
char ** getServiceList ( void );
|
||||
void setServiceList ( char ** ServiceList, int nServices );
|
||||
void addService ( char * ServiceName );
|
||||
|
||||
protected:
|
||||
// *********************************************************************
|
||||
// * This is the pointer to the next cdevAccountRecord object that may
|
||||
// * be stored in a cdevAccountTable
|
||||
// *********************************************************************
|
||||
cdevAccountRecord * next;
|
||||
|
||||
// *********************************************************************
|
||||
// * This is a static buffer that will be used to perform reads
|
||||
// * whenever the size of the data to be read does not exceed the
|
||||
// * basic size.
|
||||
// *********************************************************************
|
||||
static char tempBuf[MAX_TEMP_BUF];
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the process ID of the running CDEV application.
|
||||
// *********************************************************************
|
||||
pid_t processID;
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the time that the application was started.
|
||||
// *********************************************************************
|
||||
char startTime [20];
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the name of the application and the arguments that were
|
||||
// * provided when it was started.
|
||||
// *********************************************************************
|
||||
char appName [256];
|
||||
int argCnt;
|
||||
char ** argList;
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the name of the user that started the application.
|
||||
// *********************************************************************
|
||||
char userName [128];
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the name of the host where the application was started
|
||||
// * and pertinent information about the operating system.
|
||||
// *********************************************************************
|
||||
char hostName [128];
|
||||
char osName [32];
|
||||
char osRelease [32];
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the version of CDEV that the application is using.
|
||||
// * Includes the suffix (SHARED) or (ARCHIVE).
|
||||
// *********************************************************************
|
||||
char cdevVersion[64];
|
||||
|
||||
// *********************************************************************
|
||||
// * These are the services that the application has loaded.
|
||||
// *********************************************************************
|
||||
int serviceCnt;
|
||||
int serviceMax;
|
||||
char ** serviceList;
|
||||
};
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevAccountEntry:
|
||||
// * This class is used to create a single instance of a cdevAccountRecord
|
||||
// * that will be associated with a CDEV application. This class instance
|
||||
// * will be called to write accounting information to the CDEV Accounting
|
||||
// * file whenever a significant event (start-up, service load, shutdown)
|
||||
// * occurs.
|
||||
// *****************************************************************************
|
||||
class cdevAccountEntry : public cdevAccountRecord
|
||||
{
|
||||
public:
|
||||
cdevAccountEntry ( char * OutputFile = NULL );
|
||||
~cdevAccountEntry ( void );
|
||||
int updateRecord ( void );
|
||||
int removeRecord ( void );
|
||||
void initialize ( void );
|
||||
void addService ( char * service );
|
||||
|
||||
private:
|
||||
char outputFile[256];
|
||||
};
|
||||
|
||||
extern cdevAccountEntry * cdevGlobalAccountEntry;
|
||||
|
||||
#endif /* _CDEV_ACCOUNT_H_ */
|
||||
@@ -0,0 +1,117 @@
|
||||
#ifndef _CDEV_ALIAS_DEFINITION_H_
|
||||
#define _CDEV_ALIAS_DEFINITION_H_
|
||||
|
||||
#ifndef _CDEV_DIRECTORY_TABLE_H_
|
||||
#error "You must include cdevDirectoryTable.h to load cdevAliasDefinition.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevAliasDefinition :
|
||||
// * This class stores the name of an alias and a reference to the device
|
||||
// * definition that it is associated with.
|
||||
// *
|
||||
// * This class maintains a variety of internal data items for the following
|
||||
// * purposes...
|
||||
// *
|
||||
// * alias - This is the name of the alias.
|
||||
// * device - This is the cdevDeviceDefinition for the device that it
|
||||
// * references.
|
||||
// * next - This is the next alias in the list.
|
||||
// *****************************************************************************
|
||||
class cdevAliasDefinition
|
||||
{
|
||||
private:
|
||||
char * name;
|
||||
cdevDeviceDefinition & device;
|
||||
cdevAliasDefinition * next;
|
||||
|
||||
public:
|
||||
inline cdevAliasDefinition ( char * Name, cdevDeviceDefinition & Device );
|
||||
inline ~cdevAliasDefinition ( void );
|
||||
inline void asciiDump ( FILE * fp = stdout );
|
||||
|
||||
// *********************************************************************
|
||||
// * Member access methods.
|
||||
// *********************************************************************
|
||||
inline char * getName ( void );
|
||||
inline cdevDeviceDefinition & getDevice ( void );
|
||||
inline cdevAliasDefinition * getNext ( void );
|
||||
inline void setNext ( cdevAliasDefinition * Next );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevAliasDefinition::cdevAliasDefinition :
|
||||
// * This is the constructor for the cdevAliasDefinition class. The Name
|
||||
// * pointer becomes the property of the class and should not be accessed
|
||||
// * by the caller after it has been provided to this constructor.
|
||||
// *****************************************************************************
|
||||
inline cdevAliasDefinition::cdevAliasDefinition
|
||||
( char * Name, cdevDeviceDefinition & Device )
|
||||
: name(Name), device(Device), next(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevAliasDefinition::~cdevAliasDefinition :
|
||||
// * This is the destructor faor the cdevAliasDefinition class.
|
||||
// *****************************************************************************
|
||||
inline cdevAliasDefinition::~cdevAliasDefinition ( void )
|
||||
{
|
||||
delete name;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevAliasDefinition::~cdevAliasDefinition :
|
||||
// * This is the destructor for the cdevAliasDefinition class.
|
||||
// *****************************************************************************
|
||||
inline void cdevAliasDefinition::asciiDump ( FILE * fp )
|
||||
{
|
||||
fprintf(fp, "alias %s %s\n", name, device.getName());
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevAliasDefinition::getName :
|
||||
// * This method allows the caller to obtain the name of the alias.
|
||||
// *****************************************************************************
|
||||
inline char * cdevAliasDefinition::getName ( void )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevAliasDefinition::getDevice :
|
||||
// * This method allows the caller to retrieve the device definition
|
||||
// * associated with the object.
|
||||
// *****************************************************************************
|
||||
inline cdevDeviceDefinition & cdevAliasDefinition::getDevice ( void )
|
||||
{
|
||||
return device;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevAliasDefinition::getNext :
|
||||
// * This method allows the caller to get the next alias in the list.
|
||||
// *****************************************************************************
|
||||
inline cdevAliasDefinition * cdevAliasDefinition::getNext ( void )
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevAliasDefinition::setNext :
|
||||
// * This method allows the caller to set the next alias in the list.
|
||||
// *****************************************************************************
|
||||
inline void cdevAliasDefinition::setNext ( cdevAliasDefinition * Next )
|
||||
{
|
||||
next = Next;
|
||||
}
|
||||
|
||||
|
||||
#endif /* _CDEV_ALIAS_DEFINITION_H_ */
|
||||
@@ -0,0 +1,169 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// Linked list of blocks of void pointer
|
||||
//
|
||||
// Not safe C++ practice because of void*.
|
||||
// Reason: It is very difficult to do instantiation inside
|
||||
// a shared library.
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevBlockList.h,v
|
||||
// Revision 1.1 1995/12/08 15:33:31 chen
|
||||
// linked block list
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:07 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_XOBJ_LIST_H
|
||||
#define _CDEV_XOBJ_LIST_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cdevSpec.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef void* blockListItem;
|
||||
|
||||
//===========================================================================
|
||||
// class tranObjBlockList
|
||||
// List of blocks each with size
|
||||
//===========================================================================
|
||||
const int DEFAULT_BLOCK_SIZE = 64;
|
||||
|
||||
class cdevBlockListIterator;
|
||||
|
||||
//===========================================================================
|
||||
// class cdevBlockLink
|
||||
// Node for the cdevBlockList class (private)
|
||||
//=============================================================================
|
||||
class CDEV_CLASS_SPEC cdevBlockLink
|
||||
{
|
||||
private:
|
||||
//constructors
|
||||
// create a single block with all unset value in it
|
||||
cdevBlockLink (cdevBlockLink * nextPtr, cdevBlockLink *prevPtr,
|
||||
unsigned int size = DEFAULT_BLOCK_SIZE);
|
||||
// create a single block with default value in it
|
||||
cdevBlockLink (cdevBlockLink * nextPtr, cdevBlockLink *prevPtr,
|
||||
const blockListItem& defVal,
|
||||
unsigned int size = DEFAULT_BLOCK_SIZE);
|
||||
// create a single block with some value in it
|
||||
cdevBlockLink (cdevBlockLink * nextPtr, cdevBlockLink *prevPtr,
|
||||
blockListItem *date,
|
||||
unsigned int size = DEFAULT_BLOCK_SIZE);
|
||||
// copy constructor, copy all lists
|
||||
cdevBlockLink (const cdevBlockLink& link);
|
||||
// assignment operator
|
||||
cdevBlockLink& operator = (const cdevBlockLink &link);
|
||||
// destructor
|
||||
virtual ~cdevBlockLink (void);
|
||||
|
||||
// operations
|
||||
// duplicate whole list
|
||||
cdevBlockLink* duplicate (void);
|
||||
// duplicate list starting here to the right
|
||||
cdevBlockLink* duplicate (int type); // type 0. goes to right, 1 left
|
||||
// insert a new block after
|
||||
cdevBlockLink* addNewBlock (void);
|
||||
cdevBlockLink* addNewBlock (const blockListItem & defValue);
|
||||
// free all memory associated with the list
|
||||
void freeAllMemory (void);
|
||||
|
||||
// data area
|
||||
blockListItem *value_;
|
||||
unsigned int blockSize_;
|
||||
// default value stored in the block
|
||||
// keep track how many slots are occupied
|
||||
cdevBlockLink *ptrToNextLink_;
|
||||
cdevBlockLink *ptrToPrevLink_;
|
||||
|
||||
// friends
|
||||
friend class cdevBlockList;
|
||||
friend class cdevBlockListIterator;
|
||||
};
|
||||
|
||||
class CDEV_CLASS_SPEC cdevBlockList
|
||||
{
|
||||
public:
|
||||
// constructors and destructor
|
||||
cdevBlockList (unsigned int blockSize = DEFAULT_BLOCK_SIZE);
|
||||
cdevBlockList (const blockListItem& defVal,
|
||||
unsigned int blockSize = DEFAULT_BLOCK_SIZE);
|
||||
cdevBlockList (const cdevBlockList &rsc);
|
||||
cdevBlockList& operator = (const cdevBlockList &rsc);
|
||||
virtual ~cdevBlockList (void);
|
||||
|
||||
// operations
|
||||
// access elements via subscript
|
||||
virtual blockListItem & operator [] (unsigned int ) const;
|
||||
// free all memory
|
||||
virtual void deleteAll (void);
|
||||
// just clean out value
|
||||
virtual void clearAll (void);
|
||||
virtual cdevBlockList * duplicate (void) const;
|
||||
virtual int includes (blockListItem value) const;
|
||||
virtual int length (void) const;
|
||||
|
||||
protected:
|
||||
// data filed
|
||||
cdevBlockLink firstBlock_;
|
||||
unsigned int blockSize_;
|
||||
unsigned int size_;
|
||||
blockListItem* defValue_;
|
||||
|
||||
private:
|
||||
// return how many steps a particular pointer away from
|
||||
// the beginning of the first block
|
||||
unsigned int entryNumber (blockListItem *ptr);
|
||||
cdevBlockLink* blockPointer (blockListItem *ptr);
|
||||
blockListItem* entryPointer (unsigned int steps);
|
||||
friend class cdevBlockListIterator;
|
||||
};
|
||||
|
||||
//=========================================================================
|
||||
// class cdevBlockListIterator
|
||||
// Iterator class used to loop over all list elements
|
||||
//=========================================================================
|
||||
class CDEV_CLASS_SPEC cdevBlockListIterator
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
cdevBlockListIterator (cdevBlockList &l);
|
||||
|
||||
// iterator protocol
|
||||
virtual int init (void);
|
||||
virtual blockListItem operator () ();
|
||||
virtual int operator !();
|
||||
// prefix
|
||||
virtual int operator ++();
|
||||
virtual void operator = (blockListItem newValue);
|
||||
|
||||
// new method for blockList
|
||||
int forcePut (blockListItem value);
|
||||
blockListItem * currentPosition();
|
||||
// prefix
|
||||
int operator --();
|
||||
// move cursor to the end of the list
|
||||
virtual int end (void);
|
||||
|
||||
protected:
|
||||
// data fields
|
||||
cdevBlockList &data;
|
||||
blockListItem* currEntry_;
|
||||
blockListItem* blockEnd_;
|
||||
blockListItem* blockStart_;
|
||||
blockListItem* listEnd_;
|
||||
unsigned int curPos_;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1991,1992 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// general cdev callback class
|
||||
//
|
||||
// Author: Jie Chen and Walt Akers
|
||||
//
|
||||
// Revision History:
|
||||
// cdevCallback.h,v
|
||||
// Revision 1.10 1998/01/29 15:20:05 akers
|
||||
// Ongoing development
|
||||
//
|
||||
// Revision 1.9 1997/07/16 18:38:41 akers
|
||||
// Testing for function_ in fireCallback
|
||||
//
|
||||
// Revision 1.8 1997/03/03 17:35:35 chen
|
||||
// add buffering to channel access connection
|
||||
//
|
||||
// Revision 1.7 1996/12/19 15:22:33 akers
|
||||
// Ongoing development
|
||||
//
|
||||
// Revision 1.6 1996/12/18 13:32:28 akers
|
||||
// Added support for incomplete transactions and fireCallback method
|
||||
//
|
||||
// Revision 1.4 1995/09/05 17:18:23 chen
|
||||
// add freelist and overload new/delete
|
||||
//
|
||||
// Revision 1.3 1995/07/05 19:28:50 chen
|
||||
// minor changes
|
||||
//
|
||||
// Revision 1.2 1995/07/05 18:36:39 chen
|
||||
// Allow inheritance
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:10 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_CALLBACK_H
|
||||
#define _CDEV_CALLBACK_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cdevSpec.h>
|
||||
|
||||
class cdevRequestObject;
|
||||
class cdevData;
|
||||
|
||||
typedef void(*cdevCallbackFunction) (int status,
|
||||
void *userarg,
|
||||
cdevRequestObject &obj,
|
||||
cdevData &result);
|
||||
|
||||
class CDEV_CLASS_SPEC cdevCallback
|
||||
{
|
||||
public:
|
||||
// constructor and destructor
|
||||
cdevCallback(void);
|
||||
cdevCallback(cdevCallbackFunction, void *userarg);
|
||||
cdevCallback(const cdevCallback &callback);
|
||||
cdevCallback &operator=(const cdevCallback &callback);
|
||||
virtual~cdevCallback(void);
|
||||
|
||||
virtual cdevCallbackFunction callbackFunction(void) const;
|
||||
// PURPOSE: return user callback function
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0 if there nothing
|
||||
|
||||
virtual void *userarg(void) const;
|
||||
// PURPUSE: return user arguments
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: a user argument pointer
|
||||
|
||||
int operator == (const cdevCallback &callback);
|
||||
int operator != (const cdevCallback &callback);
|
||||
// PURPOSE: if two cdevCallbacks have the same user function and user
|
||||
// arguments, == return true
|
||||
// REQUIRE: nothing
|
||||
// PROMISE:
|
||||
|
||||
void *operator new(size_t size);
|
||||
void operator delete(void *p, size_t size);
|
||||
// PURPOSE: overloaded new and delete operator.
|
||||
// REQUIRE: none
|
||||
// PROMISE:
|
||||
|
||||
// *********************************************************************
|
||||
// * The fireCallback method is allows the developer to execute the
|
||||
// * callback function that is specified in the cdevCallback object
|
||||
// * and set the incomplete_ flag to the appropriate value prior to
|
||||
// * execution, and then restore it to its default value before
|
||||
// * returning.
|
||||
// *
|
||||
// * The value provided in the "partial" parameter will be used to set
|
||||
// * the incomplete_ flag.
|
||||
// *********************************************************************
|
||||
void fireCallback ( int status,
|
||||
void * userarg,
|
||||
cdevRequestObject & req,
|
||||
cdevData & data,
|
||||
int partial)
|
||||
{
|
||||
if(function_!=NULL)
|
||||
{
|
||||
incomplete_ = partial;
|
||||
(*function_)(status, userarg, req, data);
|
||||
incomplete_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
// * The isTransactionDone method allows the caller to discover if the
|
||||
// * transaction that executed the callback method is finished or
|
||||
// * ongoing.
|
||||
// *********************************************************************
|
||||
static int isTransactionDone ( void ) { return !incomplete_; }
|
||||
|
||||
protected:
|
||||
// data area
|
||||
cdevCallbackFunction function_;
|
||||
void *userarg_;
|
||||
|
||||
private:
|
||||
// Free List for all cdevCallback
|
||||
// Reason: cdevCallback is a very small object (8 byte). Using free list
|
||||
// can speed up a program by an order of magnitude over the
|
||||
// default malloc-based memory allocation primitives. It can also
|
||||
// be less wasteful of memory, eliminating malloc's overheade of
|
||||
// four to eight bytes per allocation
|
||||
static cdevCallback *newlist;
|
||||
union
|
||||
{
|
||||
cdevCallback *freePtr;
|
||||
char *rep;
|
||||
};
|
||||
|
||||
// *********************************************************************
|
||||
// * The incomplete_ flag is used to indicate that the transaction that
|
||||
// * has called this callback method is or is not finished.
|
||||
// *
|
||||
// * The incomplete_ flag may have the following values...
|
||||
// * 0 - The transaction is finished
|
||||
// * 1 - The transaction is ongoing and more callbacks may be
|
||||
// * expected.
|
||||
// *********************************************************************
|
||||
static int incomplete_;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,697 @@
|
||||
#ifndef _CDEV_CLASS_DEFINITION_H_
|
||||
#define _CDEV_CLASS_DEFINITION_H_
|
||||
|
||||
#ifndef _CDEV_DIRECTORY_TABLE_H_
|
||||
#error "You must include cdevDirectoryTable.h to load cdevClassDefinition.h"
|
||||
#endif
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevClassDefinition :
|
||||
// * This class stores the definition of a single CDEV DDL class and all
|
||||
// * of its associated verbs, attributes and messages.
|
||||
// *
|
||||
// * This class maintains a variety of internal data items for the following
|
||||
// * purposes...
|
||||
// *
|
||||
// * directory - This is the cdevDirectoryTable that the class definition
|
||||
// * is a member of...
|
||||
// *
|
||||
// * name - This is the name of the class as defined in the CDEV DDL
|
||||
// * file.
|
||||
// *
|
||||
// * verbs - This is a list of cdevElementDefinitions that identify
|
||||
// * each verb that was defined within the class definition.
|
||||
// *
|
||||
// * attributes - This is a list of cdevElementDefinitions that identify
|
||||
// * each attribute that was defined within the class
|
||||
// * definition.
|
||||
// *
|
||||
// * messages - This is a list of cdevElementDefinitions that identify
|
||||
// * each messages that was defined within the class defintion.
|
||||
// *
|
||||
// * parent - This is the class definition for the class that this one
|
||||
// * inherited from - if any.
|
||||
// *
|
||||
// * deviceHead - This is a list of device definitions for all devices that
|
||||
// * deviceTail were created from this class.
|
||||
// *
|
||||
// * redirector - This is a table of all complete messages that this class
|
||||
// * will support. This table is only generated if devices are
|
||||
// * instanciated from the class - and it includes the message
|
||||
// * contents from all parent classes.
|
||||
// *
|
||||
// * next - This is the next class definition that occurs... This list
|
||||
// * is maintained in the cdevDirectoryTable object.
|
||||
// *****************************************************************************
|
||||
class cdevClassDefinition
|
||||
{
|
||||
private:
|
||||
cdevDirectoryTable & directory;
|
||||
cdevClassDefinition * next;
|
||||
char * name;
|
||||
cdevElementDefinition * verbs;
|
||||
cdevElementDefinition * attributes;
|
||||
cdevElementDefinition * messages;
|
||||
cdevClassDefinition * parent;
|
||||
cdevDeviceDefinition * deviceHead;
|
||||
cdevDeviceDefinition * deviceTail;
|
||||
StringHash redirector;
|
||||
|
||||
public:
|
||||
inline cdevClassDefinition(cdevDirectoryTable &Master,
|
||||
char *Name = NULL,
|
||||
cdevClassDefinition *Parent = NULL,
|
||||
cdevElementDefinition *Verbs = NULL,
|
||||
cdevElementDefinition *Attributes = NULL,
|
||||
cdevElementDefinition *Messages = NULL);
|
||||
inline ~cdevClassDefinition ( void );
|
||||
inline int addElement (cdevElementDefinition *&target,
|
||||
cdevElementDefinition * element );
|
||||
inline int addElement (cdevElementDefinition *& target,
|
||||
char * eleName,
|
||||
cdevServiceDefinition * service,
|
||||
char ** serviceData,
|
||||
int nItems);
|
||||
inline int addDevice (char * device, char * substName = NULL );
|
||||
inline int addVerb (char * eleName, cdevServiceDefinition *service, char ** serviceData, int nItems );
|
||||
inline int addVerb (cdevElementDefinition * element );
|
||||
inline int addAttribute (char * eleName, cdevServiceDefinition *service, char ** serviceData, int nItems );
|
||||
inline int addAttribute (cdevElementDefinition * element );
|
||||
inline int addMessage (char * eleName, cdevServiceDefinition *service, char ** serviceData, int nItems );
|
||||
inline int addMessage (cdevElementDefinition * element );
|
||||
inline int isA (char * className );
|
||||
inline void asciiDump (FILE * fp = stdout );
|
||||
inline void asciiDumpInstances ( FILE * fp = stdout );
|
||||
inline void asciiDumpRedirector ( FILE * fp = stdout );
|
||||
inline void createRedirectionTable ( void );
|
||||
|
||||
// *********************************************************************
|
||||
// * Member access functions:
|
||||
// *********************************************************************
|
||||
inline char * getName ( void );
|
||||
inline cdevDirectoryTable & getDirectory ( void );
|
||||
inline cdevClassDefinition * getParent ( void );
|
||||
inline cdevElementDefinition * getVerbs ( void );
|
||||
inline cdevElementDefinition * getAttributes ( void );
|
||||
inline cdevElementDefinition * getMessages ( void );
|
||||
inline cdevDeviceDefinition * getDevices ( void );
|
||||
inline StringHash & getRedirector ( void );
|
||||
inline int getElements ( cdevDirectoryTable::ElementType type,
|
||||
cdevElementDefinition ** &def,
|
||||
int &nItems );
|
||||
inline cdevClassDefinition * getNext ( void );
|
||||
inline void setNext ( cdevClassDefinition * Next );
|
||||
|
||||
};
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::cdevClassDefinition :
|
||||
// * This is the constructor for the class definition object. I
|
||||
// *****************************************************************************
|
||||
inline cdevClassDefinition::cdevClassDefinition
|
||||
( cdevDirectoryTable &Master,
|
||||
char *Name,
|
||||
cdevClassDefinition *Parent,
|
||||
cdevElementDefinition *Verbs,
|
||||
cdevElementDefinition *Attributes,
|
||||
cdevElementDefinition *Messages)
|
||||
: directory (Master),
|
||||
name (Name),
|
||||
parent (Parent),
|
||||
verbs (Verbs),
|
||||
attributes (Attributes),
|
||||
messages (Messages),
|
||||
deviceHead (NULL),
|
||||
deviceTail (NULL),
|
||||
next (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::~cdevClassDefinition :
|
||||
// * This is the descructor for the cdevClassDefinition object. It will
|
||||
// * delete the class name and each item from the elements list.
|
||||
// *****************************************************************************
|
||||
inline cdevClassDefinition::~cdevClassDefinition ( void )
|
||||
{
|
||||
cdevElementDefinition * ptr;
|
||||
cdevDeviceDefinition * dPtr;
|
||||
cdevRedirectorDefinition * rPtr;
|
||||
StringHashIterator iter(&redirector);
|
||||
|
||||
delete name;
|
||||
|
||||
while(verbs!=NULL)
|
||||
{
|
||||
ptr = verbs;
|
||||
verbs = verbs->getNext();
|
||||
delete ptr;
|
||||
}
|
||||
while(messages!=NULL)
|
||||
{
|
||||
ptr = messages;
|
||||
messages = messages->getNext();
|
||||
delete ptr;
|
||||
}
|
||||
while(attributes!=NULL)
|
||||
{
|
||||
ptr = attributes;
|
||||
attributes = attributes->getNext();
|
||||
delete ptr;
|
||||
}
|
||||
while(deviceHead!=NULL)
|
||||
{
|
||||
dPtr = deviceHead;
|
||||
deviceHead = deviceHead->getNext();
|
||||
directory.getDeviceHash().remove(dPtr->getName());
|
||||
delete dPtr;
|
||||
}
|
||||
for(iter.first(); (rPtr = (cdevRedirectorDefinition *)iter.data())!=NULL; )
|
||||
{
|
||||
iter++;
|
||||
redirector.remove(rPtr->getName());
|
||||
delete rPtr;
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addElement :
|
||||
// * This method is used to add an element (verb, attribute, or message) to
|
||||
// * the cdevClassDefinition. The target parameter is a reference to the
|
||||
// * list that will receive the incoming element.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addElement
|
||||
( cdevElementDefinition *&target,
|
||||
cdevElementDefinition * element )
|
||||
{
|
||||
cdevElementDefinition *curr, *prev;
|
||||
int result = CDEV_SUCCESS;
|
||||
|
||||
for(curr=target, prev=NULL;
|
||||
curr!=NULL && strcmp(curr->getName(), element->getName());
|
||||
curr=curr->getNext())
|
||||
{
|
||||
prev = curr;
|
||||
}
|
||||
if(curr == NULL)
|
||||
{
|
||||
if(prev) prev->setNext(new cdevElementDefinition(element));
|
||||
else target = new cdevElementDefinition(element);
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
return result;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addElement :
|
||||
// * This method will create a new element and add it to the list of elements
|
||||
// * that is reference by the target paremeter.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addElement
|
||||
(cdevElementDefinition *& target,
|
||||
char * eleName,
|
||||
cdevServiceDefinition * service,
|
||||
char ** serviceData,
|
||||
int nItems)
|
||||
{
|
||||
cdevElementDefinition *curr, *prev;
|
||||
int result = CDEV_SUCCESS;
|
||||
|
||||
for(curr=target, prev=NULL;
|
||||
curr!=NULL && strcmp(curr->getName(), eleName);
|
||||
curr=curr->getNext())
|
||||
{
|
||||
prev = curr;
|
||||
}
|
||||
if(curr == NULL)
|
||||
{
|
||||
if(prev) prev->setNext(new cdevElementDefinition(eleName, service, serviceData, nItems));
|
||||
else target = new cdevElementDefinition(eleName, service, serviceData, nItems);
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
return result;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addDevice :
|
||||
// * This method will add a new device to the device list. This device name
|
||||
// * will also be placed in the hashTable in the cdevDirectoryTable object
|
||||
// * specified by directory.
|
||||
// *
|
||||
// * Note the device name becomes the property of the cdevDeviceDefinition
|
||||
// * class and should not be deleted.
|
||||
// *
|
||||
// * The redirection table for this device will also be created as the
|
||||
// * first device is instanciated.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addDevice ( char * device, char * substName )
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
|
||||
if(device!=NULL && directory.getDeviceHash().find(device)==NULL)
|
||||
{
|
||||
cdevDeviceDefinition * def =
|
||||
new cdevDeviceDefinition(directory, device, substName, *this);
|
||||
|
||||
if(deviceTail==NULL)
|
||||
{
|
||||
deviceHead = def;
|
||||
deviceTail = def;
|
||||
createRedirectionTable();
|
||||
directory.addClassInstance(this);
|
||||
}
|
||||
else {
|
||||
deviceTail->setNext( def );
|
||||
deviceTail = def;
|
||||
}
|
||||
|
||||
directory.addDevice(def);
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addVerb :
|
||||
// * This method will add a verb to the verbs element definition list.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addVerb
|
||||
( char * eleName, cdevServiceDefinition *service, char ** serviceData, int nItems )
|
||||
{
|
||||
return addElement(verbs, eleName, service, serviceData, nItems);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addVerb :
|
||||
// * This method will add a verb to the verbs element definition list.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addVerb ( cdevElementDefinition * element )
|
||||
{
|
||||
return addElement(verbs, element);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addAttribute :
|
||||
// * This method will add an attribute to the attributes element
|
||||
// * definition list.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addAttribute
|
||||
( char * eleName, cdevServiceDefinition * service, char ** serviceData, int nItems )
|
||||
{
|
||||
return addElement(attributes, eleName, service, serviceData, nItems);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addAttribute :
|
||||
// * This method will add an attribute to the attributes element
|
||||
// * definition list.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addAttribute ( cdevElementDefinition * element )
|
||||
{
|
||||
return addElement(attributes, element);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addMessage :
|
||||
// * This method will add a message to the messages element definition list.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addMessage
|
||||
( char * eleName, cdevServiceDefinition * service, char ** serviceData, int nItems )
|
||||
{
|
||||
return addElement(messages, eleName, service, serviceData, nItems);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::addMessage :
|
||||
// * This method will add a message to the messages element definition list.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::addMessage ( cdevElementDefinition * element )
|
||||
{
|
||||
return addElement(messages, element);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::isA :
|
||||
// * This method will ascend the class hierarchy attempting to locate a
|
||||
// * class with the name specified in className. It will return TRUE if this
|
||||
// * class is or inherits from the specified className, or FALSE if not.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::isA ( char * className )
|
||||
{
|
||||
int result;
|
||||
if(strcmp(name, className)==0) result = 1;
|
||||
else if(parent!=NULL) result = parent->isA(className);
|
||||
else result = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::asciiDump :
|
||||
// * This method dumps the contents of the cdevClassDefinition to the user
|
||||
// * specified file descriptor.
|
||||
// *****************************************************************************
|
||||
inline void cdevClassDefinition::asciiDump ( FILE * fp )
|
||||
{
|
||||
if(name)
|
||||
{
|
||||
fprintf(fp, "\nclass %s", name);
|
||||
if(parent) fprintf(fp, " : %s", parent->name);
|
||||
fprintf(fp, "\n\t{\n");
|
||||
|
||||
if(verbs!=NULL) verbs->asciiDumpList(fp, "verbs");
|
||||
if(attributes!=NULL) attributes->asciiDumpList(fp, "attributes");
|
||||
if(messages!=NULL) messages->asciiDumpList(fp, "messages");
|
||||
|
||||
fprintf(fp, "\t}\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::asciiDumpInstances :
|
||||
// * This method dumps the instance data of the class definition to the
|
||||
// * caller specified file descriptor.
|
||||
// *****************************************************************************
|
||||
inline void cdevClassDefinition::asciiDumpInstances ( FILE * fp )
|
||||
{
|
||||
if(deviceHead!=NULL)
|
||||
{
|
||||
cdevDeviceDefinition * device = deviceHead;
|
||||
|
||||
fprintf(fp, "\n%s : \n", name);
|
||||
while(device!=NULL)
|
||||
{
|
||||
if(device->getName()!=device->getSubstituteName())
|
||||
{
|
||||
fprintf(fp, "\t%s {%s}\n", device->getName(), device->getSubstituteName());
|
||||
}
|
||||
else fprintf(fp, "\t%s\n", device->getName());
|
||||
device = device->getNext();
|
||||
}
|
||||
fprintf(fp, "\t;\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::asciiDumpRedirector :
|
||||
// * This method dumps the contents of the redirection table that is used
|
||||
// * to route messages to their intended service.
|
||||
// *****************************************************************************
|
||||
inline void cdevClassDefinition::asciiDumpRedirector ( FILE * fp )
|
||||
{
|
||||
StringHashIterator iter(&redirector);
|
||||
cdevRedirectorDefinition * def;
|
||||
|
||||
fprintf(fp, "\n/* Redirection table for class %s */\n", name);
|
||||
fprintf(fp, "class %s\n\t{\n\tmessages\n\t\t{\n", name);
|
||||
for(iter.first();
|
||||
(def = (cdevRedirectorDefinition *)iter.data())!=NULL;
|
||||
iter++)
|
||||
{
|
||||
def->asciiDump(fp);
|
||||
}
|
||||
fprintf(fp, "\t\t}\n\t}\n");
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::createRedirectionTable :
|
||||
// * This method will read the verbs, attributes and messages and will
|
||||
// * generate a redirection table that will allow the cdevDirectoryTable
|
||||
// * to route requests to the correct service using the proper serviceData.
|
||||
// *****************************************************************************
|
||||
inline void cdevClassDefinition::createRedirectionTable ( void )
|
||||
{
|
||||
cdevRedirectorDefinition * def;
|
||||
cdevElementDefinition ** msgPtr, ** vrbPtr, **atrPtr;
|
||||
int msgCnt, vrbCnt, atrCnt;
|
||||
int msgIdx, vrbIdx, atrIdx;
|
||||
|
||||
// *********************************************************************
|
||||
// * Get a pointer to all of the verbs that are in use by the class.
|
||||
// *********************************************************************
|
||||
getElements(cdevDirectoryTable::MESSAGE, msgPtr, msgCnt);
|
||||
getElements(cdevDirectoryTable::VERB, vrbPtr, vrbCnt);
|
||||
getElements(cdevDirectoryTable::ATTRIBUTE, atrPtr, atrCnt);
|
||||
|
||||
// *********************************************************************
|
||||
// * Process through all of the messages and add them to the
|
||||
// * redirection list first. Display a warning if they are already
|
||||
// * present.
|
||||
// *********************************************************************
|
||||
for(msgIdx=0; msgIdx<msgCnt; msgIdx++)
|
||||
{
|
||||
if(msgPtr[msgIdx]->getName() && msgPtr[msgIdx]->getService())
|
||||
{
|
||||
if(redirector.find(msgPtr[msgIdx]->getName())!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_INFO, "CDEV Directory", NULL,
|
||||
"Message %s already defined for class %s",
|
||||
msgPtr[msgIdx]->getName(), name);
|
||||
}
|
||||
else {
|
||||
def = new cdevRedirectorDefinition(strdup(msgPtr[msgIdx]->getName()), *msgPtr[msgIdx]);
|
||||
redirector.insert(def->getName(), def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
// * Walk through the verb list and combine them with each attribute...
|
||||
// * For each verb that has a service associated with it, use the verbs
|
||||
// * element definition... If the verb does not have a service, then
|
||||
// * use the attributes element definition.
|
||||
// *********************************************************************
|
||||
for(vrbIdx=0; vrbIdx<vrbCnt; vrbIdx++)
|
||||
{
|
||||
if(vrbPtr[vrbIdx]->getName())
|
||||
{
|
||||
// *****************************************************
|
||||
// * Using the verbs service.
|
||||
// *****************************************************
|
||||
if(vrbPtr[vrbIdx]->getService())
|
||||
{
|
||||
for(atrIdx=0; atrIdx<atrCnt; atrIdx++)
|
||||
{
|
||||
if(atrPtr[atrIdx]->getName()!=NULL)
|
||||
{
|
||||
char * temp = new char[strlen(vrbPtr[vrbIdx]->getName())+strlen(atrPtr[atrIdx]->getName())+2];
|
||||
sprintf(temp, "%s %s", vrbPtr[vrbIdx]->getName(), atrPtr[atrIdx]->getName());
|
||||
if(redirector.find(temp)!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_INFO, "CDEV Directory", NULL,
|
||||
"Message %s already defined for class %s",
|
||||
temp, name);
|
||||
delete temp;
|
||||
}
|
||||
else {
|
||||
def = new cdevRedirectorDefinition(temp, *vrbPtr[vrbIdx]);
|
||||
redirector.insert(def->getName(), def);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// *****************************************************
|
||||
// * Using the attributes service.
|
||||
// *****************************************************
|
||||
else for(atrIdx=0; atrIdx<atrCnt; atrIdx++)
|
||||
{
|
||||
if(atrPtr[atrIdx]->getName() && atrPtr[atrIdx]->getService())
|
||||
{
|
||||
char * temp = new char[strlen(vrbPtr[vrbIdx]->getName())+strlen(atrPtr[atrIdx]->getName())+2];
|
||||
sprintf(temp, "%s %s", vrbPtr[vrbIdx]->getName(), atrPtr[atrIdx]->getName());
|
||||
if(redirector.find(temp)!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_INFO, "CDEV Directory", NULL,
|
||||
"Message %s already defined for class %s",
|
||||
temp, name);
|
||||
delete temp;
|
||||
}
|
||||
else {
|
||||
def = new cdevRedirectorDefinition(temp, *atrPtr[atrIdx]);
|
||||
redirector.insert(def->getName(), def);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Neither the verb nor the message for \"%s %s\" has a service",
|
||||
vrbPtr[vrbIdx]->getName(), atrPtr[atrIdx]->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *********************************************************************
|
||||
// * Release the memory used to store the pointers.
|
||||
// *********************************************************************
|
||||
if(msgPtr) delete msgPtr;
|
||||
if(vrbPtr) delete vrbPtr;
|
||||
if(atrPtr) delete atrPtr;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getElements :
|
||||
// * This method allows the caller to retrieve a list of all element
|
||||
// * definitions of a particular type from all subclasses of the current
|
||||
// * class.
|
||||
// *****************************************************************************
|
||||
inline int cdevClassDefinition::getElements ( cdevDirectoryTable::ElementType type,
|
||||
cdevElementDefinition ** &def,
|
||||
int &nItems )
|
||||
{
|
||||
StringHash tempHash;
|
||||
cdevClassDefinition * classDef = this;
|
||||
|
||||
def = NULL;
|
||||
nItems = 0;
|
||||
|
||||
do
|
||||
{
|
||||
cdevElementDefinition * el =
|
||||
type==cdevDirectoryTable::VERB?classDef->verbs:
|
||||
(type==cdevDirectoryTable::ATTRIBUTE?classDef->attributes:
|
||||
classDef->messages);
|
||||
|
||||
for(; el!=NULL; el = el->getNext())
|
||||
{
|
||||
if(tempHash.find(el->getName())==NULL)
|
||||
{
|
||||
tempHash.insert(el->getName(), el);
|
||||
nItems++;
|
||||
}
|
||||
}
|
||||
classDef = classDef->parent;
|
||||
} while(classDef!=NULL);
|
||||
|
||||
if(nItems!=0)
|
||||
{
|
||||
StringHashIterator iter(&tempHash);
|
||||
|
||||
def = new cdevElementDefinition * [nItems];
|
||||
nItems = 0;
|
||||
|
||||
for(iter.first(); iter.key()!=NULL; iter++)
|
||||
{
|
||||
def[nItems++] = (cdevElementDefinition *)iter.data();
|
||||
}
|
||||
}
|
||||
|
||||
return nItems;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getName :
|
||||
// * This method allows the caller to retrieve the name of the class.
|
||||
// *****************************************************************************
|
||||
inline char * cdevClassDefinition::getName ( void )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition:: :
|
||||
// * This method allows the caller to retrieve the directory table that
|
||||
// * owns this device.
|
||||
// *****************************************************************************
|
||||
inline cdevDirectoryTable & cdevClassDefinition::getDirectory ( void )
|
||||
{
|
||||
return directory;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getParent :
|
||||
// * This method allows the caller to retrieve the class definition that
|
||||
// * this class inherits from.
|
||||
// *****************************************************************************
|
||||
inline cdevClassDefinition * cdevClassDefinition::getParent ( void )
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getVerbs :
|
||||
// * This method allows the caller to retrieve the lement definition list
|
||||
// * containing all of the classes verbs.
|
||||
// *****************************************************************************
|
||||
inline cdevElementDefinition * cdevClassDefinition::getVerbs ( void )
|
||||
{
|
||||
return verbs;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getAttributes :
|
||||
// * This method allows the caller to retrieve the element definition list
|
||||
// * containing all of the classes verbs.
|
||||
// *****************************************************************************
|
||||
inline cdevElementDefinition * cdevClassDefinition::getAttributes ( void )
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getMessages :
|
||||
// * This method allows the caller to retrieve the element definition list
|
||||
// * containing all of the classes messages.
|
||||
// *****************************************************************************
|
||||
inline cdevElementDefinition * cdevClassDefinition::getMessages ( void )
|
||||
{
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getDevices :
|
||||
// * This method allows the caller to retrieve the device definition list
|
||||
// * containing all of the instances of the class.
|
||||
// *****************************************************************************
|
||||
inline cdevDeviceDefinition * cdevClassDefinition::getDevices ( void )
|
||||
{
|
||||
return deviceHead;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getRedirector :
|
||||
// * This method allows the caller to retrieve the redirection list for
|
||||
// * the class.
|
||||
// *****************************************************************************
|
||||
inline StringHash & cdevClassDefinition::getRedirector ( void )
|
||||
{
|
||||
return redirector;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::getNext :
|
||||
// * This method allows the caller to retrieve the next class definition in
|
||||
// * the list.
|
||||
// *****************************************************************************
|
||||
inline cdevClassDefinition * cdevClassDefinition::getNext ( void )
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevClassDefinition::setNext :
|
||||
// * This method allows the caller to set the next class definition in the
|
||||
// * list.
|
||||
// *****************************************************************************
|
||||
inline void cdevClassDefinition::setNext ( cdevClassDefinition * Next )
|
||||
{
|
||||
next = Next;
|
||||
}
|
||||
|
||||
|
||||
#endif /* _CDEV_CLASS_DEFINITION_H_ */
|
||||
@@ -0,0 +1,81 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevClock Class Header File.
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevClock.h,v
|
||||
// Revision 1.2 1998/02/10 18:04:56 chen
|
||||
// add cdevSystem timer handler
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:02 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_CLOCK_H
|
||||
#define _CDEV_CLOCK_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <cdevTimeValue.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevClock
|
||||
{
|
||||
public:
|
||||
// constructor and destructor
|
||||
cdevClock (void);
|
||||
virtual ~cdevClock(void);
|
||||
|
||||
int isEmpty (void) const;
|
||||
// PURPOSE: check whether this clock is set or not
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 1: empty, return 0: not empty
|
||||
|
||||
const cdevTimeValue &scheduledTime (void) const;
|
||||
// PURPOSE: return scheduled timer value
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return time_value ZERO if empty
|
||||
|
||||
static cdevTimeValue currentTime (void);
|
||||
// PURPOSE: return current time
|
||||
// REQUIRE: static function
|
||||
// PROMISE: return current time (unix only)
|
||||
|
||||
int schedule (const void *a, const cdevTimeValue &);
|
||||
// PURPOSE: schedule a timer
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: your timer will be remembered
|
||||
|
||||
int cancel (void);
|
||||
// PURPOSE: cancel a shceduled timer
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: there will be no timer
|
||||
|
||||
int expired (void);
|
||||
// PURPOSE: check whether the timer is expired or not
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 1: expired, return 0: not expired
|
||||
|
||||
protected:
|
||||
static const cdevTimeValue zero;
|
||||
|
||||
private:
|
||||
cdevTimeValue clock_value_;
|
||||
const void *usr_arg_;
|
||||
// deny access to copy and assignment operation
|
||||
// no reason to create two clocks with same time value
|
||||
cdevClock (const cdevClock&);
|
||||
cdevClock& operator = (const cdevClock&);
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,135 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* Description:
|
||||
* cdevCollection class implementation
|
||||
*
|
||||
* Author: Walt Akers, Chip Watson & Jie Chen
|
||||
*
|
||||
* Revision History:
|
||||
* cdevCollection.h,v
|
||||
* Revision 1.3 1998/08/03 16:24:25 chen
|
||||
* AIX porting
|
||||
*
|
||||
* Revision 1.2 1997/12/12 16:35:43 chen
|
||||
* add VMS fix
|
||||
*
|
||||
* Revision 1.1 1996/11/12 20:32:11 akers
|
||||
* New collection device source code
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _CDEV_COLLECTION_H
|
||||
#define _CDEV_COLLECTION_H
|
||||
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevDevice.h>
|
||||
|
||||
#if defined(__VMS) || defined (AIX)
|
||||
typedef char* va_list;
|
||||
#undef va_start
|
||||
#define va_start(ap,v) ((void)((ap)=(char*)(&v + 1)))
|
||||
#undef va_arg
|
||||
#define va_arg(ap,type) (((type *)((ap)+=sizeof(type)))[-1])
|
||||
#undef va_end
|
||||
#define va_end(ap) ((void)0)
|
||||
#endif
|
||||
|
||||
class cdevCollectionRequest;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevCollection: public cdevDevice
|
||||
{
|
||||
friend class cdevDevice;
|
||||
|
||||
public:
|
||||
//===================================================================
|
||||
// Public Interface for Clients
|
||||
//===================================================================
|
||||
static cdevCollection& attachRef (char *name);
|
||||
static cdevCollection* attachPtr (char *name);
|
||||
// PURPOSE: create a reference or pointer for device of a given name
|
||||
// within the default system
|
||||
// REQUIRE: name != 0
|
||||
// PROMISE: a cdevCollection
|
||||
|
||||
static void detach (cdevCollection& dev);
|
||||
static void detach (cdevCollection* dev);
|
||||
// PURPOSE: destroy a cdevCollection
|
||||
// REQUIRE: dev != 0
|
||||
// PROMISE: memory will be freed if no more attachment on this device
|
||||
|
||||
//========================================================================
|
||||
// Public Interface for cdevRequestObject
|
||||
//========================================================================
|
||||
virtual cdevRequestObject *getRequestObject (char * msg );
|
||||
virtual int getRequestObject (char *msg, cdevRequestObject* &reqobj);
|
||||
// PURPOSE: get right requestObject based on its name
|
||||
// REQUIRE: name != 0, callers provide pointer only.
|
||||
// PROMISE: always return CDEV_SUCCESS. reqobj may be an errorRequestObject
|
||||
|
||||
//========================================================================
|
||||
// Public Interface for RTTI
|
||||
//========================================================================
|
||||
virtual const char *className (void) const {return "cdevCollection";}
|
||||
|
||||
//========================================================================
|
||||
// Public Interface for list manipulation
|
||||
//========================================================================
|
||||
char ** getList();
|
||||
// PURPOSE: obtain a null terminated array of device names
|
||||
// REQUIRE: caller is responsible for freeing list
|
||||
// PROMISE: if collection is empty, returns NULL
|
||||
|
||||
int add(char* name); // add a single device
|
||||
int add(int num, char* name, ...); // add multiple devices
|
||||
int add(int num, char** names); // add array of names of length num
|
||||
int add(char** names); // add a null terminated array of names
|
||||
int addRegexp(char* regexp); // add by regular expression
|
||||
int remove(char* name);
|
||||
int remove(int num, char* name, ...);
|
||||
int remove(int num, char** names);
|
||||
int remove(char** names); // remove a null terminated array of names
|
||||
int removeRegexp(char* regexp);
|
||||
// PURPOSE: add(remove) a (list of/regexp of) names to the collection
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: merged list will have no duplicates
|
||||
// return CDEV_SUCCESS: no duplicates/missing found, CDEV_WARNING:
|
||||
// at least one duplicate name was dropped during add or
|
||||
// at least one name was not found during remove
|
||||
|
||||
protected:
|
||||
//constructors and destructor
|
||||
cdevCollection (char *name,
|
||||
cdevSystem& system = cdevSystem::defaultSystem() );
|
||||
virtual ~cdevCollection (void);
|
||||
|
||||
// attach pointer or reference with system as second argument
|
||||
static cdevCollection& attachRef (char *name, cdevSystem& system);
|
||||
static cdevCollection* attachPtr (char *name, cdevSystem& system);
|
||||
// PURPOSE: create a reference or pointer for device of a given name
|
||||
// REQUIRE: name != 0
|
||||
// PROMISE: a cdevCollection
|
||||
|
||||
private:
|
||||
cdevSlist nameList_;
|
||||
|
||||
// hide assignment and copy operator since the collection is
|
||||
// a memory manager for collectionRequests and lists of devices
|
||||
cdevCollection& operator = (const cdevCollection &);
|
||||
cdevCollection (const cdevCollection &);
|
||||
|
||||
// friend class declaration
|
||||
friend class cdevCollectionRequest;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
#ifndef _CDEV_COLLECTION_DEFINITION_H_
|
||||
#define _CDEV_COLLECTION_DEFINITION_H_
|
||||
|
||||
#ifndef _CDEV_DIRECTORY_TABLE_H_
|
||||
#error "You must include cdevDirectoryTable.h to load cdevCollectionDefinition.h"
|
||||
#endif
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevCollectionDefinition :
|
||||
// * This class stores information that identifies a specific device name
|
||||
// * and associates it with a collection of devices.
|
||||
// *
|
||||
// * This class maintains a variety of internal data items for the following
|
||||
// * purposes...
|
||||
// *
|
||||
// * name - This is the name of the device as specified in the DDL file.
|
||||
// * directory - This is the cdevDirectoryTable object where the device was
|
||||
// * registered.
|
||||
// * cdevClass - This is the definition object for the class that the device
|
||||
// * belongs to (collection).
|
||||
// * devices - This is the list of devices that make up the collection.
|
||||
// * deviceCnt - This is the number of devices in the list.
|
||||
// * next - This is the next device in the linked list of
|
||||
// * cdevCollectionDefinition objects. This list is maintained
|
||||
// * as part of the cdevClassDefinition object.
|
||||
// *****************************************************************************
|
||||
class cdevCollectionDefinition
|
||||
{
|
||||
private:
|
||||
char * name;
|
||||
char ** devices;
|
||||
int deviceCnt;
|
||||
cdevCollectionDefinition * next;
|
||||
|
||||
public:
|
||||
inline cdevCollectionDefinition ( char * Name,
|
||||
char ** Devices = NULL,
|
||||
int DeviceCnt = 0 );
|
||||
inline ~cdevCollectionDefinition ( void );
|
||||
|
||||
inline void asciiDump ( FILE * fp = stdout );
|
||||
|
||||
// *********************************************************************
|
||||
// * Member access methods.
|
||||
// *********************************************************************
|
||||
inline char * getName ( void );
|
||||
inline char ** getDevices ( void );
|
||||
inline int getDeviceCnt ( void );
|
||||
inline cdevCollectionDefinition * getNext ( void );
|
||||
inline void setNext ( cdevCollectionDefinition * Next );
|
||||
};
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionDefinition::cdevCollectionDefinition :
|
||||
// * This is the constructor for the cdevCollectionDefinition class.
|
||||
// *****************************************************************************
|
||||
inline cdevCollectionDefinition::cdevCollectionDefinition
|
||||
( char * Name, char ** Devices, int DeviceCnt )
|
||||
: next(NULL), name(Name), devices(Devices), deviceCnt(DeviceCnt)
|
||||
{
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionDefinition::~cdevCollectionDefinition :
|
||||
// * This is the destructor for the cdevCollectionDefinition class.
|
||||
// *****************************************************************************
|
||||
inline cdevCollectionDefinition::~cdevCollectionDefinition ( void )
|
||||
{
|
||||
if(name) delete name;
|
||||
if(devices && deviceCnt)
|
||||
{
|
||||
while((--deviceCnt)>=0) delete devices[deviceCnt];
|
||||
}
|
||||
if(devices) delete devices;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionDefinition::asciiDump :
|
||||
// * Write the formatted output of the collection to the specified file
|
||||
// * pointer.
|
||||
// *****************************************************************************
|
||||
inline void cdevCollectionDefinition::asciiDump ( FILE * fp )
|
||||
{
|
||||
if(devices && deviceCnt)
|
||||
{
|
||||
fprintf(fp, "\ncollection %s :\n", name);
|
||||
for(int i=0; i<deviceCnt; i++)
|
||||
{
|
||||
fprintf(fp, "\t%s\n", devices[i]);
|
||||
}
|
||||
fprintf(fp, "\t;\n");
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionDefinition::getName :
|
||||
// * This method allows the caller to retrieve the device name.
|
||||
// *****************************************************************************
|
||||
inline char * cdevCollectionDefinition::getName ( void )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionDefinition::getDevices :
|
||||
// * This method returns the list of devices associated with the
|
||||
// * cdevCollection.
|
||||
// *****************************************************************************
|
||||
inline char ** cdevCollectionDefinition::getDevices ( void )
|
||||
{
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionDefinition::getDevices :
|
||||
// * This method returns the number of devices in the device list.
|
||||
// *****************************************************************************
|
||||
inline int cdevCollectionDefinition::getDeviceCnt ( void )
|
||||
{
|
||||
return deviceCnt;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionDefinition::getNext :
|
||||
// * This method allows the caller to retrieve the next device in the list.
|
||||
// *****************************************************************************
|
||||
inline cdevCollectionDefinition * cdevCollectionDefinition::getNext ( void )
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionDefinition::setNext :
|
||||
// * This method allows the caller to set the next device in the list.
|
||||
// *****************************************************************************
|
||||
inline void cdevCollectionDefinition::setNext ( cdevCollectionDefinition * Next )
|
||||
{
|
||||
next = Next;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 1995,1996 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* Description:
|
||||
* Class implementing request objects for collections
|
||||
*
|
||||
* Author: Walt Akers
|
||||
*
|
||||
* Revision History:
|
||||
* cdevCollectionRequest.h,v
|
||||
* Revision 1.1 1996/11/12 20:32:18 akers
|
||||
* New collection device source code
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef _CDEV_COLLECTION_REQUEST_H
|
||||
#define _CDEV_COLLECTION_REQUEST_H
|
||||
|
||||
#include <cdevSystem.h>
|
||||
#include <cdevRequestObject.h>
|
||||
#include <cdevCollection.h>
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevCollectionRequest:
|
||||
// * This is the cdevCollectionRequest class. It is the master type for
|
||||
// * all service derived cdevCollectionRequest objects.
|
||||
// *****************************************************************************
|
||||
class CDEV_CLASS_SPEC cdevCollectionRequest: public cdevRequestObject
|
||||
{
|
||||
friend class cdevCollection;
|
||||
friend class cdevGrpCollectionRequest;
|
||||
|
||||
public:
|
||||
// *********************************************************************
|
||||
// * Returns the name of the class.
|
||||
// *********************************************************************
|
||||
const char *className (void) const {return "cdevCollectionRequest";}
|
||||
|
||||
// *********************************************************************
|
||||
// * Returns the RESULT_CODE_TAG identifier.
|
||||
// *********************************************************************
|
||||
static int resultCodeTag(void) { return RESULT_CODE_TAG; }
|
||||
|
||||
protected:
|
||||
// *********************************************************************
|
||||
// * Constructor and destructor for the class.
|
||||
// *********************************************************************
|
||||
cdevCollectionRequest (char **devices, int nDevices, char *msg, cdevSystem& sys);
|
||||
virtual ~cdevCollectionRequest (void);
|
||||
|
||||
// *********************************************************************
|
||||
// * Factory used to generate cdevCollectionRequest objects.
|
||||
// *********************************************************************
|
||||
static cdevCollectionRequest * attachPtr(cdevCollection &device, char *msg, cdevSystem &system);
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the integer that wil be used to store the cdevData tag that
|
||||
// * will contain the completion code.
|
||||
// *********************************************************************
|
||||
static int RESULT_CODE_TAG;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// Utility prototypes and inline functions for cdev.
|
||||
//
|
||||
// Author: Walt Akers
|
||||
//
|
||||
// Revision History:
|
||||
// cdevCommon.h,v
|
||||
// Revision 1.2 1995/10/30 13:33:16 akers
|
||||
// Added cdev specific version of strncpy
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_COMMON_H
|
||||
#define _CDEV_COMMON_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevStrncpy:
|
||||
// * This is an alternative to the strncpy routine. This function will
|
||||
// * always NULL terminate the resulting string, strncpy does not.
|
||||
// *****************************************************************************
|
||||
inline char * cdevStrncpy(char *s1, const char *s2, size_t n)
|
||||
{
|
||||
char * result = s1;
|
||||
if(s1!=NULL)
|
||||
{
|
||||
while(s2!=NULL && *s2 && (n--)>1) *(s1++) = *(s2++);
|
||||
*s1=0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* _CDEV_COMMON_H */
|
||||
@@ -0,0 +1,95 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// CDEV Configuration Loader for different site
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevConfigFinder.h,v
|
||||
// Revision 1.1 1997/08/27 18:23:30 chen
|
||||
// Change error reporting to site specific scheme
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_CONFIG_FINDER_H
|
||||
#define _CDEV_CONFIG_FINDER_H
|
||||
|
||||
#if defined (_WIN32)
|
||||
|
||||
#ifndef SHOBJ
|
||||
#define SHOBJ 1
|
||||
#endif
|
||||
|
||||
#endif /* WIN 32 */
|
||||
|
||||
#ifdef SHOBJ
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cdevSystem.h>
|
||||
|
||||
#define _CDEV_CONFIG_FILENAME "cdevSiteConfig.so"
|
||||
#define _CDEV_CONFIG_ROUTINE "_cdev_site_config"
|
||||
|
||||
class shObjLoader;
|
||||
|
||||
class cdevConfigFinder
|
||||
{
|
||||
public:
|
||||
// constructor and destructor
|
||||
cdevConfigFinder (cdevSystem& system = cdevSystem::defaultSystem ());
|
||||
~cdevConfigFinder (void);
|
||||
|
||||
|
||||
int loadConfig (void);
|
||||
// PURPOSE: load a site defined configuration file with routine name
|
||||
// _cdev_site_config (cdevSystem& system)
|
||||
// REQUIRE: none
|
||||
// PROMISE: return 0: configuration loaded. return -1: failed
|
||||
|
||||
protected:
|
||||
|
||||
// flag that denotes whether the system has tried load config or not
|
||||
static int tloadconfig_;
|
||||
|
||||
private:
|
||||
// deny assignment and copy operations
|
||||
cdevConfigFinder (const cdevConfigFinder& finder);
|
||||
cdevConfigFinder& operator = (const cdevConfigFinder& finder);
|
||||
|
||||
// data area
|
||||
shObjLoader* loader_;
|
||||
cdevSystem& system_;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cdevSystem.h>
|
||||
|
||||
class cdevConfigFinder
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
cdevConfigFinder (cdevSystem& system = cdevSystem::defaultSystem ());
|
||||
|
||||
int loadConfig (void) {return 0;}
|
||||
private:
|
||||
// deny assignment and copy operations
|
||||
cdevConfigFinder (const cdevConfigFinder& finder);
|
||||
cdevConfigFinder& operator = (const cdevConfigFinder& finder);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,578 @@
|
||||
//---------------------------------------------------------------------------
|
||||
// Copyright (c) 1991,1992 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// description: cdevData.h
|
||||
// Self descibing data structure to manage the storage and transport
|
||||
// of data between local cdev functions, as well as remote client and
|
||||
// server applications.
|
||||
//
|
||||
// Author: Walt Akers and Danjin Wu
|
||||
//
|
||||
// Revision History:
|
||||
// cdevData.h,v
|
||||
// Revision 1.24 1997/12/22 13:47:02 akers
|
||||
// Made changeTag method virtual
|
||||
//
|
||||
// Revision 1.23 1997/08/01 19:06:29 akers
|
||||
// Added addTag and tagExists feature to the library
|
||||
//
|
||||
// Revision 1.22 1997/01/14 19:39:39 chen
|
||||
// add += operator
|
||||
//
|
||||
// Revision 1.21 1997/01/09 16:32:39 akers
|
||||
// Corrected anachronism
|
||||
//
|
||||
// Revision 1.20 1996/11/21 17:02:57 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.19 1996/10/01 13:58:19 akers
|
||||
// Changes to support AIX
|
||||
//
|
||||
// Revision 1.18 1996/09/20 19:33:11 akers
|
||||
// Changed protection in cdevDataEntryStorage, cdevDataEntry and cdevData in order to support subclassing of the cdevData object
|
||||
//
|
||||
// Revision 1.17 1996/09/20 15:41:51 akers
|
||||
// Made xdr methods virual
|
||||
//
|
||||
// Revision 1.16 1996/08/26 19:14:05 akers
|
||||
// Adding cdevData.inserttag callback capabilities
|
||||
//
|
||||
// Revision 1.15 1996/08/23 15:34:07 akers
|
||||
// Added comparison operator to cdevData
|
||||
//
|
||||
// Revision 1.14 1996/07/12 18:08:52 chen
|
||||
// change copy and assignment to const cdevData&
|
||||
//
|
||||
// Revision 1.13 1996/04/12 13:40:04 akers
|
||||
// Added char * cast operator
|
||||
//
|
||||
// Revision 1.12 1996/02/27 20:50:05 danjin
|
||||
// add assignment operator from various typed data to cdevData object
|
||||
//
|
||||
// Revision 1.11 1995/11/01 15:43:42 akers
|
||||
// Corrected INLINE definition
|
||||
//
|
||||
// Revision 1.10 1995/10/06 20:09:47 chen
|
||||
// add stdio
|
||||
//
|
||||
// Revision 1.9 1995/10/06 19:38:34 chen
|
||||
// Seperate inline functions
|
||||
//
|
||||
// Revision 1.8 1995/10/03 19:36:34 chen
|
||||
// Use new cdevGlobalTagTable Class
|
||||
//
|
||||
// Revision 1.7 1995/09/22 21:04:24 danjin
|
||||
// added cdevDataIterator mechanism
|
||||
//
|
||||
// Revision 1.6 1995/09/13 15:27:10 danjin
|
||||
// added changeTagName func
|
||||
//
|
||||
// Revision 1.5 1995/09/06 18:34:16 danjin
|
||||
// added time stamp structure and related func
|
||||
//
|
||||
// Revision 1.4 1995/07/20 14:36:52 akers
|
||||
// Mispelling in header
|
||||
//
|
||||
// Revision 1.3 1995/07/19 20:34:06 akers
|
||||
// CVS
|
||||
//
|
||||
// Revision 1.2 1995/07/14 13:20:09 akers
|
||||
// Updated cdevData header file supporting changes specified at June 95 Review
|
||||
//
|
||||
//
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
#ifndef _CDEV_DATA_H
|
||||
#define _CDEV_DATA_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <cdevErrCode.h>
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevDataEntry.h>
|
||||
#include <cdevTagTable.h>
|
||||
#include <cdevGlobalTagTable.h>
|
||||
|
||||
#ifndef __hpux
|
||||
extern char* ltoa (long val);
|
||||
extern char* ultoa (unsigned long val);
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
extern "C" char *ctime (__const time_t *__timer) __THROW;
|
||||
#endif
|
||||
|
||||
class CDEV_CLASS_SPEC cdevData
|
||||
{
|
||||
friend class cdevDataIterator;
|
||||
protected:
|
||||
cdevDataEntry *entries;
|
||||
|
||||
// *********************************************************************
|
||||
// * copy:
|
||||
// * This function copies the contents of the cdevData object
|
||||
// * specified by data into this cdevData object. It is used by
|
||||
// * both the copy constructor and by the assignment operator.
|
||||
// *********************************************************************
|
||||
cdevData & copy (const cdevData & data);
|
||||
|
||||
// *********************************************************************
|
||||
// * lookupTag:
|
||||
// * This function is for internal use and allows a cdevData object
|
||||
// * to locate and optionally create a tagged data item.
|
||||
// *********************************************************************
|
||||
cdevDataEntry * lookupTag(int tag, int create = 0);
|
||||
cdevDataEntry * lookupTag(char * ctag, int create = 0);
|
||||
|
||||
// *********************************************************************
|
||||
// * setupTag:
|
||||
// * This function is for internal use and is used to prepare a new
|
||||
// * cdevDataEntry object prior to inserting data into it.
|
||||
// *********************************************************************
|
||||
cdevDataEntry * setupTag (
|
||||
int tag, cdevDataTypes type, size_t elemSize,
|
||||
size_t numElems, size_t numDims );
|
||||
|
||||
public:
|
||||
// *********************************************************************
|
||||
// * This group of static functions allows the user an interface to the
|
||||
// * database of tagged data items that is stored in the
|
||||
// * cdevGlobalTagTable object.
|
||||
// *********************************************************************
|
||||
static int tagC2I (char *ctag, int *tag);
|
||||
static int tagI2C (int tag, char * &ctag);
|
||||
static void insertTag(int tag, char *ctag);
|
||||
static int tagExists(char * ctag);
|
||||
static int tagExists(int tag);
|
||||
static int addTag (char * ctag);
|
||||
|
||||
// ***************************************************************************
|
||||
// * addTagCallback :
|
||||
// * This method will add a cdevTagTableCallback object to the list of
|
||||
// * classes that should be notified each time a tag is added to the
|
||||
// * cdevTagTable.
|
||||
// ***************************************************************************
|
||||
static void addTagCallback ( cdevTagTableCallback * cb );
|
||||
|
||||
// ***************************************************************************
|
||||
// * delTagCallback :
|
||||
// * This method will remote a cdevTagTableCallback object that was
|
||||
// * previously added to the list of callback classes.
|
||||
// *
|
||||
// * Note: This method does not actually delete the cdevTagTableCallback
|
||||
// * object, it merely removes it from the list. It is the
|
||||
// * responsibility of the owner to delete the object when it is
|
||||
// * no longer needed.
|
||||
// ***************************************************************************
|
||||
static void delTagCallback ( cdevTagTableCallback * cb );
|
||||
|
||||
// *****************************************************************************
|
||||
// * readTagTable :
|
||||
// * This method allows the caller to obtain a list of tag names and
|
||||
// * integers that are currently stored in this tag table.
|
||||
// *
|
||||
// * Note: This method will allocate an array of integers and an array of
|
||||
// * character string pointers. The strings that are stored in the
|
||||
// * string array will be the actual strings from within the
|
||||
// * tag table and should not be deleted...
|
||||
// *
|
||||
// * The data allocated becomes the property of the caller and must
|
||||
// * be deleted when it is no longer needed... the correct syntax to
|
||||
// * delete these items is...
|
||||
// *
|
||||
// * delete tags;
|
||||
// * delete ctags;
|
||||
// *
|
||||
// * This will delete the array, however, it will leave the
|
||||
// * individual array elements intact.
|
||||
// *****************************************************************************
|
||||
static int readTagTable ( int * &tags, char ** &ctags, int &ntags );
|
||||
|
||||
// *********************************************************************
|
||||
// * cdevData:
|
||||
// * This is the default constructor, it simply initializes
|
||||
// * variables within the cdevData object.
|
||||
// *********************************************************************
|
||||
cdevData ( void );
|
||||
|
||||
// *********************************************************************
|
||||
// * cdevData:
|
||||
// * Copy constructor. This constructor duplicates the cdevData
|
||||
// * object that it has been passed as a parameter.
|
||||
// *********************************************************************
|
||||
cdevData ( const cdevData & data );
|
||||
|
||||
// *********************************************************************
|
||||
// * ~cdevData:
|
||||
// * This is the default destructor for the cdevData object. It
|
||||
// * frees any memory allocated for storage and deletes the object.
|
||||
// *********************************************************************
|
||||
~cdevData( void );
|
||||
|
||||
// *********************************************************************
|
||||
// * Assignment operator:
|
||||
// * This function copies the contents of a cdevData object to this
|
||||
// * object.
|
||||
// *********************************************************************
|
||||
cdevData & operator = (const cdevData & data);
|
||||
|
||||
// *********************************************************************
|
||||
// * Casting operators:
|
||||
// * These operators provide convenience methods for the user to
|
||||
// * obtain the value tagged data item from the cdevData object.
|
||||
// *********************************************************************
|
||||
operator char ( void );
|
||||
operator short ( void );
|
||||
operator unsigned short ( void );
|
||||
operator int ( void );
|
||||
operator unsigned int ( void );
|
||||
operator long ( void );
|
||||
operator unsigned long ( void );
|
||||
operator float ( void );
|
||||
operator double ( void );
|
||||
operator char * ( void );
|
||||
|
||||
// *********************************************************************
|
||||
// * Assignment operators:
|
||||
// * These operators provide convenience methods for the user to
|
||||
// * obtain the value tagged cdevData object from various typed data.
|
||||
// *********************************************************************
|
||||
cdevData& operator= (unsigned char x);
|
||||
cdevData& operator= (short x);
|
||||
cdevData& operator= (unsigned short x);
|
||||
cdevData& operator= (int x);
|
||||
cdevData& operator= (unsigned int x);
|
||||
cdevData& operator= (long x);
|
||||
cdevData& operator= (unsigned long x);
|
||||
cdevData& operator= (float x);
|
||||
cdevData& operator= (double x);
|
||||
|
||||
// *********************************************************************
|
||||
// * Append operation:
|
||||
// * This operation will append a cdevData onto an existing cdevData
|
||||
// * and return this object. If there is confilicts among tags, the
|
||||
// * appended one wins
|
||||
// *********************************************************************
|
||||
cdevData& operator += (const cdevData& data);
|
||||
|
||||
// *********************************************************************
|
||||
// * asciiDump:
|
||||
// * Performs a diagnostic dump of the entire contents of the
|
||||
// * cdevData object to the specified file pointer.
|
||||
// *********************************************************************
|
||||
#ifdef _WIN32
|
||||
inline void asciiDump ( FILE * fp = stdout )
|
||||
{
|
||||
int fd = _fileno(fp);
|
||||
long osfHandle = _get_osfhandle(fd);
|
||||
asciiDump(osfHandle);
|
||||
_lseek(fd, 0L, SEEK_END);
|
||||
}
|
||||
void asciiDump ( long osfHandle );
|
||||
#else
|
||||
void asciiDump ( FILE * fp = stdout );
|
||||
#endif
|
||||
|
||||
// *********************************************************************
|
||||
// * XDR Utilities:
|
||||
// * These functions provide the mechanisms for converting a cdevData
|
||||
// * object into a network portable bninary stream, and then
|
||||
// * reconstructing them after transport.
|
||||
// *********************************************************************
|
||||
virtual int xdrSize (size_t * bufLen, size_t * elementCount);
|
||||
virtual int xdrExport ( char ** buf, size_t * bufLen );
|
||||
virtual int xdrExport ( char * buf, size_t bufLen, size_t count);
|
||||
virtual int xdrImport ( char * buf, size_t bufLen);
|
||||
|
||||
// *********************************************************************
|
||||
// * remove:
|
||||
// * Removes cdevDataEntry objects from the cdevData object by tag
|
||||
// * integer or by tag string. If no tag is specified, then all
|
||||
// * cdevDataEntry objects will be removed.
|
||||
// *********************************************************************
|
||||
void remove( void );
|
||||
void remove( int tag );
|
||||
void remove( char * ctag );
|
||||
|
||||
// *********************************************************************
|
||||
// * changeTag:
|
||||
// * Replace a new tag with the old one within the
|
||||
// * cdevData object. If the old one can not be not found,
|
||||
// * CDEV_NOTFOUND is returned. If the new tag has already
|
||||
// * been found in that cdevData object, CDEV_ERROR is returned.
|
||||
// *********************************************************************
|
||||
virtual int changeTag(int oldTag, int newTag);
|
||||
int changeTag(int oldTag, char *c_newTag);
|
||||
int changeTag(char *c_oldTag, int newTag);
|
||||
int changeTag(char *c_oldTag, char *c_newTag);
|
||||
|
||||
// *********************************************************************
|
||||
// * getType:
|
||||
// * Retrieves the cdevDataTypes of the referenced tagged data item.
|
||||
// * If no item with that tag is within the cdevData object, then
|
||||
// * CDEV_INVALID is returned.
|
||||
// *********************************************************************
|
||||
cdevDataTypes getType(int tag);
|
||||
cdevDataTypes getType(char *ctag);
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// * getDim:
|
||||
// * Obtains the number of dimensions in the specified tagged data
|
||||
// * item. Returns CDEV_SUCCESS if the tagged item exists, otherwise,
|
||||
// * CDEV_NOTFOUND is returned.
|
||||
// **********************************************************************
|
||||
int getDim(int tag, size_t *dim);
|
||||
int getDim(char *ctag, size_t *dim);
|
||||
|
||||
// *********************************************************************
|
||||
// * getElems:
|
||||
// * Obtains the number of elements in the specified tagged data
|
||||
// * item. Returns CDEV_SUCCESS if the tagged item exists, otherwise,
|
||||
// * CDEV_NOTFOUND is returned.
|
||||
// **********************************************************************
|
||||
int getElems(int tag, size_t *elems);
|
||||
int getElems(char *ctag, size_t *elems);
|
||||
|
||||
// *********************************************************************
|
||||
// * getBounds:
|
||||
// * Obtains the bounding dimensions of a cdevDataEntry array. The
|
||||
// * integer array passed as the bounds parameter must be allocated
|
||||
// * by the caller. The number of integers required is 2 times the
|
||||
// * number of dimensions, the first being the offset and the second
|
||||
// * being the length of the dimension. The len parameter specifies
|
||||
// * the actual number of integers allocated.
|
||||
// *********************************************************************
|
||||
int getBounds(int tag, size_t * bounds, size_t len);
|
||||
int getBounds(char * ctag, size_t * bounds, size_t len);
|
||||
|
||||
// *********************************************************************
|
||||
// * getBounds:
|
||||
// * Obtains the bounding dimensions of a cdevDataEntry array. The
|
||||
// * cdevBounds structure passed as the bounds parameter must be
|
||||
// * allocated by the caller. The numBounds variable indicates the
|
||||
// * number of cdevBounds structures allocated by the caller.
|
||||
// *********************************************************************
|
||||
int getBounds(int tag, cdevBounds * bounds, size_t numBounds);
|
||||
int getBounds(char * ctag, cdevBounds * bounds, size_t numBounds);
|
||||
|
||||
// *********************************************************************
|
||||
// * setBounds:
|
||||
// * Allows the caller to set the dimensions of a multidimensional
|
||||
// * tagged data item. The number of integers required is 2 times the
|
||||
// * number of dimensions, the first being the offset and the second
|
||||
// * being the length of the dimension. The len parameter specifies
|
||||
// * the actual number of integers submitted.
|
||||
// *********************************************************************
|
||||
int setBounds(int tag, size_t * bounds, size_t len);
|
||||
int setBounds(char * ctag, size_t * bounds, size_t len);
|
||||
|
||||
// *********************************************************************
|
||||
// * setBounds:
|
||||
// * Allows the caller to set the dimensions of a multidimensional
|
||||
// * tagged data item. The numBounds variable indicates the number
|
||||
// * of cdevBounds structures submitted by the user.
|
||||
// *********************************************************************
|
||||
int setBounds(int tag, cdevBounds * bounds, size_t numBounds);
|
||||
int setBounds(char * ctag, cdevBounds * bounds, size_t numBounds);
|
||||
|
||||
// *********************************************************************
|
||||
// * insert:
|
||||
// * The following functions allow the insertion of scalar data into
|
||||
// * a cdevData object.
|
||||
// *********************************************************************
|
||||
int insert ( int tag, BYTE data );
|
||||
int insert ( int tag, short data );
|
||||
int insert ( int tag, unsigned short data );
|
||||
int insert ( int tag, long data );
|
||||
int insert ( int tag, unsigned long data );
|
||||
int insert ( int tag, float data );
|
||||
int insert ( int tag, double data );
|
||||
int insert ( int tag, cdev_TS_STAMP data );
|
||||
|
||||
// *********************************************************************
|
||||
// * Overloaded character tag based insertion mechanism
|
||||
// *********************************************************************
|
||||
int insert ( char * ctag, BYTE data);
|
||||
int insert ( char * ctag, short data);
|
||||
int insert ( char * ctag, unsigned short data);
|
||||
int insert ( char * ctag, long data);
|
||||
int insert ( char * ctag, unsigned long data);
|
||||
int insert ( char * ctag, float data);
|
||||
int insert ( char * ctag, double data);
|
||||
int insert ( char * ctag, cdev_TS_STAMP data);
|
||||
|
||||
// ********************************************************************
|
||||
// * insert:
|
||||
// * The following functions allow the insertion of arrays of data
|
||||
// * into a cdevData object. The len variable contains the total
|
||||
// * number of elements to be inserted, the ndim variable indicates
|
||||
// * the number of dimensions in the array.
|
||||
// ********************************************************************
|
||||
int insert (int tag, BYTE * data, size_t len, size_t ndim = 1);
|
||||
int insert (int tag, short * data, size_t len, size_t ndim = 1);
|
||||
int insert (int tag, unsigned short * data, size_t len, size_t ndim = 1);
|
||||
int insert (int tag, long * data, size_t len, size_t ndim = 1);
|
||||
int insert (int tag, unsigned long * data, size_t len, size_t ndim = 1);
|
||||
int insert (int tag, float * data, size_t len, size_t ndim = 1);
|
||||
int insert (int tag, double * data, size_t len, size_t ndim = 1);
|
||||
int insert ( int tag, cdev_TS_STAMP *data, size_t len, size_t ndim = 1);
|
||||
|
||||
// *********************************************************************
|
||||
// * Overloaded character tag based insertion mechanism
|
||||
// *********************************************************************
|
||||
int insert (char * ctag, BYTE * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, short * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, unsigned short * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, long * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, unsigned long * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, float * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, double * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, cdev_TS_STAMP *data, size_t len, size_t ndim =1 );
|
||||
|
||||
// *********************************************************************
|
||||
// * insert:
|
||||
// * The following functions explicitly call the long functions when
|
||||
// * dealing with integer data. On a system with 16 bit integers,
|
||||
// * the short functions should be called.
|
||||
// *********************************************************************
|
||||
#ifdef DEFAULT_16_BIT_INTEGER
|
||||
int insert ( int tag, int data );
|
||||
int insert ( int tag, unsigned int data );
|
||||
int insert ( char * ctag, int data);
|
||||
int insert ( char * ctag, unsigned int data);
|
||||
int insert (int tag, int * data, size_t len, size_t ndim = 1);
|
||||
int insert (int tag, unsigned int * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, int * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, unsigned int * data, size_t len, size_t ndim = 1);
|
||||
#else
|
||||
int insert ( int tag, int data );
|
||||
int insert ( int tag, unsigned int data ) ;
|
||||
int insert ( char * ctag, int data);
|
||||
int insert ( char * ctag, unsigned int data);
|
||||
int insert (int tag, int * data, size_t len, size_t ndim = 1);
|
||||
int insert (int tag, unsigned int * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, int * data, size_t len, size_t ndim = 1);
|
||||
int insert (char * ctag, unsigned int * data, size_t len, size_t ndim = 1);
|
||||
#endif
|
||||
|
||||
// *********************************************************************
|
||||
// * insert:
|
||||
// * The following functions insert character strings and arrays of
|
||||
// * character strings. Their treatment is different from the scalar
|
||||
// * data types.
|
||||
// *********************************************************************
|
||||
int insert ( int tag, char * data );
|
||||
int insert ( int tag, char ** data, size_t len = 0, size_t ndim = 1 );
|
||||
|
||||
// *********************************************************************
|
||||
// * Overloaded character tag based insertion mechanism
|
||||
// *********************************************************************
|
||||
int insert ( char * ctag, char * data);
|
||||
int insert ( char * ctag, char ** data, size_t len = 0, size_t ndim = 1);
|
||||
|
||||
// *********************************************************************
|
||||
// * get:
|
||||
// * This group of functions allows the user to extract scalar and
|
||||
// * array data from the cdevData object.
|
||||
// *********************************************************************
|
||||
int get(int tag, BYTE * data);
|
||||
int get(int tag, short * data);
|
||||
int get(int tag, unsigned short * data);
|
||||
int get(int tag, long * data);
|
||||
int get(int tag, unsigned long * data);
|
||||
int get(int tag, float * data);
|
||||
int get(int tag, double * data);
|
||||
int get(int tag, char * data, size_t len);
|
||||
int get(int tag, char ** data);
|
||||
int get(int tag, cdev_TS_STAMP * data);
|
||||
// *********************************************************************
|
||||
// * Overloaded character tag based extraction mechanism
|
||||
// *********************************************************************
|
||||
int get(char * ctag, BYTE * data);
|
||||
int get(char * ctag, short * data);
|
||||
int get(char * ctag, unsigned short * data);
|
||||
int get(char * ctag, long * data);
|
||||
int get(char * ctag, unsigned long * data);
|
||||
int get(char * ctag, float * data);
|
||||
int get(char * ctag, double * data);
|
||||
int get(char * ctag, char * data, size_t len);
|
||||
int get(char * ctag, char ** data);
|
||||
int get(char * ctag, cdev_TS_STAMP * data);
|
||||
|
||||
// *********************************************************************
|
||||
// * get:
|
||||
// * The following get functions explicitly call the long integer
|
||||
// * functions unless the user is on a system with 16 bit integers.
|
||||
// *********************************************************************
|
||||
#ifdef DEFAULT_16_BIT_INTEGER
|
||||
int get(int tag, int * data);
|
||||
int get(int tag, unsigned int * data);
|
||||
int get(char *ctag, int * data);
|
||||
int get(char *ctag, unsigned int * data);
|
||||
#else
|
||||
int get(int tag, int * data);
|
||||
int get(int tag, unsigned int * data);
|
||||
int get(char *ctag, int * data);
|
||||
int get(char *ctag, unsigned int * data);
|
||||
#endif
|
||||
|
||||
// *********************************************************************
|
||||
// * find:
|
||||
// * These functions allow the user to obtain a pointer to data
|
||||
// * within the actual data variables within the cdevData object.
|
||||
// *********************************************************************
|
||||
int find(int tag, void* &data);
|
||||
int find(char * ctag, void* &data);
|
||||
|
||||
// *********************************************************************
|
||||
// * operator ==, operator !=:
|
||||
// * These methods provides a fast way for the caller to identify if two
|
||||
// * cdevData objects contain the identical fields and values...
|
||||
// *********************************************************************
|
||||
int operator == (cdevData & data);
|
||||
int operator != (cdevData & data) { return !(operator == (data)); }
|
||||
};
|
||||
|
||||
|
||||
class CDEV_CLASS_SPEC cdevDataIterator
|
||||
{
|
||||
public:
|
||||
cdevDataIterator(cdevData* data);
|
||||
~cdevDataIterator() {};
|
||||
int init();
|
||||
int operator !();
|
||||
int operator ++();
|
||||
int tag(void);
|
||||
|
||||
protected:
|
||||
cdevData *dataobj_;
|
||||
cdevDataEntry *cur_;
|
||||
};
|
||||
|
||||
#undef INLINE
|
||||
#ifndef _CDEV_NO_INLINE
|
||||
#define INLINE inline
|
||||
#include "cdevData.i"
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,572 @@
|
||||
//---------------------------------------------------------------------------
|
||||
// Copyright (c) 1991,1992 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// description: cdevData.h
|
||||
// Self descibing data structure to manage the storage and transport
|
||||
// of data between local cdev functions, as well as remote client and
|
||||
// server applications.
|
||||
//
|
||||
// Author: Walt Akers and Danjin Wu
|
||||
//
|
||||
// Revision History:
|
||||
// cdevData.i,v
|
||||
// Revision 1.6 1996/11/21 17:02:59 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.5 1996/07/12 18:09:01 chen
|
||||
// change copy and assignment to const cdevData&
|
||||
//
|
||||
// Revision 1.4 1996/04/12 13:40:07 akers
|
||||
// Added char * cast operator
|
||||
//
|
||||
// Revision 1.3 1996/02/27 20:50:13 danjin
|
||||
// add assignment operator from various typed data to cdevData object
|
||||
//
|
||||
// Revision 1.2 1995/10/16 18:14:20 chen
|
||||
// Fix a bug for SunOs and g++
|
||||
//
|
||||
// Revision 1.1 1995/10/06 19:39:03 chen
|
||||
// all cdevData inline functions
|
||||
//
|
||||
//
|
||||
INLINE
|
||||
cdevDataEntry* cdevData::lookupTag(char * ctag, int create)
|
||||
{
|
||||
int tag;
|
||||
return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?
|
||||
(cdevDataEntry *)0:lookupTag(tag, create);
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData &
|
||||
cdevData::operator = (const cdevData & data)
|
||||
{
|
||||
return copy(data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
void cdevData::remove( char * ctag )
|
||||
{
|
||||
int tag; if(!cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)) remove(tag);
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevDataTypes cdevData::getType(char *ctag)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?
|
||||
CDEV_INVALID:getType(tag);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::getDim(char *ctag, size_t *dim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?
|
||||
CDEV_NOTFOUND:getDim(tag, dim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::getElems(char *ctag, size_t *elems)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?
|
||||
CDEV_NOTFOUND:getElems(tag, elems);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::getBounds(char * ctag, size_t * bounds, size_t len)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?
|
||||
CDEV_NOTFOUND:getBounds(tag, bounds, len);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::getBounds(char * ctag, cdevBounds * bounds, size_t numBounds)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?
|
||||
CDEV_NOTFOUND:getBounds(tag, bounds, numBounds);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::setBounds(char * ctag, size_t * bounds, size_t len)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?
|
||||
CDEV_NOTFOUND:setBounds(tag, bounds, len);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::setBounds(char * ctag, cdevBounds * bounds, size_t numBounds)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?
|
||||
CDEV_NOTFOUND:setBounds(tag, bounds, numBounds);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, BYTE data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, short data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, unsigned short data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, long data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, unsigned long data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, float data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, double data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, cdev_TS_STAMP data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, BYTE * data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, short * data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, unsigned short * data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, long * data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, unsigned long * data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, float * data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, double * data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, char * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, char ** data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, cdev_TS_STAMP * data, size_t len, size_t ndim)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:insert(tag, data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, BYTE * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, short * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, unsigned short * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, long * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, unsigned long * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, float * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, double * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, char * data, size_t len)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data, len);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, char ** data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char * ctag, cdev_TS_STAMP * data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:get(tag, data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::find(char * ctag, void* &data)
|
||||
{
|
||||
int tag; return cdevGlobalTagTable::tagTable()->tagC2I(ctag, &tag)?CDEV_NOTFOUND:find(tag, data);
|
||||
}
|
||||
|
||||
#ifdef DEFAULT_16_BIT_INTEGER
|
||||
INLINE
|
||||
int cdevData::insert ( int tag, int data )
|
||||
{
|
||||
return insert(tag, (short)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( int tag, unsigned int data )
|
||||
{
|
||||
return insert(tag, (unsigned short)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, int data)
|
||||
{
|
||||
return insert(ctag, (short)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, unsigned int data)
|
||||
{
|
||||
return insert(ctag, (unsigned short)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (int tag, int * data, size_t len, size_t ndim)
|
||||
{
|
||||
return insert(tag, (short *)data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (int tag, unsigned int * data, size_t len, size_t ndim)
|
||||
{
|
||||
return insert(tag, (unsigned short *)data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, int * data, size_t len, size_t ndim)
|
||||
{
|
||||
return insert(ctag, (short *)data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, unsigned int * data, size_t len, size_t ndim)
|
||||
{
|
||||
return insert(ctag, (unsigned short *)data, len, ndim);
|
||||
}
|
||||
#else
|
||||
INLINE
|
||||
int cdevData::insert ( int tag, int data )
|
||||
{
|
||||
return insert(tag, (long)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( int tag, unsigned int data )
|
||||
{
|
||||
return insert(tag, (unsigned long)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, int data)
|
||||
{
|
||||
return insert(ctag, (long)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert ( char * ctag, unsigned int data)
|
||||
{
|
||||
return insert(ctag, (unsigned long)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (int tag, int * data, size_t len, size_t ndim)
|
||||
{
|
||||
return insert(tag, (long *)data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (int tag, unsigned int * data, size_t len, size_t ndim)
|
||||
{
|
||||
return insert(tag, (unsigned long *)data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, int * data, size_t len, size_t ndim)
|
||||
{
|
||||
return insert(ctag, (long *)data, len, ndim);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::insert (char * ctag, unsigned int * data, size_t len, size_t ndim)
|
||||
{
|
||||
return insert(ctag, (unsigned long *)data, len, ndim);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEFAULT_16_BIT_INTEGER
|
||||
INLINE
|
||||
int cdevData::get(int tag, int * data)
|
||||
{
|
||||
return get(tag, (short *)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(int tag, unsigned int * data)
|
||||
{
|
||||
return get(tag, (unsigned short *) data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char *ctag, int * data)
|
||||
{
|
||||
return get(ctag, (short *)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char *ctag, unsigned int * data)
|
||||
{
|
||||
return get(ctag, (unsigned short *) data);
|
||||
}
|
||||
#else
|
||||
INLINE
|
||||
int cdevData::get(int tag, int * data)
|
||||
{
|
||||
return get(tag, (long *)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(int tag, unsigned int * data)
|
||||
{
|
||||
return get(tag, (unsigned long *) data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char *ctag, int * data)
|
||||
{
|
||||
return get(ctag, (long *)data);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int cdevData::get(char *ctag, unsigned int * data)
|
||||
{
|
||||
return get(ctag, (unsigned long *) data);
|
||||
}
|
||||
#endif
|
||||
|
||||
INLINE
|
||||
cdevData::operator char( void )
|
||||
{
|
||||
BYTE x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData::operator short( void )
|
||||
{
|
||||
short x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData::operator unsigned short( void )
|
||||
{
|
||||
unsigned short x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData::operator int( void )
|
||||
{
|
||||
int x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData::operator unsigned int( void )
|
||||
{
|
||||
unsigned int x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData::operator long( void )
|
||||
{
|
||||
long x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData::operator unsigned long( void )
|
||||
{
|
||||
unsigned long x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData::operator float( void )
|
||||
{
|
||||
float x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
INLINE
|
||||
cdevData::operator double( void )
|
||||
{
|
||||
double x; get("value", &x); return x;
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
cdevData::operator char * ( void )
|
||||
{
|
||||
char * result = NULL;
|
||||
static char temp[64];
|
||||
size_t dim = 0;
|
||||
int valueTag = 1;
|
||||
cdevDataTypes dataType = CDEV_INVALID;
|
||||
|
||||
tagC2I("value", &valueTag);
|
||||
getDim(valueTag, &dim);
|
||||
if(dim==0) dataType = getType(valueTag);
|
||||
|
||||
switch(dataType)
|
||||
{
|
||||
case CDEV_INVALID:
|
||||
result=NULL;
|
||||
break;
|
||||
|
||||
case CDEV_STRING:
|
||||
find("value", (void * &)result);
|
||||
break;
|
||||
|
||||
default:
|
||||
get("value", temp, 64);
|
||||
result = temp;
|
||||
break;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
cdevData& cdevData::operator= (unsigned char x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
INLINE cdevData& cdevData::operator= (short x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
INLINE cdevData& cdevData::operator= (unsigned short x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
INLINE cdevData& cdevData::operator= (int x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
INLINE cdevData& cdevData::operator= (unsigned int x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
INLINE cdevData& cdevData::operator= (long x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
INLINE cdevData& cdevData::operator= (unsigned long x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
INLINE cdevData& cdevData::operator= (float x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
INLINE cdevData& cdevData::operator= (double x)
|
||||
{
|
||||
insert("value", x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,365 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 1991,1992 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// description: cdevDataEntry.h
|
||||
// This file defines the classes necessary for storage of an individual
|
||||
// tagged data item within a cdevData class object.
|
||||
//
|
||||
// Author: Walt Akers & Danjin Wu
|
||||
//
|
||||
// Revision History:
|
||||
// cdevDataEntry.h,v
|
||||
// Revision 1.9 1996/11/21 17:03:04 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.8 1996/09/20 19:33:12 akers
|
||||
// Changed protection in cdevDataEntryStorage, cdevDataEntry and cdevData in order to support subclassing of the cdevData object
|
||||
//
|
||||
// Revision 1.7 1996/08/23 21:24:25 akers
|
||||
// Corrected Problem with operator ==
|
||||
//
|
||||
// Revision 1.6 1996/08/23 15:34:09 akers
|
||||
// Added comparison operator to cdevData
|
||||
//
|
||||
// Revision 1.5 1995/10/16 18:13:59 chen
|
||||
// Fix a bug fot sunOs and g++
|
||||
//
|
||||
// Revision 1.4 1995/09/22 21:08:14 danjin
|
||||
// cdevdataIterator is friend class
|
||||
//
|
||||
// Revision 1.3 1995/09/06 18:34:49 danjin
|
||||
// added time stamp structure type
|
||||
//
|
||||
// Revision 1.2 1995/07/14 13:25:30 akers
|
||||
// Header files added to support the changes specified at June 95 Review
|
||||
//
|
||||
//
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef __CDEV_DATA_ENTRY_H_
|
||||
#define __CDEV_DATA_ENTRY_H_
|
||||
|
||||
#include <string.h>
|
||||
#include <cdevTypes.h>
|
||||
|
||||
// #############################################################################
|
||||
// # cdevDataEntryStorage:
|
||||
// # This class contains the data elements and methods necessary to store data
|
||||
// # associated with one tagged data item.
|
||||
// #
|
||||
// # Note: Because the cdevData object must actively manipulate the data in
|
||||
// # this structure - it has been made public to increase access speed
|
||||
// # and to allow the subclassing of the cdevData object.
|
||||
// #############################################################################
|
||||
class cdevDataEntryStorage
|
||||
{
|
||||
public:
|
||||
// *************************************************************
|
||||
// * tag_:
|
||||
// * This is the integer value that is used to uniquely identify
|
||||
// * a data element within a cdevData object.
|
||||
// *************************************************************
|
||||
int tag_;
|
||||
|
||||
// *************************************************************
|
||||
// * dataType_:
|
||||
// * This is the data type of the tagged data item that is to be
|
||||
// * stored in this cdevDataEntryStorage object.
|
||||
// *************************************************************
|
||||
cdevDataTypes dataType_;
|
||||
|
||||
// *************************************************************
|
||||
// * size_:
|
||||
// * This variable is the allocated size of the buffer_ which is
|
||||
// * used to store both the array data and its associated bounds
|
||||
// * information.
|
||||
// *************************************************************
|
||||
size_t size_;
|
||||
|
||||
// *************************************************************
|
||||
// * dim_:
|
||||
// * This variable indicates the user specified number of
|
||||
// * dimensions that the array represents.
|
||||
// *************************************************************
|
||||
size_t dim_;
|
||||
|
||||
// *************************************************************
|
||||
// * elems_:
|
||||
// * This variable contains the maximum number of elements that
|
||||
// * the array may contain.
|
||||
// *************************************************************
|
||||
size_t elems_;
|
||||
|
||||
// *************************************************************
|
||||
// * bytes_:
|
||||
// * This variable contains the number of bytes per element.
|
||||
// *************************************************************
|
||||
size_t bytes_;
|
||||
|
||||
// *************************************************************
|
||||
// * buffer_:
|
||||
// * This is the buffer that is allocated to store data and
|
||||
// * bounds information.
|
||||
// *************************************************************
|
||||
unsigned char * buffer_;
|
||||
|
||||
// *************************************************************
|
||||
// * data_:
|
||||
// * This is a union that is used to store scalar data and a
|
||||
// * pointer to the array data this is stored within this object
|
||||
// *************************************************************
|
||||
union dataUnion {
|
||||
BYTE cval;
|
||||
short sval;
|
||||
unsigned short usval;
|
||||
long lval;
|
||||
unsigned long ulval;
|
||||
float fval;
|
||||
double dval;
|
||||
void * vptr;
|
||||
BYTE * cptr;
|
||||
short * sptr;
|
||||
unsigned short * usptr;
|
||||
long * lptr;
|
||||
unsigned long * ulptr;
|
||||
float * fptr;
|
||||
double * dptr;
|
||||
char * str;
|
||||
char ** strarr;
|
||||
cdev_TS_STAMP ts;
|
||||
cdev_TS_STAMP * tsptr;
|
||||
} data_;
|
||||
|
||||
// *************************************************************
|
||||
// * cdevDataEntryStorage:
|
||||
// * Default constructor for the cdevDataEntryStorage class. It sets
|
||||
// * the buffer_ pointer to NULL to prevent deletion of non-
|
||||
// * allocated memory, and then calls the clear method to
|
||||
// * initialize all data variables.
|
||||
// *************************************************************
|
||||
cdevDataEntryStorage ( void ) : buffer_(NULL)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * ~cdevDataEntryStorage:
|
||||
// * Default destructor for the cdevDaaEntry class. It calls
|
||||
// * the clear method to release and reinitialize all data
|
||||
// * elements.
|
||||
// *************************************************************
|
||||
~cdevDataEntryStorage ( void )
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * clear:
|
||||
// * Releases and reinitializes all data variables.
|
||||
// *************************************************************
|
||||
void clear ( void )
|
||||
{
|
||||
deallocate();
|
||||
tag_ = 0;
|
||||
dataType_ = CDEV_INVALID;
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * allocate:
|
||||
// * Allocates a block of memory sufficient to store a caller
|
||||
// * specified number of cdevBounds structures and a caller
|
||||
// * specified number of bytes. If sufficient space has already
|
||||
// * been allocated, then it will be used, otherwise, a new
|
||||
// * block will be created to service the request.
|
||||
// *************************************************************
|
||||
void allocate ( size_t dimensions, size_t elems, size_t bytesPerElem )
|
||||
{
|
||||
size_t newBlockSize =
|
||||
(dimensions*sizeof(cdevBounds))+(elems * bytesPerElem);
|
||||
|
||||
if(buffer_==NULL || newBlockSize>size_)
|
||||
{
|
||||
deallocate();
|
||||
buffer_ = ::new unsigned char[newBlockSize];
|
||||
size_ = newBlockSize;
|
||||
}
|
||||
dim_ = dimensions;
|
||||
elems_ = elems;
|
||||
bytes_ = bytesPerElem;
|
||||
data_.vptr = &buffer_[dim_ * sizeof(cdevBounds)];
|
||||
memset (buffer_, 0, newBlockSize);
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * deallocate:
|
||||
// * Deallocates any memory previously allocated to the buffer
|
||||
// * and reinitializes the size_, dim_, bytes_ and buffer_
|
||||
// * variables. Any references to the previously allocated
|
||||
// * block is cleared.
|
||||
// *************************************************************
|
||||
void deallocate ( void )
|
||||
{
|
||||
if(buffer_ != NULL)
|
||||
{
|
||||
::delete buffer_;
|
||||
buffer_ = NULL;
|
||||
}
|
||||
size_ = 0;
|
||||
dim_ = 0;
|
||||
elems_ = 0;
|
||||
bytes_ = 0;
|
||||
data_.dval = 0.00;
|
||||
// memset(&data_, 0, sizeof(data_));
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * bounds:
|
||||
// * Returns a pointer to the cdevBounds object if the data
|
||||
// * is multidimensional, otherwise, a NULL is returned.
|
||||
// *************************************************************
|
||||
cdevBounds * bounds ( void )
|
||||
{
|
||||
return (dim_>0)?(cdevBounds *)buffer_:(cdevBounds *)0;
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * operator ==:
|
||||
// * This operator allows you to directly and rapidly
|
||||
// * compare two cdevDataEntryStorage objects...
|
||||
// *************************************************************
|
||||
int operator == (cdevDataEntryStorage & entry);
|
||||
|
||||
// *************************************************************
|
||||
// * operator !=:
|
||||
// * This operator allows the caller to directly and rapidly
|
||||
// * comapre two cdevDataEntryStorage objects.
|
||||
// *************************************************************
|
||||
int operator != (cdevDataEntryStorage & entry)
|
||||
{
|
||||
return !(operator == (entry));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// #############################################################################
|
||||
// # cdevDataEntry:
|
||||
// # This class is used to define the node attributes necessary to support
|
||||
// # linked lists of cdevDataEntryStorage objects. It also provides an internal
|
||||
// # freelist of cdevDataEntry objects.
|
||||
// #
|
||||
// # Note: Because the cdevData object must actively manipulate the data in
|
||||
// # this structure - it has been made public to increase access speed
|
||||
// # and to allow the subclassing of the cdevData object.
|
||||
// #############################################################################
|
||||
class cdevDataEntry : public cdevDataEntryStorage
|
||||
{
|
||||
public:
|
||||
// *************************************************************
|
||||
// * freeList_:
|
||||
// * This is a pointer to a list of currently allocated
|
||||
// * cdevDataEntrys that will be provided to the user
|
||||
// * upon request. This technique should reduce the number of
|
||||
// * mallocs called to allocated cdevDataEntrys.
|
||||
// *************************************************************
|
||||
static cdevDataEntry * freeList_;
|
||||
|
||||
// *************************************************************
|
||||
// * ALLOCATION_COUNT:
|
||||
// * This is the minimum number of cdevDataEntrys that will
|
||||
// * be allocated when the freeList_ becomes empty.
|
||||
// *************************************************************
|
||||
enum { ALLOCATION_COUNT = 16 };
|
||||
|
||||
// *************************************************************
|
||||
// * next_ :
|
||||
// * This is the pointer to the next element in the list of
|
||||
// * cdevDataEntry objects.
|
||||
// *************************************************************
|
||||
cdevDataEntry * next_;
|
||||
|
||||
// *************************************************************
|
||||
// * cdevDataEntry:
|
||||
// * Constructor for the class. It serves only to set the next_
|
||||
// * pointer to NULL.
|
||||
// *************************************************************
|
||||
cdevDataEntry ( void ) : next_(NULL), cdevDataEntryStorage()
|
||||
{
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * ~cdevDataEntry:
|
||||
// * Destructor for the class. It is a placeholder that
|
||||
// * does nothing when called.
|
||||
// *************************************************************
|
||||
~cdevDataEntry ( void )
|
||||
{
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * next:
|
||||
// * Retrieves a pointer to the next_ cdevDataEntry object.
|
||||
// * Incorporation of this function into a list object is the
|
||||
// * responsibility of the caller.
|
||||
// *************************************************************
|
||||
cdevDataEntry * &next ( void )
|
||||
{
|
||||
return next_;
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * new:
|
||||
// * Allocation function for the object. It will get the next
|
||||
// * preallocated cdevDataEntry object from the freeList_,
|
||||
// * or, if none are available, refill the freeList_ and then
|
||||
// * return a new cdevDataEntry object.
|
||||
// *************************************************************
|
||||
void * operator new ( size_t size );
|
||||
|
||||
// *************************************************************
|
||||
// * delete:
|
||||
// * Rather than deallocating the cdevDataEntry object, this
|
||||
// * function returns it to the freeList_ where it may be
|
||||
// * retrieved by a later call of new.
|
||||
// *************************************************************
|
||||
void operator delete ( void * ptr )
|
||||
{
|
||||
cdevDataEntry * node = (cdevDataEntry *)ptr;
|
||||
if(node != NULL) {
|
||||
node->next_ = freeList_;
|
||||
freeList_ = node;
|
||||
}
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * operator ==:
|
||||
// * This operator allows you to directly and rapidly
|
||||
// * compare two cdevDataEntry objects...
|
||||
// *************************************************************
|
||||
int operator == (cdevDataEntry & entry)
|
||||
{
|
||||
cdevDataEntryStorage *storage = &entry;
|
||||
|
||||
return cdevDataEntryStorage::operator == (*storage);
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// * operator !=:
|
||||
// * This operator allows the caller to directly and rapidly
|
||||
// * comapre two cdevDataEntry objects.
|
||||
// *************************************************************
|
||||
int operator != (cdevDataEntry & entry)
|
||||
{
|
||||
cdevDataEntryStorage *storage = &entry;
|
||||
return !(cdevDataEntryStorage::operator == (*storage));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /* __CDEV_DATA_ENTRY_H_ */
|
||||
@@ -0,0 +1,192 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* cdevDefCollectionRequest.h : This is the default class that will be used
|
||||
* to support collection operations for services.
|
||||
*
|
||||
* Author: Walt Akers
|
||||
*
|
||||
* Revision History:
|
||||
* cdevDefCollectionRequest.h,v
|
||||
* Revision 1.2 1998/10/22 17:57:41 chen
|
||||
* fix a bug on setting collection values
|
||||
*
|
||||
* Revision 1.1 1996/11/12 20:32:25 akers
|
||||
* New collection device source code
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef _CDEV_DEF_COLLECTION_REQUEST_H
|
||||
#define _CDEV_DEF_COLLECTION_REQUEST_H
|
||||
|
||||
#include <cdevCollectionRequest.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevDefCollectionRequest: public cdevCollectionRequest
|
||||
{
|
||||
friend class cdevCollectionRequest;
|
||||
friend class cdevService;
|
||||
|
||||
public:
|
||||
// *********************************************************************
|
||||
// * This structure is provided as the void * argument to the default
|
||||
// * callback whenever the synchronous send is used. The checkSum is
|
||||
// * used to detect if the result returned after the send method stopped
|
||||
// * waiting for it.
|
||||
// *********************************************************************
|
||||
typedef struct
|
||||
{
|
||||
int completionCode;
|
||||
int finished;
|
||||
cdevData *data;
|
||||
} SendStatus;
|
||||
|
||||
// *********************************************************************
|
||||
// * These methods get state and access information for the underlying
|
||||
// * cdevRequestObjects.
|
||||
// *********************************************************************
|
||||
virtual int getState (void);
|
||||
virtual int getAccess (void);
|
||||
|
||||
// *********************************************************************
|
||||
// * This method sets the context of each of the underlying
|
||||
// * cdevRequestObjects.
|
||||
// *********************************************************************
|
||||
virtual int setContext (cdevData &ctx);
|
||||
|
||||
// *********************************************************************
|
||||
// * cdevClientRequestObject::send :
|
||||
// * The send interface is used to provide synchronous I/O with the
|
||||
// * service.
|
||||
// *
|
||||
// * Returns CDEV_SUCCESS on success or CDEV_ERROR on error.
|
||||
// *********************************************************************
|
||||
virtual int send ( cdevData & in, cdevData & out )
|
||||
{ return send(&in, &out); }
|
||||
virtual int send ( cdevData * in, cdevData & out )
|
||||
{ return send(in, &out); }
|
||||
virtual int send ( cdevData & in, cdevData * out )
|
||||
{ return send(&in, out); }
|
||||
virtual int send ( cdevData * in, cdevData * out );
|
||||
|
||||
// *********************************************************************
|
||||
// * sendNoBlock :
|
||||
// * The sendNoBlock interface is used in conjunction with cdevGroup
|
||||
// * or cdevSystem to execute a series of operations.
|
||||
// *
|
||||
// * Returns CDEV_SUCCESS on success or CDEV_ERROR on error.
|
||||
// *********************************************************************
|
||||
virtual int sendNoBlock (cdevData & in, cdevData & out)
|
||||
{ return sendNoBlock(&in, &out); }
|
||||
virtual int sendNoBlock (cdevData * in, cdevData & out)
|
||||
{ return sendNoBlock(in, &out); }
|
||||
virtual int sendNoBlock (cdevData & in, cdevData * out)
|
||||
{ return sendNoBlock(&in, out); }
|
||||
virtual int sendNoBlock (cdevData * in, cdevData * out);
|
||||
|
||||
// *********************************************************************
|
||||
// * sendCallback :
|
||||
// * The sendCallback interface provides asynchronous communications
|
||||
// * with the service.
|
||||
// *
|
||||
// * Returns CDEV_SUCCESS on success or CDEV_ERROR on error.
|
||||
// *********************************************************************
|
||||
virtual int sendCallback (cdevData & in, cdevCallback & callback)
|
||||
{ return sendCallback(&in, callback); }
|
||||
virtual int sendCallback (cdevData * in, cdevCallback & callback);
|
||||
|
||||
// *********************************************************************
|
||||
// * This method returns the name of the class.
|
||||
// *********************************************************************
|
||||
const char *className (void) const {return "cdevDefCollectionRequest";}
|
||||
|
||||
protected:
|
||||
// *********************************************************************
|
||||
// * These are the protected constructor and destructor for this object.
|
||||
// *********************************************************************
|
||||
cdevDefCollectionRequest (char **devices, int nDevices, char *msg, cdevSystem& sys);
|
||||
virtual ~cdevDefCollectionRequest (void);
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the syncCallback method. It will be used by the send
|
||||
// * method in order to detect the completion of the operation.
|
||||
// *********************************************************************
|
||||
static void syncCallback (int status, void * user, cdevRequestObject &, cdevData &data);
|
||||
|
||||
// *********************************************************************
|
||||
// * This callback function is used to receive the individual callbacks
|
||||
// * from the underlying cdevRequestObjects and is used by sendCallback.
|
||||
// *********************************************************************
|
||||
static void asyncCallback (int, void *, cdevRequestObject &, cdevData &);
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the asyncNoBlockCallback method. It will be used by the
|
||||
// * sendNoBlock method in order to detect the completion of the
|
||||
// * operation.
|
||||
// *********************************************************************
|
||||
static void asyncNoBlockCallback (int status, void * user, cdevRequestObject &, cdevData &data);
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// * This is routine set scaler value to array of cdevData with a
|
||||
// * specified tag
|
||||
// *********************************************************************
|
||||
static int setScalerDataValue (cdevData& data, int tag,
|
||||
cdevData* res, int num);
|
||||
|
||||
// *********************************************************************
|
||||
// * This is routine set vector value to array of cdevData with a
|
||||
// * specified tag
|
||||
// *********************************************************************
|
||||
static int setVectorDataValue (cdevData& data, int tag, size_t dim,
|
||||
cdevData* res, int num);
|
||||
|
||||
// *********************************************************************
|
||||
// * This is routine split a input cdevData into an array of cdevData.
|
||||
// * The input data is either a scaler value which will be duplicated
|
||||
// * to all splited data values, or a array of data whose bound[0].length
|
||||
// * must be the same as the 'num'. This works for a single tag
|
||||
// *********************************************************************
|
||||
static int splitDataItem (cdevData& data, int tag,
|
||||
cdevData* res, int num);
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
// * This is routine split a input cdevData into an array of cdevData.
|
||||
// * The input data is either a scaler value which will be duplicated
|
||||
// * to all splited data values, or a array of data whose bound[0].length
|
||||
// * must be the same as the 'num'
|
||||
// * caller must free return cdevData array if it is not zero.
|
||||
// *********************************************************************
|
||||
static cdevData *splitData (cdevData& data, int splitnum);
|
||||
|
||||
private:
|
||||
static SendStatus sendStatus;
|
||||
static int sendCheckSum;
|
||||
|
||||
// *********************************************************************
|
||||
// * These are the cdevRequestObjects that are addressed by each call
|
||||
// * to this cdevDefCollectionRequest. The nRequests variable contains
|
||||
// * the number of cdevRequestObjects that are represented.
|
||||
// *********************************************************************
|
||||
cdevRequestObject **requests;
|
||||
int nRequests;
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the master data structure. It contains no actual data,
|
||||
// * however, it identifies the data structure that should exist when
|
||||
// * the request has been executed.
|
||||
// *
|
||||
// * This structure is inspected and updated at the completion of each
|
||||
// * callback, and is used to initially create the cdevData objects that
|
||||
// * are used for interim data storage.
|
||||
// *********************************************************************
|
||||
cdevData format;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,161 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevDevice: a virtual control device
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevDevice.h,v
|
||||
// Revision 1.4 1996/11/21 17:03:13 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.3 1995/07/05 18:39:43 chen
|
||||
// change interface
|
||||
//
|
||||
// Revision 1.2 1995/06/30 15:59:27 chen
|
||||
// remove all unnecessary files
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:06 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_DEVICE_H
|
||||
#define _CDEV_DEVICE_H
|
||||
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevSlist.h>
|
||||
#include <cdevSystem.h>
|
||||
#include <cdevData.h>
|
||||
#include <cdevCallback.h>
|
||||
#include <cdevIOcontext.h>
|
||||
|
||||
class cdevRequestObject;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevDevice: public cdevIOcontext
|
||||
{
|
||||
public:
|
||||
//===================================================================
|
||||
// Public Interface for Clients
|
||||
//===================================================================
|
||||
static cdevDevice& attachRef (char *name);
|
||||
static cdevDevice* attachPtr (char *name);
|
||||
// PURPOSE: create a reference or pointer for device of a given name
|
||||
// within the default system
|
||||
// REQUIRE: name != 0
|
||||
// PROMISE: a cdevDevice
|
||||
|
||||
static void detach (cdevDevice& dev);
|
||||
static void detach (cdevDevice* dev);
|
||||
// PURPOSE: destroy a cdevDevice
|
||||
// REQUIRE: dev != 0
|
||||
// PROMISE: memory will be freed if no more attachment on this device
|
||||
|
||||
const char *name (void) const;
|
||||
// PURPOSE: return device name
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: a name
|
||||
|
||||
cdevSystem& system (void) const;
|
||||
// PURPOSE: return system associated with this device
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return reference of the system
|
||||
|
||||
virtual int send (char *msg, cdevData &out, cdevData& result);
|
||||
virtual int send (char *msg, cdevData *out, cdevData& result);
|
||||
virtual int send (char *msg, cdevData &out, cdevData* result);
|
||||
virtual int send (char *msg, cdevData *out, cdevData* result);
|
||||
// PURPOSE: synchronous IO operations
|
||||
// REQUIRE: when set, provide out, when get, provide result
|
||||
// PROMISE: return CDEV_SUCCESS: success. Check cdevErrCode.h for error info
|
||||
|
||||
virtual int sendNoBlock (char *msg, cdevData &out, cdevData &result);
|
||||
virtual int sendNoBlock (char *msg, cdevData *out, cdevData &result);
|
||||
virtual int sendNoBlock (char *msg, cdevData &out, cdevData *result);
|
||||
virtual int sendNoBlock (char *msg, cdevData *out, cdevData *result);
|
||||
// PURPOSE: asynchronous IO operations
|
||||
// REQUIRE: same as the above and one may use cdevGroup to group these
|
||||
// PROMISE: return CDEV_SUCCESS: success. Check cdevErrCode.h for error info
|
||||
|
||||
virtual int sendCallback (char *msg, cdevData &out, cdevCallback &callback);
|
||||
virtual int sendCallback (char *msg, cdevData *out, cdevCallback &callback);
|
||||
// PURPOSE: asynchronous IO operations with user supplied callback function
|
||||
// REQUIRE: out != 0
|
||||
// PROMISE: return CDEV_SUCCESS: request sendout success.
|
||||
// check cdevErrCode.h for error info
|
||||
|
||||
// setIOcontext function, pass cxt to requestObject int the list
|
||||
virtual int setContext (cdevData& cxt);
|
||||
// PURPOSE: set context to this device
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: always return 0, set constext to all request objects
|
||||
// in this device
|
||||
|
||||
//========================================================================
|
||||
// Public Interface for cdevRequestObject
|
||||
//========================================================================
|
||||
virtual cdevRequestObject* getRequestObject (char *msg);
|
||||
// PURPOSE: get a requestObject based on message 'msg'
|
||||
// REQUIRE: msg != 0
|
||||
// PROMISE: return a pointer to requestObject
|
||||
|
||||
virtual int getRequestObject (char *msg, cdevRequestObject* &reqobj);
|
||||
// PURPOSE: get right requestObject
|
||||
// REQUIRE: msg != 0, callers provide pointer only.
|
||||
// PROMISE: always return CDEV_SUCCESS. reqobj may be an errorRequestObject
|
||||
|
||||
virtual int registerReqObject (cdevRequestObject *obj);
|
||||
// PURPOSE: register a requestObject into this device
|
||||
// REQUIRE: obj != 0
|
||||
// PROMISE: return CDEV_SUCCESS: success, CDEV_ERROR: already here
|
||||
|
||||
virtual int removeReqObject (cdevRequestObject *obj);
|
||||
// PURPOSE: remove a requestObject from the device
|
||||
// REQUIRE: obj != 0
|
||||
// PROMISE: return CDEV_SUCCESS: success, CDEV_ERROR: not here
|
||||
|
||||
virtual const char *className (void) const {return "cdevDevice";}
|
||||
|
||||
protected:
|
||||
//constructors and destructor
|
||||
cdevDevice (char *name, cdevSystem& system = cdevSystem::defaultSystem() );
|
||||
virtual ~cdevDevice (void);
|
||||
|
||||
// attach pointer or reference with system as second argument
|
||||
// protected to prevent application from using multiple systems
|
||||
static cdevDevice& attachRef (char *name, cdevSystem& system);
|
||||
static cdevDevice* attachPtr (char *name, cdevSystem& system);
|
||||
// PURPOSE: create a reference or pointer for device of a given name
|
||||
// REQUIRE: name != 0
|
||||
// PROMISE: a cdevDevice
|
||||
|
||||
cdevRequestObject* findRequestObject(char *msg);
|
||||
// PURPOSE: find an existing requestObject
|
||||
// REQUIRE: name != 0, callers provide pointer only.
|
||||
// PROMISE: return valid request object or NULL if not found
|
||||
|
||||
// Protected data items
|
||||
char *deviceName_;
|
||||
cdevSystem& system_;
|
||||
cdevSlist reqObjList_;
|
||||
int unregOn_; // unregister self from system on delete
|
||||
int refCount_;
|
||||
|
||||
private:
|
||||
// hide assignment and copy operator since the device is
|
||||
// a memory manager for requestObject
|
||||
cdevDevice& operator = (const cdevDevice &);
|
||||
cdevDevice (const cdevDevice &);
|
||||
|
||||
// friend class declaration
|
||||
friend class cdevSystem;
|
||||
friend class cdevRequestObject;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,134 @@
|
||||
#ifndef _CDEV_DEVICE_DEFINITION_H_
|
||||
#define _CDEV_DEVICE_DEFINITION_H_
|
||||
|
||||
#ifndef _CDEV_DIRECTORY_TABLE_H_
|
||||
#error "You must include cdevDirectoryTable.h to load cdevDeviceDefinition.h"
|
||||
#endif
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevDeviceDefinition :
|
||||
// * This class stores information that identifies a specific device name
|
||||
// * and associates it with a class.
|
||||
// *
|
||||
// * This class maintains a variety of internal data items for the following
|
||||
// * purposes...
|
||||
// *
|
||||
// * name - This is the name of the device as specified in the DDL file.
|
||||
// * directory - This is the cdevDirectoryTable object where the device was
|
||||
// * registered.
|
||||
// * cdevClass - This is the definition object for the class that the device
|
||||
// * belongs to.
|
||||
// * next - This is the next device in the linked list of cdevDevice
|
||||
// * Definition objects. This list is maintained as part of the
|
||||
// * cdevClassDefinition object.
|
||||
// *****************************************************************************
|
||||
class cdevDeviceDefinition
|
||||
{
|
||||
private:
|
||||
char * name;
|
||||
char * substName;
|
||||
class cdevDirectoryTable & directory;
|
||||
class cdevClassDefinition & cdevClass;
|
||||
cdevDeviceDefinition * next;
|
||||
|
||||
public:
|
||||
inline cdevDeviceDefinition ( cdevDirectoryTable & Directory,
|
||||
char * Name,
|
||||
char * SubstName,
|
||||
cdevClassDefinition & CdevClass );
|
||||
inline ~cdevDeviceDefinition ( void );
|
||||
|
||||
// *********************************************************************
|
||||
// * Member access methods.
|
||||
// *********************************************************************
|
||||
inline char * getName ( void );
|
||||
inline char * getSubstituteName ( void );
|
||||
inline cdevDirectoryTable & getDirectory ( void );
|
||||
inline cdevClassDefinition & getClass ( void );
|
||||
inline cdevDeviceDefinition * getNext ( void );
|
||||
inline void setNext ( cdevDeviceDefinition * Next );
|
||||
};
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDeviceDefinition::cdevDeviceDefinition :
|
||||
// * This is the constructor for the cdevDeviceDefinition class.
|
||||
// *****************************************************************************
|
||||
inline cdevDeviceDefinition::cdevDeviceDefinition
|
||||
( cdevDirectoryTable & Directory,
|
||||
char * Name,
|
||||
char * SubstName,
|
||||
cdevClassDefinition & CdevClass )
|
||||
: directory(Directory), next(NULL), name(Name),
|
||||
substName(SubstName), cdevClass(CdevClass)
|
||||
{
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDeviceDefinition::~cdevDeviceDefinition :
|
||||
// * This is the destructor for the cdevDeviceDefinition class.
|
||||
// *****************************************************************************
|
||||
inline cdevDeviceDefinition::~cdevDeviceDefinition ( void )
|
||||
{
|
||||
if(name) delete name;
|
||||
if(substName) delete substName;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDeviceDefinition::getName :
|
||||
// * This method allows the caller to retrieve the device name.
|
||||
// *****************************************************************************
|
||||
inline char * cdevDeviceDefinition::getName ( void )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDeviceDefinition::getSubstituteName :
|
||||
// * This method allows the caller to retrieve the device name.
|
||||
// *****************************************************************************
|
||||
inline char * cdevDeviceDefinition::getSubstituteName ( void )
|
||||
{
|
||||
return substName==NULL?name:substName;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDeviceDefinition::getDirectory :
|
||||
// * This method allows the caller to retrieve the directory object that
|
||||
// * owns this device.
|
||||
// *****************************************************************************
|
||||
inline cdevDirectoryTable & cdevDeviceDefinition::getDirectory ( void )
|
||||
{
|
||||
return directory;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDeviceDefinition::getClass :
|
||||
// * This method allows the caller to retrieve the class object that
|
||||
// * owns this device.
|
||||
// *****************************************************************************
|
||||
inline cdevClassDefinition & cdevDeviceDefinition::getClass ( void )
|
||||
{
|
||||
return cdevClass;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDeviceDefinition::getNext :
|
||||
// * This method allows the caller to retrieve the next device in the list.
|
||||
// *****************************************************************************
|
||||
inline cdevDeviceDefinition * cdevDeviceDefinition::getNext ( void )
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDeviceDefinition::setNext :
|
||||
// * This method allows the caller to set the next device in the list.
|
||||
// *****************************************************************************
|
||||
inline void cdevDeviceDefinition::setNext ( cdevDeviceDefinition * Next )
|
||||
{
|
||||
next = Next;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevRequestObject for cdevDirectory Class
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevDirRequestObj.h,v
|
||||
// Revision 1.1 1998/02/13 14:01:45 chen
|
||||
// enable request object for cdevDirectory
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_DIR_REQUEST_OBJ_H
|
||||
#define _CDEV_DIR_REQUEST_OBJ_H
|
||||
|
||||
#include <cdevSystem.h>
|
||||
#include <cdevDevice.h>
|
||||
#include <cdevRequestObject.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevDirRequestObj: public cdevRequestObject
|
||||
{
|
||||
public:
|
||||
// constructor and destructor
|
||||
cdevDirRequestObj (cdevDevice& device, char* msg,
|
||||
cdevSystem& system = cdevSystem::defaultSystem ());
|
||||
|
||||
~cdevDirRequestObj (void);
|
||||
|
||||
int send (cdevData& out, cdevData& result);
|
||||
int send (cdevData *out, cdevData& result);
|
||||
int send (cdevData& out, cdevData* result);
|
||||
int send (cdevData *out, cdevData* result);
|
||||
|
||||
|
||||
int sendNoBlock (cdevData& out, cdevData& result);
|
||||
int sendNoBlock (cdevData* out, cdevData& result);
|
||||
int sendNoBlock (cdevData& out, cdevData* result);
|
||||
int sendNoBlock (cdevData* out, cdevData* result);
|
||||
|
||||
int sendCallback (cdevData& out, cdevCallback& callback);
|
||||
int sendCallback (cdevData* out, cdevCallback& callback);
|
||||
|
||||
const char *className (void) const {return "cdevDirRequestObj";}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
#ifndef _CDEV_DIRECTORY_H
|
||||
#define _CDEV_DIRECTORY_H
|
||||
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevData.h>
|
||||
#include <cdevCallback.h>
|
||||
#include <cdevDevice.h>
|
||||
|
||||
class cdevDirectoryTable;
|
||||
class StringHash;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevDirectory : public cdevDevice
|
||||
{
|
||||
public:
|
||||
cdevDirectory(cdevSystem &system=cdevSystem::defaultSystem());
|
||||
~cdevDirectory(void);
|
||||
|
||||
int addNameSvc(cdevDevice *svc);
|
||||
int removeNameSvc(cdevDevice *svc);
|
||||
|
||||
int send(char *msg, cdevData &data, cdevData &result);
|
||||
int send(char *msg, cdevData *data, cdevData &result);
|
||||
int send(char *msg, cdevData &data, cdevData *result);
|
||||
int send(char *msg, cdevData *data, cdevData *result);
|
||||
|
||||
int sendNoBlock(char *msg, cdevData &out, cdevData &result);
|
||||
int sendNoBlock(char *msg, cdevData *out, cdevData &result);
|
||||
int sendNoBlock(char *msg, cdevData &out, cdevData *result);
|
||||
int sendNoBlock(char *msg, cdevData *out, cdevData *result);
|
||||
|
||||
int sendCallback(char *msg, cdevData &out, cdevCallback &callback);
|
||||
int sendCallback(char *msg, cdevData *out, cdevCallback &callback);
|
||||
|
||||
cdevRequestObject *getRequestObject (char *msg);
|
||||
int getRequestObject (char *msg, cdevRequestObject* &reqobj);
|
||||
|
||||
virtual const char *className(void) const { return "cdevDirectory"; }
|
||||
|
||||
private:
|
||||
typedef int (*QueryFunction) ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
|
||||
static int query ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int queryClass ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int queryClasses ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int queryCollection ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int queryVerbs ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int queryAttributes ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int queryMessages ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int service ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int resolveService ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int serviceData ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int resolveServiceData ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int validate ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int update ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int writeAscii ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
static int writeBinary ( cdevDirectory &dir,
|
||||
char * msg, cdevData *in, cdevData *out );
|
||||
|
||||
class cdevDirectoryNode
|
||||
{
|
||||
public:
|
||||
cdevDirectoryNode ( cdevDevice * svc = NULL ) : next(NULL), device(svc) {}
|
||||
~cdevDirectoryNode( void ) {}
|
||||
cdevDirectoryNode * next;
|
||||
cdevDevice * device;
|
||||
};
|
||||
|
||||
cdevDirectoryNode * node;
|
||||
class cdevDirectoryTable * table;
|
||||
class StringHash * commandHash;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,722 @@
|
||||
#ifndef _CDEV_DIRECTORY_TABLE_H_
|
||||
#define _CDEV_DIRECTORY_TABLE_H_
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cdevSystem.h>
|
||||
#include <cdevErrCode.h>
|
||||
#include <cdevError.h>
|
||||
#include <StringHash.h>
|
||||
|
||||
#ifdef __VMS
|
||||
typedef unsigned long u_long;
|
||||
typedef unsigned short u_short;
|
||||
#endif
|
||||
|
||||
|
||||
class cdevElementDefinition;
|
||||
class cdevClassDefinition;
|
||||
class cdevServiceDefinition;
|
||||
class cdevAliasDefinition;
|
||||
class cdevDeviceDefinition;
|
||||
class cdevCollectionDefinition;
|
||||
|
||||
int CDEV_CLASS_SPEC cdevReportError(int severity, char *name, void *, char *formatString, ...);
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevDirectoryTable :
|
||||
// * This is the master class that is used to collect and maintain
|
||||
// * information associated with the CDEV Device Definition Language file.
|
||||
// *
|
||||
// * This class maintains a number of tables and lists for the following
|
||||
// * purposes...
|
||||
// *
|
||||
// * collectionClass - This is the single instance of the cdevClassDefinition
|
||||
// * for the collection class.
|
||||
// *
|
||||
// * serviceHead - This is a list of all of the services that have been
|
||||
// * serviceTail read from the DDL file in the order in which they
|
||||
// * were loaded.
|
||||
// *
|
||||
// * classHead - This is a list of all of the classes that have been
|
||||
// * classTail read from the DDL file in the order in which they
|
||||
// * were loaded.
|
||||
// *
|
||||
// * aliasHead - This is a list of aliases that are defined within
|
||||
// * aliasTail the DDL file.
|
||||
// *
|
||||
// * collectionHead - This is a list of collection devices that are
|
||||
// * collectionTail defined within the DDL file.
|
||||
// *
|
||||
// * serviceHash - This is a hash table that allows for fast lookup of
|
||||
// * each of the services that were loaded into the
|
||||
// * service list.
|
||||
// *
|
||||
// * classHash - This is a hash table that allows fast lookup by name
|
||||
// * of any of the classes that were loaded into the
|
||||
// * class list.
|
||||
// *
|
||||
// * classInstanceHash - This is a hash table that contains only the names
|
||||
// * and addresses of classes that have been used to
|
||||
// * instanciate a device.
|
||||
// *
|
||||
// * deviceHash - This is a hash table that allows the caller to
|
||||
// * quickly locate any device that has been defined in
|
||||
// * the DDL file.
|
||||
// *
|
||||
// * collectionHash - This is a hash table that allows the caller to
|
||||
// * quickly locate a collection device definition.
|
||||
// *****************************************************************************
|
||||
class CDEV_CLASS_SPEC cdevDirectoryTable
|
||||
{
|
||||
public:
|
||||
static long BinaryMagic_1_4;
|
||||
static long BinaryMagic_1_5;
|
||||
static long BinaryMagic;
|
||||
|
||||
typedef enum {VERB=0, ATTRIBUTE, MESSAGE} ElementType;
|
||||
|
||||
private:
|
||||
cdevClassDefinition * collectionClass;
|
||||
|
||||
cdevServiceDefinition * serviceHead;
|
||||
cdevServiceDefinition * serviceTail;
|
||||
cdevClassDefinition * classHead;
|
||||
cdevClassDefinition * classTail;
|
||||
cdevAliasDefinition * aliasHead;
|
||||
cdevAliasDefinition * aliasTail;
|
||||
cdevCollectionDefinition * collectionHead;
|
||||
cdevCollectionDefinition * collectionTail;
|
||||
StringHash serviceHash;
|
||||
StringHash classHash;
|
||||
StringHash classInstanceHash;
|
||||
StringHash deviceHash;
|
||||
StringHash collectionHash;
|
||||
|
||||
public:
|
||||
inline cdevDirectoryTable ( void );
|
||||
inline ~cdevDirectoryTable ( void );
|
||||
|
||||
inline int addService ( cdevServiceDefinition *def );
|
||||
inline int addService ( char *name,
|
||||
char **tags=NULL,
|
||||
int nTags=0);
|
||||
|
||||
inline int addClass ( cdevClassDefinition *def );
|
||||
inline int addClass ( char *name,
|
||||
cdevClassDefinition *parent = NULL,
|
||||
cdevElementDefinition *verbs = NULL,
|
||||
cdevElementDefinition *attributes = NULL,
|
||||
cdevElementDefinition *messages = NULL);
|
||||
|
||||
inline int addClassInstance ( cdevClassDefinition * def );
|
||||
inline int addDevice ( cdevDeviceDefinition * def );
|
||||
inline int addAlias ( cdevAliasDefinition * def );
|
||||
inline int addAlias ( char * name, cdevDeviceDefinition & def );
|
||||
inline int addCollection ( cdevCollectionDefinition * def );
|
||||
inline int addCollection ( char * name, char ** devices, int nDevices );
|
||||
|
||||
inline void asciiDump ( FILE * fp = stdout );
|
||||
inline void asciiDumpRedirector ( FILE * fp = stdout );
|
||||
|
||||
inline cdevServiceDefinition * findService ( char * name );
|
||||
inline cdevClassDefinition * findClass ( char * name );
|
||||
|
||||
// *********************************************************************
|
||||
// * Member access methods.
|
||||
// *********************************************************************
|
||||
inline cdevServiceDefinition * getServices ( void );
|
||||
inline cdevClassDefinition * getClasses ( void );
|
||||
inline cdevAliasDefinition * getAliases ( void );
|
||||
inline StringHash & getServiceHash ( void );
|
||||
inline StringHash & getClassHash ( void );
|
||||
inline StringHash & getInstanceHash ( void );
|
||||
inline StringHash & getDeviceHash ( void );
|
||||
inline StringHash & getCollectionHash (void );
|
||||
|
||||
// *********************************************************************
|
||||
// * External data load/dump methods.
|
||||
// *********************************************************************
|
||||
int load ( char * inputFile );
|
||||
int asciiLoad ( char * inputFile );
|
||||
int asciiBufferLoad ( char * buffer );
|
||||
void binaryDump ( char * outputFile );
|
||||
int binaryLoad ( char * inputFile );
|
||||
int loadText ( char * includePath, char * filename, char * &buf, int &buflen, int &cursor);
|
||||
void readServices ( char * buf );
|
||||
void readClasses ( char * buf );
|
||||
void readElements ( cdevClassDefinition &def, ElementType type, char *start, char *end );
|
||||
void readDevices ( char * buf );
|
||||
void readAliases ( char * buf );
|
||||
void readCollections ( char * buf );
|
||||
void compressComments ( char * filename, char * buf );
|
||||
void compressSpaces ( char * filename, char * buf );
|
||||
};
|
||||
|
||||
#include <cdevDeviceDefinition.h>
|
||||
#include <cdevAliasDefinition.h>
|
||||
#include <cdevServiceDefinition.h>
|
||||
#include <cdevElementDefinition.h>
|
||||
#include <cdevRedirectorDefinition.h>
|
||||
#include <cdevClassDefinition.h>
|
||||
#include <cdevCollectionDefinition.h>
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::cdevDirectoryTable :
|
||||
// * Constructor for the cdevDirectoryTable class.
|
||||
// *****************************************************************************
|
||||
inline cdevDirectoryTable::cdevDirectoryTable ( void )
|
||||
: serviceHead(NULL), serviceTail(NULL), classHead(NULL), classTail(NULL),
|
||||
aliasHead(NULL), aliasTail(NULL), collectionHead(NULL),
|
||||
collectionTail(NULL), serviceHash(0), classHash(0),
|
||||
deviceHash(0, 9973), classInstanceHash(0), collectionHash(0)
|
||||
{
|
||||
// *********************************************************************
|
||||
// * Note, by creating a collection class to hold all collection devices
|
||||
// * I am preventing the developer from creating his own collection
|
||||
// * class.
|
||||
// *********************************************************************
|
||||
collectionClass = new cdevClassDefinition(*this, strdup("collection"));
|
||||
addClass(collectionClass);
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::~cdevDirectoryTable :
|
||||
// * This is the destructor for the cdevDirectoryTable class.
|
||||
// *****************************************************************************
|
||||
inline cdevDirectoryTable::~cdevDirectoryTable ( void )
|
||||
{
|
||||
while(serviceHead!=NULL)
|
||||
{
|
||||
cdevServiceDefinition *ptr = serviceHead;
|
||||
serviceHead = ptr->getNext();
|
||||
serviceHash.remove(ptr->getName());
|
||||
delete ptr;
|
||||
}
|
||||
while(classHead!=NULL)
|
||||
{
|
||||
cdevClassDefinition *ptr = classHead;
|
||||
classHead = ptr->getNext();
|
||||
classHash.remove(ptr->getName());
|
||||
classInstanceHash.remove(ptr->getName());
|
||||
delete ptr;
|
||||
}
|
||||
while(aliasHead!=NULL)
|
||||
{
|
||||
cdevAliasDefinition *ptr = aliasHead;
|
||||
aliasHead = ptr->getNext();
|
||||
deviceHash.remove(ptr->getName());
|
||||
delete ptr;
|
||||
}
|
||||
while(collectionHead!=NULL)
|
||||
{
|
||||
cdevCollectionDefinition *ptr = collectionHead;
|
||||
collectionHead = ptr->getNext();
|
||||
collectionHash.remove(ptr->getName());
|
||||
delete ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addService :
|
||||
// * Adds a new service to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addService ( cdevServiceDefinition * def )
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
|
||||
if(def!=NULL && def->getName() && *def->getName())
|
||||
{
|
||||
if(serviceHash.find(def->getName())!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Service \"%s\" is already defined", def->getName());
|
||||
result = CDEV_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceHash.insert(def->getName(), def);
|
||||
if(serviceTail==NULL)
|
||||
{
|
||||
serviceTail = def;
|
||||
serviceHead = def;
|
||||
}
|
||||
else {
|
||||
serviceTail->setNext(def);
|
||||
serviceTail = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addService :
|
||||
// * Adds a new service to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addService ( char * name, char ** tags, int nTags )
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
|
||||
if(name!=NULL && *name)
|
||||
{
|
||||
if(serviceHash.find(name)!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Service \"%s\" is already defined", name);
|
||||
result = CDEV_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
cdevServiceDefinition *def = new cdevServiceDefinition
|
||||
(name, tags, nTags);
|
||||
|
||||
serviceHash.insert(name, def);
|
||||
if(serviceTail==NULL)
|
||||
{
|
||||
serviceTail = def;
|
||||
serviceHead = def;
|
||||
}
|
||||
else {
|
||||
serviceTail->setNext(def);
|
||||
serviceTail = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addClass :
|
||||
// * Adds a new class to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addClass ( cdevClassDefinition * def )
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
if(def!=NULL && def->getName() && *def->getName())
|
||||
{
|
||||
if(classHash.find(def->getName())!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Class \"%s\" is already defined", def->getName());
|
||||
result = CDEV_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
classHash.insert(def->getName(), def);
|
||||
if(classTail==NULL)
|
||||
{
|
||||
classTail = def;
|
||||
classHead = def;
|
||||
}
|
||||
else {
|
||||
classTail->setNext(def);
|
||||
classTail = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addClass :
|
||||
// * Adds a new class to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addClass
|
||||
( char *name,
|
||||
cdevClassDefinition *parent,
|
||||
cdevElementDefinition *verbs,
|
||||
cdevElementDefinition *attributes,
|
||||
cdevElementDefinition *messages)
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
|
||||
if(name!=NULL && *name)
|
||||
{
|
||||
if(classHash.find(name)!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Class \"%s\" is already defined", name);
|
||||
result = CDEV_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
cdevClassDefinition *def = new cdevClassDefinition
|
||||
(*this, name, parent, verbs, attributes, messages);
|
||||
|
||||
classHash.insert(name, def);
|
||||
if(classTail==NULL)
|
||||
{
|
||||
classTail = def;
|
||||
classHead = def;
|
||||
}
|
||||
else {
|
||||
classTail->setNext(def);
|
||||
classTail = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addClassInstance :
|
||||
// * Adds a new class instance to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addClassInstance ( cdevClassDefinition * def )
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
if(def!=NULL && def->getName() && *def->getName())
|
||||
{
|
||||
if(classHash.find(def->getName())==NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Class \"%s\" has not been defined", def->getName());
|
||||
result = CDEV_ERROR;
|
||||
}
|
||||
else if(classInstanceHash.find(def->getName())==NULL)
|
||||
{
|
||||
classInstanceHash.insert(def->getName(), def);
|
||||
}
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addDevice :
|
||||
// * Adds a new device to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addDevice ( cdevDeviceDefinition * def )
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
if(def!=NULL && def->getName()!=NULL && *def->getName())
|
||||
{
|
||||
if(deviceHash.find(def->getName())!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Device \"%s\" has already been defined", def->getName());
|
||||
result = CDEV_ERROR;
|
||||
}
|
||||
else deviceHash.insert(def->getName(), def);
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addAlias :
|
||||
// * Adds a new alias to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addAlias ( cdevAliasDefinition * def )
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
if(def!=NULL && def->getName() && *def->getName())
|
||||
{
|
||||
if(deviceHash.find(def->getName())!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Alias \"%s\" has already been defined", def->getName());
|
||||
result = CDEV_ERROR;
|
||||
}
|
||||
else {
|
||||
if(aliasTail==NULL)
|
||||
{
|
||||
aliasHead = def;
|
||||
aliasTail = def;
|
||||
}
|
||||
else {
|
||||
aliasTail->setNext(def);
|
||||
aliasTail = def;
|
||||
}
|
||||
deviceHash.insert(def->getName(), &def->getDevice());
|
||||
}
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addAlias :
|
||||
// * Adds a new alias to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addAlias
|
||||
( char * name, cdevDeviceDefinition & device )
|
||||
{
|
||||
cdevAliasDefinition *def = new cdevAliasDefinition(name, device);
|
||||
int result = addAlias(def);
|
||||
if(result!=CDEV_SUCCESS) delete def;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addCollection :
|
||||
// * Adds a new collection to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addCollection ( cdevCollectionDefinition * def )
|
||||
{
|
||||
int result = CDEV_SUCCESS;
|
||||
if(def!=NULL && def->getName()!=NULL && *def->getName())
|
||||
{
|
||||
if(deviceHash.find(def->getName())!=NULL ||
|
||||
collectionHash.find(def->getName())!=NULL)
|
||||
{
|
||||
cdevReportError(CDEV_SEVERITY_ERROR, "CDEV Directory", NULL,
|
||||
"Collection device \"%s\" has already been defined", def->getName());
|
||||
result = CDEV_ERROR;
|
||||
}
|
||||
else {
|
||||
if(collectionTail==NULL)
|
||||
{
|
||||
collectionTail = def;
|
||||
collectionHead = def;
|
||||
}
|
||||
else {
|
||||
collectionTail->setNext(def);
|
||||
collectionTail = def;
|
||||
}
|
||||
collectionHash.insert(def->getName(), def);
|
||||
collectionClass->addDevice (strdup(def->getName()));
|
||||
}
|
||||
}
|
||||
else result = CDEV_ERROR;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::addCollection :
|
||||
// * Adds a new collection to the directory table.
|
||||
// *****************************************************************************
|
||||
inline int cdevDirectoryTable::addCollection ( char * name, char ** devices, int nDevices )
|
||||
{
|
||||
int result;
|
||||
|
||||
cdevCollectionDefinition * def =
|
||||
new cdevCollectionDefinition(name, devices, nDevices);
|
||||
|
||||
if((result = addCollection(def))!=CDEV_SUCCESS) delete def;
|
||||
|
||||
return result;
|
||||
}
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::findService :
|
||||
// * Allows the caller to locate a service by name.
|
||||
// *****************************************************************************
|
||||
inline cdevServiceDefinition * cdevDirectoryTable::findService ( char * name )
|
||||
{
|
||||
return (cdevServiceDefinition *)serviceHash.find(name);
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::findClass :
|
||||
// * Allows the caller to locate a class by name.
|
||||
// *****************************************************************************
|
||||
inline cdevClassDefinition * cdevDirectoryTable::findClass ( char * name )
|
||||
{
|
||||
return (cdevClassDefinition *)classHash.find(name);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::asciiDump :
|
||||
// * This method will write the contents of the cdevDirectory object to
|
||||
// * the user provided file pointer.
|
||||
// *****************************************************************************
|
||||
inline void cdevDirectoryTable::asciiDump ( FILE * fp )
|
||||
{
|
||||
cdevServiceDefinition *sPtr = serviceHead;
|
||||
if(sPtr)
|
||||
{
|
||||
fprintf(fp, "\n// ******************************************\n");
|
||||
fprintf(fp, "// * Table of service definitions... *\n");
|
||||
fprintf(fp, "// ******************************************\n");
|
||||
}
|
||||
while(sPtr!=NULL)
|
||||
{
|
||||
sPtr->asciiDump(fp);
|
||||
sPtr = sPtr->getNext();
|
||||
}
|
||||
|
||||
cdevClassDefinition *cPtr = classHead;
|
||||
if(cPtr)
|
||||
{
|
||||
fprintf(fp, "\n// ******************************************\n");
|
||||
fprintf(fp, "// * Table of class definitions... *\n");
|
||||
fprintf(fp, "// ******************************************\n");
|
||||
}
|
||||
while(cPtr!=NULL)
|
||||
{
|
||||
if(cPtr!=collectionClass) cPtr->asciiDump(fp);
|
||||
cPtr = cPtr->getNext();
|
||||
}
|
||||
|
||||
cPtr = classHead;
|
||||
if(cPtr)
|
||||
{
|
||||
fprintf(fp, "\n// ******************************************\n");
|
||||
fprintf(fp, "// * Table of class instance definitions... *\n");
|
||||
fprintf(fp, "// ******************************************\n");
|
||||
}
|
||||
while(cPtr!=NULL)
|
||||
{
|
||||
if(cPtr!=collectionClass) cPtr->asciiDumpInstances(fp);
|
||||
cPtr = cPtr->getNext();
|
||||
}
|
||||
|
||||
cdevAliasDefinition *aPtr = aliasHead;
|
||||
if(aPtr)
|
||||
{
|
||||
fprintf(fp, "\n\n// ******************************************\n");
|
||||
fprintf(fp, "// * Table of alias definitions... *\n");
|
||||
fprintf(fp, "// ******************************************\n");
|
||||
}
|
||||
while(aPtr!=NULL)
|
||||
{
|
||||
aPtr->asciiDump(fp);
|
||||
aPtr = aPtr->getNext();
|
||||
}
|
||||
|
||||
cdevCollectionDefinition * clPtr = collectionHead;
|
||||
if(clPtr)
|
||||
{
|
||||
fprintf(fp, "\n\n// ******************************************\n");
|
||||
fprintf(fp, "// * Table of collection definitions... *\n");
|
||||
fprintf(fp, "// ******************************************\n");
|
||||
}
|
||||
while(clPtr!=NULL)
|
||||
{
|
||||
clPtr->asciiDump(fp);
|
||||
clPtr = clPtr->getNext();
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::asciiDumpRedirector :
|
||||
// * This is a diagnostic method that allows the caller to dump the contents
|
||||
// * of the redirection table for each class that has been instanciated.
|
||||
// *****************************************************************************
|
||||
inline void cdevDirectoryTable::asciiDumpRedirector ( FILE * fp )
|
||||
{
|
||||
int cnt = 0;
|
||||
|
||||
cdevClassDefinition *def;
|
||||
for(def = classHead; def!=NULL; def = def->getNext())
|
||||
{
|
||||
if(classInstanceHash.find(def->getName())!=NULL)
|
||||
{
|
||||
def->asciiDumpRedirector(fp);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
if(!cnt) cdevReportError(CDEV_SEVERITY_WARN, "CDEV Directory", NULL,
|
||||
"No devices have been instanciated");
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::getServices :
|
||||
// * Returns the list of services that are defined within the directory.
|
||||
// *****************************************************************************
|
||||
inline cdevServiceDefinition * cdevDirectoryTable::getServices ( void )
|
||||
{
|
||||
return serviceHead;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::getClasses :
|
||||
// * Returns the list of classes that are defined within the directory.
|
||||
// *****************************************************************************
|
||||
inline cdevClassDefinition * cdevDirectoryTable::getClasses ( void )
|
||||
{
|
||||
return classHead;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::getAliases :
|
||||
// * Returns the list of aliases that are defined within the directory.
|
||||
// *****************************************************************************
|
||||
inline cdevAliasDefinition * cdevDirectoryTable::getAliases ( void )
|
||||
{
|
||||
return aliasHead;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::getServiceHash :
|
||||
// * Return a hash table of services that are defined within the directory.
|
||||
// *****************************************************************************
|
||||
inline StringHash & cdevDirectoryTable::getServiceHash ( void )
|
||||
{
|
||||
return serviceHash;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::getClassHash :
|
||||
// * Return a hash table of classes that are defined within the directory.
|
||||
// *****************************************************************************
|
||||
inline StringHash & cdevDirectoryTable::getClassHash ( void )
|
||||
{
|
||||
return classHash;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::getInstanceHash :
|
||||
// * Return a hash table of classes that have been instanciated within the
|
||||
// * directory.
|
||||
// *****************************************************************************
|
||||
inline StringHash & cdevDirectoryTable::getInstanceHash ( void )
|
||||
{
|
||||
return classInstanceHash;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::getDeviceHash :
|
||||
// * Return a hash table of device names that have been instanciated in all
|
||||
// * classes within the directory. This hash-table includes aliases that
|
||||
// * have been instanciated.
|
||||
// *****************************************************************************
|
||||
inline StringHash & cdevDirectoryTable::getDeviceHash ( void )
|
||||
{
|
||||
return deviceHash;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevDirectoryTable::getCollectionHash :
|
||||
// * Return a hash table of collection names that have been instanciated in
|
||||
// * the DDL file. Each collection definition contains the list of devices
|
||||
// * that it contains.
|
||||
// *****************************************************************************
|
||||
inline StringHash & cdevDirectoryTable::getCollectionHash ( void )
|
||||
{
|
||||
return collectionHash;
|
||||
}
|
||||
|
||||
|
||||
#endif /* _CDEV_DIRECTORY_TABLE_H_ */
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <cdevData.h>
|
||||
#include <cdevDirectoryTable.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevDirectoryTool : public cdevDirectoryTable
|
||||
{
|
||||
public:
|
||||
cdevDirectoryTool ( void );
|
||||
~cdevDirectoryTool ( void );
|
||||
|
||||
static int query ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int queryClass ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int queryClasses ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int queryCollection ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int queryVerbs ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int queryAttributes ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int queryMessages ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int service ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int serviceData ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int validate ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int update ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int writeAscii ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
static int writeBinary ( cdevDirectoryTable &table, cdevData *in, cdevData *out );
|
||||
|
||||
protected:
|
||||
static int queryElements ( cdevDirectoryTable &table, cdevDirectoryTable::ElementType type,
|
||||
cdevData *in, cdevData *out);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,260 @@
|
||||
#ifndef _CDEV_ELEMENT_DEFINITION_H_
|
||||
#define _CDEV_ELEMENT_DEFINITION_H_
|
||||
|
||||
#ifndef _CDEV_DIRECTORY_TABLE_H_
|
||||
#error "You must include cdevDirectoryTable.h to load cdevElementDefinition.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevElementDefinition :
|
||||
// * This class is used to store the information that describes the contents
|
||||
// * of a single element of a CDEV DDL class definition (verb, attribute,
|
||||
// * or message.
|
||||
// *
|
||||
// * This class maintains a variety of internal data items for the following
|
||||
// * purposes...
|
||||
// *
|
||||
// * name - This is the name of the verb, attribute, or message that
|
||||
// * is represented by this element definition.
|
||||
// * service - This is the service that this element direct the request
|
||||
// * to.
|
||||
// * serviceData - These are the values that will be palcded in the tags
|
||||
// * that were specified in the service definition.
|
||||
// * nItems - This is the number of tagged data items that were
|
||||
// * specified in the serviceData.
|
||||
// * next - This is the next element item in the list. Lists of
|
||||
// * elements are maintained in the cdevClassDefinition objects
|
||||
// *****************************************************************************
|
||||
class cdevElementDefinition
|
||||
{
|
||||
private:
|
||||
cdevElementDefinition * next;
|
||||
char * name;
|
||||
cdevServiceDefinition * service;
|
||||
char ** serviceData;
|
||||
int nItems;
|
||||
|
||||
public:
|
||||
inline cdevElementDefinition ( cdevElementDefinition *def );
|
||||
inline cdevElementDefinition ( char * Name = NULL,
|
||||
cdevServiceDefinition * Service = NULL,
|
||||
char ** ServiceData = NULL,
|
||||
int NItems = 0);
|
||||
inline virtual ~cdevElementDefinition ( void );
|
||||
inline void asciiDump ( FILE * fp = stdout);
|
||||
inline void asciiDumpList ( FILE * fp = stdout, char * keyword = "UNKNOWN");
|
||||
|
||||
// *********************************************************************
|
||||
// * Member access methods.
|
||||
// *********************************************************************
|
||||
inline char * getName ( void );
|
||||
inline cdevServiceDefinition * getService ( void );
|
||||
inline char ** getServiceData ( void );
|
||||
inline int getDataCnt ( void );
|
||||
inline cdevElementDefinition * getNext ( void );
|
||||
inline void setNext ( cdevElementDefinition * Next );
|
||||
};
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::cdevElementDefinition :
|
||||
// * This is the constructor for the cdevElementDefintion class. This
|
||||
// * constructor copies the contents from a pre-existing
|
||||
// * cdevElementDefinition object, and assumes that the data should be
|
||||
// * deleted by the originating class.
|
||||
// *****************************************************************************
|
||||
inline cdevElementDefinition::cdevElementDefinition ( cdevElementDefinition *def )
|
||||
: next (NULL),
|
||||
name (def->name),
|
||||
service (def->service),
|
||||
serviceData (def->serviceData),
|
||||
nItems (def->nItems)
|
||||
{
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::cdevElementDefinition :
|
||||
// * This is the constructor for the cdevElementDefinition class and it
|
||||
// * uses literal values that are provoded by the caller. It assumes that it
|
||||
// * it responsible for deleteing these data items when the instance of the
|
||||
// * class is deleted.
|
||||
// *****************************************************************************
|
||||
inline cdevElementDefinition::cdevElementDefinition
|
||||
( char * Name,
|
||||
cdevServiceDefinition * Service,
|
||||
char ** ServiceData,
|
||||
int NItems)
|
||||
: next (NULL),
|
||||
name (Name),
|
||||
service (Service),
|
||||
serviceData (ServiceData),
|
||||
nItems (NItems)
|
||||
{
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::~cdevElementDefinition :
|
||||
// * This is the destructor for the cdevElementDefinition class.
|
||||
// *****************************************************************************
|
||||
inline cdevElementDefinition::~cdevElementDefinition ( void )
|
||||
{
|
||||
if(name) delete name;
|
||||
while((--nItems)>=0) delete serviceData[nItems];
|
||||
if(serviceData) delete serviceData;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::asciiDump :
|
||||
// * This method will dump the contents of the cdevElementDefinition class
|
||||
// * class to the user specified file pointer.
|
||||
// *****************************************************************************
|
||||
inline void cdevElementDefinition::asciiDump ( FILE * fp )
|
||||
{
|
||||
if(name)
|
||||
{
|
||||
fprintf(fp, "\t\t%s", name);
|
||||
|
||||
if(service)
|
||||
{
|
||||
fprintf(fp, " %s", service->getName());
|
||||
|
||||
for(int i=0; i<nItems; i++)
|
||||
{
|
||||
if(i==0) fprintf(fp, " {");
|
||||
fprintf(fp, "%s", serviceData[i]);
|
||||
if(i<nItems-1) fprintf(fp, ", ");
|
||||
else fprintf(fp, "}");
|
||||
}
|
||||
}
|
||||
fprintf(fp, ";\n");
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::asciiDumpList :
|
||||
// * This method dumps the complete contents of the cdevElementDefinition
|
||||
// * list.
|
||||
// *****************************************************************************
|
||||
inline void cdevElementDefinition::asciiDumpList (FILE *fp, char * keyword)
|
||||
{
|
||||
cdevElementDefinition * def = this;
|
||||
int nameLen = 0;
|
||||
int serviceLen = 0;
|
||||
|
||||
for(def = this; def!=NULL; def = def->next)
|
||||
{
|
||||
int n = def->name==NULL?0:strlen(def->name);
|
||||
int s = def->service==NULL?0:strlen(def->service->getName());
|
||||
if(n>nameLen) nameLen = n;
|
||||
if(s>serviceLen) serviceLen = s;
|
||||
}
|
||||
if(serviceLen)
|
||||
{
|
||||
fprintf(fp, "\t%s\n\t\t{\n", keyword);
|
||||
for(def = this; def!=NULL; def = def->next)
|
||||
{
|
||||
if(nameLen>0 && def->service)
|
||||
fprintf(fp, "\t\t%-*s", nameLen, def->name);
|
||||
else fprintf(fp, "\t\t%s", def->name);
|
||||
|
||||
if(def->service)
|
||||
{
|
||||
if(serviceLen>0 && def->nItems)
|
||||
fprintf(fp, " %-*s", serviceLen, def->service->getName());
|
||||
else fprintf(fp, " %s", def->service->getName());
|
||||
|
||||
for(int i=0; i<def->nItems; i++)
|
||||
{
|
||||
if(i==0) fprintf(fp, " {");
|
||||
fprintf(fp, "%s", def->serviceData[i]);
|
||||
if(i<def->nItems-1) fprintf(fp, ", ");
|
||||
else fprintf(fp, "}");
|
||||
}
|
||||
}
|
||||
fprintf(fp, ";\n");
|
||||
}
|
||||
fprintf(fp, "\t\t}\n");
|
||||
}
|
||||
else {
|
||||
int cnt = 0;
|
||||
char prefix[25];
|
||||
sprintf(prefix, "%s {", keyword);
|
||||
fprintf(fp, "\t%s", prefix);
|
||||
for(def = this; def!=NULL; def = def->next, cnt++)
|
||||
{
|
||||
if(def->next)
|
||||
{
|
||||
fprintf(fp, " %s,", def->name);
|
||||
if(cnt==3)
|
||||
{
|
||||
fprintf(fp, "\n\t%*c", strlen("prefix")+1, 32);
|
||||
cnt=-1;
|
||||
}
|
||||
}
|
||||
else fprintf(fp, " %s ", def->name);
|
||||
}
|
||||
fprintf(fp, "}\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::getName :
|
||||
// * This method allows the caller to retrieve the name of the element.
|
||||
// *****************************************************************************
|
||||
inline char * cdevElementDefinition::getName ( void )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::getService :
|
||||
// * This method allows the caller to retrieve the service definition
|
||||
// *****************************************************************************
|
||||
inline cdevServiceDefinition * cdevElementDefinition::getService ( void )
|
||||
{
|
||||
return service;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::getServiceData :
|
||||
// * This method allows the caller to retrieve the service data.
|
||||
// *****************************************************************************
|
||||
inline char ** cdevElementDefinition::getServiceData ( void )
|
||||
{
|
||||
return serviceData;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::getDataCnt :
|
||||
// * This method allows the caller to retrieve the number of strings that
|
||||
// * are stored in the serviceData.
|
||||
// *****************************************************************************
|
||||
inline int cdevElementDefinition::getDataCnt ( void )
|
||||
{
|
||||
return nItems;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::getNext :
|
||||
// * This method allows the caller to retrieve the next element in the list.
|
||||
// *****************************************************************************
|
||||
inline cdevElementDefinition * cdevElementDefinition::getNext ( void )
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevElementDefinition::setNext :
|
||||
// * This method allows the caller to set the next element in the list.
|
||||
// *****************************************************************************
|
||||
inline void cdevElementDefinition::setNext ( cdevElementDefinition * Next )
|
||||
{
|
||||
next = Next;
|
||||
}
|
||||
|
||||
#endif /* _CDEV_ELEMENT_DEFINITION_H_ */
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// CDEV error codes
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevErrCode.h,v
|
||||
// Revision 1.8 1998/01/14 17:49:48 chen
|
||||
// add msg error
|
||||
//
|
||||
// Revision 1.7 1998/01/14 13:47:10 chen
|
||||
// add more status code
|
||||
//
|
||||
// Revision 1.6 1996/12/16 20:48:51 akers
|
||||
// Support for additional cdevCallback features
|
||||
//
|
||||
// Revision 1.5 1996/11/21 17:03:29 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.4 1995/10/17 17:33:57 akers
|
||||
// Updated error, status, access and severity codes
|
||||
//
|
||||
// Revision 1.3 1995/10/03 20:07:13 chen
|
||||
// add connection event type
|
||||
//
|
||||
// Revision 1.2 1995/07/05 18:44:05 chen
|
||||
// change to C code callable style
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:08 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
*/
|
||||
#ifndef _CDEV_ERROR_CODE_H
|
||||
#define _CDEV_ERROR_CODE_H
|
||||
|
||||
/* Error and status values */
|
||||
#define CDEV_WARNING -2 /* Failure of function is non-consequential */
|
||||
#define CDEV_ERROR -1 /* Errors that are not in any categories */
|
||||
#define CDEV_SUCCESS 0 /* cdev success */
|
||||
#define CDEV_INVALIDOBJ 1 /* invalid cdev objects */
|
||||
#define CDEV_INVALIDARG 2 /* invalid argument passed to cdev calls */
|
||||
#define CDEV_INVALIDSVC 3 /* wrong service during dynamic loading */
|
||||
#define CDEV_INVALIDOP 4 /* operation is unsupported (collection) */
|
||||
|
||||
#define CDEV_NOTCONNECTED 5 /* not connected to low network service */
|
||||
#define CDEV_IOFAILED 6 /* low level network service IO failed */
|
||||
#define CDEV_CONFLICT 7 /* conflicts of data types or tags */
|
||||
#define CDEV_NOTFOUND 8 /* cdev cannot find user request (cdevData) */
|
||||
|
||||
#define CDEV_TIMEOUT 9 /* time out */
|
||||
#define CDEV_CONVERT 10 /* cdevData conversion error */
|
||||
#define CDEV_OUTOFRANGE 11 /* value out of range for device attribute */
|
||||
#define CDEV_NOACCESS 12 /* insufficient access to perform request */
|
||||
#define CDEV_ACCESSCHANGED 13 /* change in access permission of device */
|
||||
|
||||
#define CDEV_DISCONNECTED 60 /* channel has been disconnected */
|
||||
#define CDEV_RECONNECTED 61 /* channel has been reconnected */
|
||||
|
||||
#define CDEV_DELETE_CALLBACK 70 /* the callback object will be deleted */
|
||||
|
||||
/* status related to callback status and more */
|
||||
#define CDEV_NOTCONSERVER 80 /* can not connect to server/ not connected */
|
||||
#define CDEV_NOTFOUNDSERVER 81 /* can not find server */
|
||||
#define CDEV_CONN_TIMEOUT 82 /* connection timeout */
|
||||
#define CDEV_BADIO 86 /* TCP io is bad file descriptor */
|
||||
#define CDEV_OVERFLOW 87 /* overflow buffer */
|
||||
#define CDEV_INCOMPLETE 88 /* data flow will coming (unfinished) */
|
||||
#define CDEV_CBK_FINISHED 89 /* callback finished (monitor off) */
|
||||
#define CDEV_PAUSED 90 /* callback is paused */
|
||||
#define CDEV_MSG_ERR 91 /* query message syntax error */
|
||||
|
||||
/* Request object state values */
|
||||
#define CDEV_STATE_CONNECTED 0 /* request object is connected to device */
|
||||
#define CDEV_STATE_NOTCONNECTED 1 /* request object is not connected */
|
||||
#define CDEV_STATE_INVALID 2 /* request object is invalid */
|
||||
|
||||
/* Request object access values */
|
||||
#define CDEV_ACCESS_NONE 0 /* no access to specified attribute */
|
||||
#define CDEV_ACCESS_READONLY 1 /* read-only access to attribute */
|
||||
#define CDEV_ACCESS_WRITE 2 /* read-write access to attribute */
|
||||
|
||||
/* cdevError class severity codes */
|
||||
#define CDEV_SEVERITY_INFO 0 /* informative message */
|
||||
#define CDEV_SEVERITY_WARN 1 /* warning message */
|
||||
#define CDEV_SEVERITY_ERROR 2 /* error message */
|
||||
#define CDEV_SEVERITY_SEVERE 3 /* severe or fatal error message */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevRequestObject Error Handler Object (User Cannot Access this)
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevErrReqObject.h,v
|
||||
// Revision 1.2 1998/03/09 18:51:37 chen
|
||||
// redefine getState/getAccess for errReqObject
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:06 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_ERR_REQOBJ_H
|
||||
#define _CDEV_ERR_REQOBJ_H
|
||||
|
||||
#include <cdevRequestObject.h>
|
||||
|
||||
class cdevErrReqObject: public cdevRequestObject
|
||||
{
|
||||
public:
|
||||
// destructor
|
||||
~cdevErrReqObject (void);
|
||||
|
||||
int send (cdevData& out, cdevData& result);
|
||||
int send (cdevData* out, cdevData& result);
|
||||
int send (cdevData& out, cdevData* result);
|
||||
int send (cdevData* out, cdevData* result);
|
||||
|
||||
int sendNoBlock (cdevData& out, cdevData& result);
|
||||
int sendNoBlock (cdevData* out, cdevData& result);
|
||||
int sendNoBlock (cdevData& out, cdevData* result);
|
||||
int sendNoBlock (cdevData* out, cdevData* result);
|
||||
|
||||
int sendCallback (cdevData& out, cdevCallback& callback);
|
||||
int sendCallback (cdevData* out, cdevCallback& callback);
|
||||
|
||||
int getState (void);
|
||||
int getAccess (void);
|
||||
|
||||
const char *className (void) const {return "cdevErrReqObject";}
|
||||
|
||||
private:
|
||||
// constructor
|
||||
cdevErrReqObject (cdevSystem& system = cdevSystem::defaultSystem());
|
||||
friend class cdevSystem;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1991,1992 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevService Error Handler Class
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevErrSvc.h,v
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:08 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_ERR_SVC_H
|
||||
#define _CDEV_ERR_SVC_H
|
||||
|
||||
#include "cdevService.h"
|
||||
|
||||
class cdevErrSvc: public cdevService
|
||||
{
|
||||
public:
|
||||
cdevErrSvc (cdevSystem& system = cdevSystem::defaultSystem());
|
||||
// PURPOSE: constructor
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: a cdevErrSvc
|
||||
|
||||
~cdevErrSvc (void);
|
||||
// PURPOSE: Destructor
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: free all memory
|
||||
|
||||
int getFd (int * &fd, int &numFd);
|
||||
// PURPOSE: get service file descriptors
|
||||
// REQUIRE: callers provide no memory, caller don't free memory
|
||||
// PROMISE: numFd gives number of file descriptors, numFd >= 0
|
||||
|
||||
int flush (void);
|
||||
// PURPOSE: flush network request
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0
|
||||
|
||||
int poll (void);
|
||||
// PURPOSE: Service Polling Method
|
||||
// REQURIE: nothing
|
||||
// PROMISE: return 0
|
||||
|
||||
int pend (int fd = -1);
|
||||
// PURPOSE: Service Pending Method
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0
|
||||
|
||||
int pend (double seconds, int fd = -1);
|
||||
// PURPOSE: Service Pending Method For Upto 'seconds'
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0
|
||||
|
||||
int getRequestObject (char *deviceName, char *msg,
|
||||
cdevRequestObject * &reqObj);
|
||||
// PURPOSE: get requestobject
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0, reqobj = 0;
|
||||
|
||||
int getNameServer (cdevDevice * &ns);
|
||||
// PURPOSE: get name server
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0, ns = 0
|
||||
|
||||
const char *className (void) const {return "cdevErrSvc";}
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,135 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevError class (abstract base class)
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevError.h,v
|
||||
// Revision 1.5 1997/08/27 18:23:31 chen
|
||||
// Change error reporting to site specific scheme
|
||||
//
|
||||
// Revision 1.4 1995/12/14 19:11:14 chen
|
||||
// add support to C interface
|
||||
//
|
||||
// Revision 1.3 1995/10/17 17:44:13 akers
|
||||
// Added setThreshold functionality and made data items protected
|
||||
//
|
||||
// Revision 1.2 1995/10/17 15:29:45 chen
|
||||
// change reportError interface
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:08 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_ERROR_H
|
||||
#define _CDEV_ERROR_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <cdevSpec.h>
|
||||
|
||||
#define _CDEV_MAX_ERR_HANDLERS 5
|
||||
#define CDEV_SEVERITY_VOID_DATA 0xcde5da2a
|
||||
|
||||
class cdevRequestObject;
|
||||
|
||||
typedef void (*cdevErrorHandler)(int severity,
|
||||
char *text,
|
||||
cdevRequestObject* obj);
|
||||
|
||||
class CDEV_CLASS_SPEC cdevError
|
||||
{
|
||||
public:
|
||||
// destructor
|
||||
virtual ~cdevError (void);
|
||||
|
||||
virtual int autoErrorOn (void);
|
||||
// PURPOSE: turn on flag which enables auto error on
|
||||
// REQUIRE: derived class can implement diffrently
|
||||
// PROMISE: return 0
|
||||
|
||||
virtual int autoErrorOff (void);
|
||||
// PURPOSE: turn on flag which disables auto error on
|
||||
// REQUIRE: derived class can implement diffrently
|
||||
// PROMISE: return 0
|
||||
|
||||
virtual int vreportError (int severity,
|
||||
char * name,
|
||||
cdevRequestObject * obj,
|
||||
char * formatString,
|
||||
va_list argp);
|
||||
|
||||
// PURPOSE: report error to somewhere
|
||||
// REQUIRE: formatString can have anything that works in printf
|
||||
// PROMISE: same as printf
|
||||
|
||||
virtual int reportError (int severity,
|
||||
char *name,
|
||||
cdevRequestObject* obj,
|
||||
char *formatString,...);
|
||||
// PURPOSE: report error to somewhere
|
||||
// REQUIRE: formatString can have anything that works in printf
|
||||
// PROMISE: same as printf
|
||||
|
||||
virtual void reportError (int severity,
|
||||
char *message,
|
||||
cdevRequestObject* obj);
|
||||
// PURPOSE: report error to somewhere with a whole string
|
||||
// REQUIRE: user whole string
|
||||
// PROMISE:
|
||||
|
||||
|
||||
virtual void setErrorHandler (cdevErrorHandler handler = 0);
|
||||
// PURPOSE: allow caller to set up his/her own error Handler
|
||||
// REQUIRE: handle > 0 stands for a real function pointer
|
||||
// PROMISE: next time error will be handled by new error handler
|
||||
|
||||
virtual void setThreshold ( int errorThreshold );
|
||||
// PURPOSE: allow the caller to specify the minimum severity to report
|
||||
// REQUIRE: errorThreshold >=0
|
||||
// PROMISE: errors with severity < errorThreshold wil not be reported
|
||||
|
||||
virtual int attachErrorHandler (cdevErrorHandler handler);
|
||||
// PURPOSE: allow caller to attach error handler to trap error messages
|
||||
// REQUIRE: handler > 0
|
||||
// PROMISE: return CDEV_SUCCESS if this handler is attached to trap messgaes
|
||||
|
||||
virtual int detachErrorHandler (cdevErrorHandler handler);
|
||||
// PURPOSE: allow caller to dettach error handler
|
||||
// REQUIRE: handler > 0
|
||||
// PROMISE: return CDEV_SUCCESS if this handler is removed.
|
||||
|
||||
virtual void reportError (void *data,
|
||||
cdevRequestObject* obj);
|
||||
// PURPOSE: report error to somewhere with user defined data object.
|
||||
// This routine is intended for site developer use only to
|
||||
// support site wide error logging system.
|
||||
// REQUIRE: user whole string
|
||||
// PROMISE:
|
||||
|
||||
virtual const char *className(void) const {return "cdevError";}
|
||||
|
||||
protected:
|
||||
// constructers, avoiding direct instantation
|
||||
cdevError (void);
|
||||
cdevError (cdevErrorHandler handler);
|
||||
|
||||
// data areas
|
||||
cdevErrorHandler errorHandler_;
|
||||
static cdevErrorHandler defaultErrorHandler_;
|
||||
int autoErrorOn_;
|
||||
int threshold_;
|
||||
|
||||
// list of error handlers
|
||||
int numhandlers_;
|
||||
cdevErrorHandler handlers_[_CDEV_MAX_ERR_HANDLERS];
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* Description:
|
||||
* cdevErrorCollection class implementation
|
||||
*
|
||||
* Author: Walt Akers, Chip Watson & Jie Chen
|
||||
*
|
||||
* Revision History:
|
||||
* cdevErrorCollection.h,v
|
||||
* Revision 1.1 1996/11/12 20:32:30 akers
|
||||
* New collection device source code
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _CDEV_ERRORCOLLECTION_H
|
||||
#define _CDEV_ERRORCOLLECTION_H
|
||||
|
||||
#include <cdevCollection.h>
|
||||
|
||||
class cdevErrReqObject;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevErrorCollection: public cdevCollection
|
||||
{
|
||||
public:
|
||||
//========================================================================
|
||||
// Public Interface for cdevRequestObject
|
||||
//========================================================================
|
||||
virtual cdevRequestObject *getRequestObject (char * msg );
|
||||
virtual int getRequestObject (char *msg, cdevRequestObject* &reqobj);
|
||||
// PURPOSE: get a requestObject
|
||||
// REQUIRE: name != 0, callers provide pointer only.
|
||||
// PROMISE: always return CDEV_INVALIDOBJ
|
||||
|
||||
//========================================================================
|
||||
// Public Interface for RTTI
|
||||
//========================================================================
|
||||
virtual const char *className (void) const {return "cdevErrorCollection";}
|
||||
|
||||
//========================================================================
|
||||
// Public Interface for list manipulation
|
||||
//========================================================================
|
||||
int add(char* name, ...);
|
||||
int add(char** list, int len);
|
||||
int addRegexp(char* regexp);
|
||||
int remove(char* name, ...);
|
||||
int remove(char** list, int len);
|
||||
int removeRegexp(char* regexp);
|
||||
// PURPOSE: add(remove) a (list of/regexp of) names to the collection
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: always return CDEV_INVALIDOBJ
|
||||
|
||||
protected:
|
||||
//constructors and destructor
|
||||
//constructors will initialize list from directory service
|
||||
cdevErrorCollection (char *name);
|
||||
~cdevErrorCollection (void);
|
||||
|
||||
private:
|
||||
// hide assignment and copy operator since the collection is
|
||||
// a memory manager for collectionRequests and lists of devices
|
||||
cdevErrorCollection& operator = (const cdevCollection &);
|
||||
cdevErrorCollection (const cdevCollection &);
|
||||
|
||||
// friend class declaration
|
||||
friend class cdevCollection;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,138 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevExecGroup: handle buffering mechanism for multiple
|
||||
// executions
|
||||
//
|
||||
// For service layer only
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevExecGroup.h,v
|
||||
// Revision 1.1 1997/03/03 17:36:00 chen
|
||||
// add buffering to channel access connection
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_EXEC_GROUP_H
|
||||
#define _CDEV_EXEC_GROUP_H
|
||||
|
||||
#include <cdevGroup.h>
|
||||
|
||||
class cdevExecObj;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevExecGroup: public cdevGroup
|
||||
{
|
||||
public:
|
||||
// constructors and destructor
|
||||
cdevExecGroup (cdevService* service,
|
||||
unsigned int blockSize = DEFAULT_BLOCK_SIZE,
|
||||
cdevSystem& system = cdevSystem::defaultSystem());
|
||||
~cdevExecGroup (void);
|
||||
|
||||
int flush (void);
|
||||
// PURPOSE: flush all network requests inside this group
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: all network requests of this group will be sent out
|
||||
// return CDEV_SUCCESS
|
||||
|
||||
virtual const char *className (void) const {return "cdevExecGroup";}
|
||||
|
||||
protected:
|
||||
|
||||
int start (void);
|
||||
// PURPOSE: start this group. (see next)
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: group stared, return CDEV_SUCCESS
|
||||
|
||||
int end (void);
|
||||
// PURPOSE: end this group, all async IO between
|
||||
// start and end will be in the group
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: group ended, return CDEV_SUCCESS
|
||||
|
||||
int poll (void);
|
||||
// PURPOSE: polling all outstanding IO events of this group
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return CDEV_SUCCESS
|
||||
|
||||
int pend (int fd = -1);
|
||||
// PURPOSE: do network pending for IO events forever until all
|
||||
// network requests of this group have come back
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: all come back or block forever (return CDEV_SUCCESS)
|
||||
|
||||
int pend (double seconds, int fd = -1);
|
||||
// PURPOSE: do network pending for IO events for upto 'seconds' long or
|
||||
// all network requests of this group have come back
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return CDEV_SUCCESS: finished, return CDEV_TIMEOUT: timeout
|
||||
|
||||
int allFinished (void);
|
||||
// PURPOSE: check all transaction finished of this group
|
||||
// REQUIRE: after pend call
|
||||
// PROMISE: return 1: all finished, 0: not yet
|
||||
|
||||
int status (int status[], int &numTransactions);
|
||||
// PURPOSE: check status of all transactions
|
||||
// REQURIE: transaction status will be in the integer array returned
|
||||
// by this call. Element of the array = 0 finished.
|
||||
// Callers provide integer array buffer with buffer size
|
||||
// PROMISE: return CDEV_SUCCESS on success and numTransaction will be
|
||||
// real number of trasanctions. return CDEV_INVALIDARG
|
||||
// when the integer buffer is not big enough.
|
||||
|
||||
void execDeferred (void);
|
||||
void execImmediate (void);
|
||||
// PURPOSE: change behaviour of execution of command inside the group
|
||||
// execDeferred will buffer all commands until pend or poll or
|
||||
// flush is called
|
||||
// execImmediate will flush commands to underlying services
|
||||
// immediately
|
||||
// REQUIRE: none
|
||||
// PROMISE: execution mode changed
|
||||
|
||||
int executionMode (void) const;
|
||||
// PURPOSE: return execution mode
|
||||
// REQUIRE: none
|
||||
// PROMISE: CDEV_EXEC_DEFERRED or CDEV_EXEC_IMMEDIATE
|
||||
|
||||
int readyToExec (void) const;
|
||||
// PURPOSE: for deferred mode group only. Return execution stage.
|
||||
// REQUIRE: none
|
||||
// PROMISE: 0: the deferred group is still in the buffered stage
|
||||
// 1: the deferred group is ready to flush all buffered
|
||||
// commands
|
||||
|
||||
// get underlying service
|
||||
void getServices (void);
|
||||
|
||||
// send out all buffered commands
|
||||
int execAllCommands (void);
|
||||
|
||||
// find out which service is ready
|
||||
cdevService *pendingService (int handle);
|
||||
// handle events inherited from cdevSync
|
||||
int handleEvents (cdevTimeValue *tv);
|
||||
// notify one partucular service
|
||||
void notifyService (int fd);
|
||||
|
||||
private:
|
||||
// data member
|
||||
// deny access of copy and assignment since the group is a manager
|
||||
cdevExecGroup (const cdevExecGroup& );
|
||||
cdevExecGroup& operator = (const cdevExecGroup&);
|
||||
|
||||
// friend class
|
||||
friend class cdevExecObj;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdev deferred execution object (for service developer only)
|
||||
//
|
||||
// deferred execution object is registered into one and only one
|
||||
// opened group which is the outmost deferred one
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevExecObj.h,v
|
||||
// Revision 1.2 1997/03/03 17:36:03 chen
|
||||
// add buffering to channel access connection
|
||||
//
|
||||
// Revision 1.1 1995/12/08 15:34:50 chen
|
||||
// execution object
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_EXEC_OBJ_H
|
||||
#define _CDEV_EXEC_OBJ_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <cdevSystem.h>
|
||||
#include <cdevData.h>
|
||||
#include <cdevCallback.h>
|
||||
|
||||
class cdevGroup;
|
||||
class cdevRequestObject;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevExecObj
|
||||
{
|
||||
public:
|
||||
// constructor and destructor
|
||||
cdevExecObj (void);
|
||||
cdevExecObj (cdevSystem* sys,
|
||||
cdevRequestObject* reqobj,
|
||||
cdevData* out,
|
||||
cdevData* result,
|
||||
cdevCallback* callback,
|
||||
cdevGroup* execg = 0,
|
||||
void* arg = 0);
|
||||
// Important note:
|
||||
// No objects pointed by the pointers will be deleted from this object
|
||||
~cdevExecObj (void);
|
||||
|
||||
int status (void) const;
|
||||
// PURPOSE: return status of transaction object
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: -1: not registered into any group, 1: registered into groups
|
||||
|
||||
int removeFromGrps (void);
|
||||
// PURPOSE: remove this transaction object from all groups
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: status = -1
|
||||
|
||||
// data area for requestObject to access
|
||||
cdevSystem *system_;
|
||||
cdevRequestObject *reqObj_;
|
||||
cdevData *outData_;
|
||||
cdevData *resultData_;
|
||||
cdevCallback *userCallback_;
|
||||
int status_;
|
||||
cdevGroup *deferredGroup_;
|
||||
// pointer entries to the entry inside deferred group
|
||||
cdevExecObj **entryPtr_;
|
||||
// any user provided argument
|
||||
void *arg_;
|
||||
|
||||
virtual const char *className (void) const {return "cdevExecObj";}
|
||||
|
||||
private:
|
||||
// deny copy and assignment operation
|
||||
// It makes no sense for two identical transaction objects
|
||||
cdevExecObj (const cdevExecObj& rsc);
|
||||
cdevExecObj& operator = (const cdevExecObj& rsc);
|
||||
|
||||
// friend class
|
||||
friend class cdevGroup;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// File Descriptor Mask Class (Based On ACE Handler_Set)
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevFdSet.h,v
|
||||
// Revision 1.6 1997/03/26 18:34:58 akers
|
||||
// Ongoing development
|
||||
//
|
||||
// Revision 1.5 1996/10/01 13:58:23 akers
|
||||
// Changes to support AIX
|
||||
//
|
||||
// Revision 1.4 1996/09/19 18:50:06 akers
|
||||
// Included time.h in order to match redefinition of fd_set to __fd_set.
|
||||
//
|
||||
// Revision 1.3 1995/12/15 15:08:06 chen
|
||||
// Add VMS Fix
|
||||
//
|
||||
// Revision 1.2 1995/10/05 16:30:12 chen
|
||||
// Fix for VMS
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:02 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_FDSET_H
|
||||
#define _CDEV_FDSET_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cdevSpec.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <time.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __VMS
|
||||
#ifdef _TGV_MULTINET
|
||||
// Under TGV multinet and VMS, if you want sys/types.h you need to have
|
||||
// types.h already pulled in because sys/types.h makes it look like types.h
|
||||
// is loaded. Then when types.h does get loaded, it is ignored because it
|
||||
// looks like it is already loaded -- Mr. Danial Van Olst
|
||||
#include <types.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __VMS
|
||||
#ifdef _TGV_MULTINET
|
||||
// Under TGV Multinet and VMS, the file sys/param.h does not define
|
||||
// NOFILE (max number of open files per process).
|
||||
// FD_SETSIZE seems to be the correct value for NOFILE.
|
||||
// See Multinet's sys/types.h file for more info on FD_SETSIZE.
|
||||
// - Daniel Van Olst
|
||||
#ifndef NOFILE
|
||||
#define NOFILE FD_SETSIZE
|
||||
#endif /* NOFILE not defined. */
|
||||
|
||||
#endif /* _TGV_MULTINET defined. */
|
||||
#endif /* __VMS defined. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
/* The header sys/select.h must be included on AIX machines */
|
||||
/* in order to define the FD_ZERO macro. */
|
||||
#ifdef _AIX
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
/* This wrapper design is not very portable to DEC OSF/1 */
|
||||
/* I had to redefine NFDBITS to 32. On OSF/1 NFDBITS is a */
|
||||
/* macro that expands to (sizeof(fd_mask)*8) which is 4096 by */
|
||||
/* default. This was an inappropriate value for defining the */
|
||||
/* MSB_MASK default value. Any ideas? The workaround is a */
|
||||
/* pretty severe restriction for OSF/1. DJT */
|
||||
/*#if defined (__osf__) */
|
||||
/*#define NFDBITS 32 */
|
||||
/*#endif */
|
||||
|
||||
#endif
|
||||
|
||||
class CDEV_CLASS_SPEC cdevFdSet
|
||||
{
|
||||
// = TITLE
|
||||
// C++ wrapper for the BSD fd_set abstraction.
|
||||
//
|
||||
// = DESCRIPTION
|
||||
//
|
||||
|
||||
friend class cdevFdSet_Iterator;
|
||||
public:
|
||||
// = Initialization and termination.
|
||||
|
||||
cdevFdSet (void);
|
||||
cdevFdSet (const fd_set &mask);
|
||||
|
||||
// = Methods for manipulating bitsets.
|
||||
void reset (void);
|
||||
int is_set (int) const;
|
||||
void set_bit (int);
|
||||
void clr_bit (int);
|
||||
int num_set (void) const;
|
||||
int max_set (void) const;
|
||||
int pr_mask ( FILE * fp = stdout );
|
||||
void sync (int max = FD_SETSIZE);
|
||||
operator fd_set *( void ) { return &mask_; }
|
||||
|
||||
private:
|
||||
int size_;
|
||||
int max_handle_;
|
||||
fd_set mask_;
|
||||
|
||||
enum
|
||||
{
|
||||
#ifdef _WIN32
|
||||
MAX_SIZE = FD_SETSIZE,
|
||||
#else
|
||||
MAX_SIZE = NOFILE,
|
||||
WORD_SIZE = NFDBITS,
|
||||
NUM_WORDS = howmany (NOFILE, NFDBITS),
|
||||
#ifdef __DECCXX
|
||||
// DECC warns about integer overflow if 1 used because 1 is signed
|
||||
MSB_MASK = ~(1U << (NFDBITS - 1))
|
||||
#elif defined (CDEV_HAS_64BIT_LONGS)
|
||||
MSB_MASK = ~(1UL << (NFDBITS - 1))
|
||||
#else
|
||||
MSB_MASK = ~(1 << (NFDBITS - 1))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
int count_bits (unsigned long n) const;
|
||||
void set_max (int max);
|
||||
|
||||
static const char nbits_[256];
|
||||
};
|
||||
|
||||
class cdevFdSet_Iterator
|
||||
// = TITLE
|
||||
// Iterator for the cdevFdSet abstraction.
|
||||
//
|
||||
// = DESCRIPTION
|
||||
//
|
||||
{
|
||||
public:
|
||||
cdevFdSet_Iterator (cdevFdSet &);
|
||||
int operator ()(void);
|
||||
void operator++ (void);
|
||||
|
||||
private:
|
||||
cdevFdSet &fds_;
|
||||
#ifdef _WIN32
|
||||
/* index into fd_array[FD_SETSIZE] */
|
||||
unsigned int index_;
|
||||
#else
|
||||
/* index into fd_mask array */
|
||||
int index_;
|
||||
#endif
|
||||
/* current FD value = bit number in the long mask */
|
||||
/* not used in the WIN32 platform */
|
||||
int num_;
|
||||
|
||||
#ifndef _WIN32
|
||||
fd_mask val_;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdev global tag table
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevGlobalTagTable.h,v
|
||||
// Revision 1.1 1995/10/03 19:54:40 chen
|
||||
// single instance of cdevTagTable
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_GBL_TAG_TABLE_H
|
||||
#define _CDEV_GBL_TAG_TABLE_H
|
||||
|
||||
// Use singleton design pattern to ensure that there is only
|
||||
// one tag table in the system without using global variable
|
||||
// which is not desirable in C++
|
||||
|
||||
#include <cdevTagTable.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevGlobalTagTable
|
||||
{
|
||||
public:
|
||||
static cdevTagTable* tagTable (void);
|
||||
|
||||
protected:
|
||||
// constructor
|
||||
cdevGlobalTagTable (void);
|
||||
virtual ~cdevGlobalTagTable (void);
|
||||
|
||||
private:
|
||||
static cdevTagTable* instance_;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,201 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevGroup: handle multiple asynchronous operations
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevGroup.h,v
|
||||
// Revision 1.5 1997/03/03 17:36:05 chen
|
||||
// add buffering to channel access connection
|
||||
//
|
||||
// Revision 1.4 1995/12/08 15:35:37 chen
|
||||
// handle deferred mode
|
||||
//
|
||||
// Revision 1.3 1995/07/05 18:42:44 chen
|
||||
// change status interface
|
||||
//
|
||||
// Revision 1.2 1995/06/30 16:03:36 chen
|
||||
// use generic list
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:07 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_GROUP_H
|
||||
#define _CDEV_GROUP_H
|
||||
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevSync.h>
|
||||
#include <cdevSystem.h>
|
||||
#include <cdevTranObj.h>
|
||||
#include <cdevExecObj.h>
|
||||
#include <cdevCallback.h>
|
||||
#include <cdevSlist.h>
|
||||
|
||||
#include "cdevBlockList.h"
|
||||
|
||||
#define CDEV_EXEC_IMMEDIATE 0
|
||||
#define CDEV_EXEC_DEFERRED 1
|
||||
|
||||
|
||||
class CDEV_CLASS_SPEC cdevGroup: public cdevSync
|
||||
{
|
||||
public:
|
||||
// constructors and destructor
|
||||
cdevGroup (unsigned int blockSize = DEFAULT_BLOCK_SIZE,
|
||||
cdevSystem& system = cdevSystem::defaultSystem());
|
||||
virtual ~cdevGroup (void);
|
||||
|
||||
virtual int start (void);
|
||||
// PURPOSE: start this group. (see next)
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: group stared, return CDEV_SUCCESS
|
||||
|
||||
virtual int end (void);
|
||||
// PURPOSE: end this group, all async IO between
|
||||
// start and end will be in the group
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: group ended, return CDEV_SUCCESS
|
||||
|
||||
virtual int flush (void);
|
||||
// PURPOSE: flush all network requests inside this group
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: all network requests of this group will be sent out
|
||||
// return CDEV_SUCCESS
|
||||
|
||||
virtual int poll (void);
|
||||
// PURPOSE: polling all outstanding IO events of this group
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return CDEV_SUCCESS
|
||||
|
||||
virtual int pend (int fd = -1);
|
||||
// PURPOSE: do network pending for IO events forever until all
|
||||
// network requests of this group have come back
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: all come back or block forever (return CDEV_SUCCESS)
|
||||
|
||||
virtual int pend (double seconds, int fd = -1);
|
||||
// PURPOSE: do network pending for IO events for upto 'seconds' long or
|
||||
// all network requests of this group have come back
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return CDEV_SUCCESS: finished, return CDEV_TIMEOUT: timeout
|
||||
|
||||
int allFinished (void);
|
||||
// PURPOSE: check all transaction finished of this group
|
||||
// REQUIRE: after pend call
|
||||
// PROMISE: return 1: all finished, 0: not yet
|
||||
|
||||
int status (int status[], int &numTransactions);
|
||||
// PURPOSE: check status of all transactions
|
||||
// REQURIE: transaction status will be in the integer array returned
|
||||
// by this call. Element of the array = 0 finished.
|
||||
// Callers provide integer array buffer with buffer size
|
||||
// PROMISE: return CDEV_SUCCESS on success and numTransaction will be
|
||||
// real number of trasanctions. return CDEV_INVALIDARG
|
||||
// when the integer buffer is not big enough.
|
||||
|
||||
void execDeferred (void);
|
||||
void execImmediate (void);
|
||||
// PURPOSE: change behaviour of execution of command inside the group
|
||||
// execDeferred will buffer all commands until pend or poll or
|
||||
// flush is called
|
||||
// execImmediate will flush commands to underlying services
|
||||
// immediately
|
||||
// REQUIRE: none
|
||||
// PROMISE: execution mode changed
|
||||
|
||||
int executionMode (void) const;
|
||||
// PURPOSE: return execution mode
|
||||
// REQUIRE: none
|
||||
// PROMISE: CDEV_EXEC_DEFERRED or CDEV_EXEC_IMMEDIATE
|
||||
|
||||
int readyToExec (void) const;
|
||||
// PURPOSE: for deferred mode group only. Return execution stage.
|
||||
// REQUIRE: none
|
||||
// PROMISE: 0: the deferred group is still in the buffered stage
|
||||
// 1: the deferred group is ready to flush all buffered
|
||||
// commands
|
||||
|
||||
virtual const char *className (void) const {return "cdevGroup";}
|
||||
|
||||
protected:
|
||||
// all add and remove operation on the transaction object
|
||||
cdevTranObj **addTranObj (cdevTranObj* obj);
|
||||
// clean out all transaction objects
|
||||
void cleanAll (void);
|
||||
// get all services associaed with transaction objects
|
||||
// only used when one about to call IO operations
|
||||
void getServices (void);
|
||||
// find out which service is ready
|
||||
cdevService *pendingService (int handle);
|
||||
// handle events inherited from cdevSync
|
||||
virtual int handleEvents (cdevTimeValue *tv);
|
||||
// notify one partucular service
|
||||
virtual void notifyService (int fd);
|
||||
// quick polling underlying services
|
||||
virtual void qpoll (void);
|
||||
|
||||
// setup file read mask
|
||||
void setupFdMask (void);
|
||||
|
||||
// add execution object to the list
|
||||
cdevExecObj **addExecObj (cdevExecObj* eobj);
|
||||
// cleanout all execution objects
|
||||
void cleanAllEobjs (void);
|
||||
// send out all buffered commands
|
||||
int execAllCommands (void);
|
||||
|
||||
protected:
|
||||
// data member
|
||||
// transaction object list
|
||||
cdevBlockList objList_;
|
||||
// order dependent, careful!!!
|
||||
cdevBlockListIterator ite_;
|
||||
// execution object list
|
||||
cdevBlockList eobjList_;
|
||||
// order dependent, careful!!!
|
||||
cdevBlockListIterator eite_;
|
||||
// service list associcated with this group
|
||||
cdevSlist serviceList_;
|
||||
cdevSystem &system_;
|
||||
// flag to tell whether one unregister itself from the system
|
||||
int unregOn_;
|
||||
// flag to see whether this group is created successfully
|
||||
int errBit_;
|
||||
// flag to see whether transaction object should remove itself
|
||||
// from the object list
|
||||
int remXobj_;
|
||||
// flag to lock the execution object list
|
||||
int remEobj_;
|
||||
// how many transaction objects are in this group
|
||||
int hwMark_;
|
||||
// group active flag
|
||||
int active_;
|
||||
// operation mode of group
|
||||
int mode_;
|
||||
// number of execution objects
|
||||
int numEobjs_;
|
||||
// stage of deferred execution: buffer mode or execution mode
|
||||
// 0: buffer stage, 1: execution stage
|
||||
int execStage_;
|
||||
|
||||
// deny access of copy and assignment since the group is a manager
|
||||
cdevGroup (const cdevGroup& );
|
||||
cdevGroup& operator = (const cdevGroup&);
|
||||
|
||||
// friend class
|
||||
friend class cdevSystem;
|
||||
friend class cdevTranObj;
|
||||
friend class cdevExecObj;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* cdevGrpCollectionRequest.h : This class is used to collect the results that
|
||||
* are generated by numerous service-specific
|
||||
* cdevCollectionRequest objects. When all of the
|
||||
* component collections have responded to this
|
||||
* object, the data will be consolidated and
|
||||
* returned to the caller.
|
||||
*
|
||||
* Author: Walt Akers
|
||||
*
|
||||
* Revision History:
|
||||
* cdevGrpCollectionRequest.h,v
|
||||
* Revision 1.1 1996/11/12 20:32:34 akers
|
||||
* New collection device source code
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef _CDEV_GRP_COLLECTION_REQUEST_H
|
||||
#define _CDEV_GRP_COLLECTION_REQUEST_H
|
||||
|
||||
#include <cdevCollectionRequest.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevGrpCollectionRequest: public cdevCollectionRequest
|
||||
{
|
||||
friend class cdevCollectionRequest;
|
||||
|
||||
public:
|
||||
// *********************************************************************
|
||||
// * This structure is provided as the void * argument to the default
|
||||
// * callback whenever the synchronous send is used. The checkSum is
|
||||
// * used to detect if the result returned after the send method stopped
|
||||
// * waiting for it.
|
||||
// *********************************************************************
|
||||
typedef struct
|
||||
{
|
||||
int completionCode;
|
||||
int finished;
|
||||
cdevData *data;
|
||||
} SendStatus;
|
||||
|
||||
// *********************************************************************
|
||||
// * These methods get state and access information for the underlying
|
||||
// * cdevRequestObjects.
|
||||
// *********************************************************************
|
||||
virtual int getState (void);
|
||||
virtual int getAccess (void);
|
||||
|
||||
// *********************************************************************
|
||||
// * This method sets the context of each of the underlying
|
||||
// * cdevRequestObjects.
|
||||
// *********************************************************************
|
||||
virtual int setContext (cdevData &ctx);
|
||||
|
||||
// *********************************************************************
|
||||
// * send :
|
||||
// * The send interface is used to provide synchronous I/O with the
|
||||
// * service.
|
||||
// *
|
||||
// * Returns CDEV_SUCCESS on success or CDEV_ERROR on error.
|
||||
// *********************************************************************
|
||||
virtual int send ( cdevData & in, cdevData & out )
|
||||
{ return send(&in, &out); }
|
||||
virtual int send ( cdevData * in, cdevData & out )
|
||||
{ return send(in, &out); }
|
||||
virtual int send ( cdevData & in, cdevData * out )
|
||||
{ return send(&in, out); }
|
||||
virtual int send ( cdevData * in, cdevData * out );
|
||||
|
||||
// *********************************************************************
|
||||
// * sendNoBlock :
|
||||
// * The sendNoBlock interface is used in conjunction with cdevGroup
|
||||
// * or cdevSystem to execute a series of operations.
|
||||
// *
|
||||
// * Returns CDEV_SUCCESS on success or CDEV_ERROR on error.
|
||||
// *********************************************************************
|
||||
virtual int sendNoBlock (cdevData & in, cdevData & out)
|
||||
{ return sendNoBlock(&in, &out); }
|
||||
virtual int sendNoBlock (cdevData * in, cdevData & out)
|
||||
{ return sendNoBlock(in, &out); }
|
||||
virtual int sendNoBlock (cdevData & in, cdevData * out)
|
||||
{ return sendNoBlock(&in, out); }
|
||||
virtual int sendNoBlock (cdevData * in, cdevData * out);
|
||||
|
||||
// *********************************************************************
|
||||
// * sendCallback :
|
||||
// * The sendCallback interface provides asynchronous communications
|
||||
// * with the service.
|
||||
// *
|
||||
// * Returns CDEV_SUCCESS on success or CDEV_ERROR on error.
|
||||
// *********************************************************************
|
||||
virtual int sendCallback (cdevData & in, cdevCallback & callback)
|
||||
{ return sendCallback(&in, callback); }
|
||||
virtual int sendCallback (cdevData * in, cdevCallback & callback);
|
||||
|
||||
// *********************************************************************
|
||||
// * This method returns the name of the class.
|
||||
// *********************************************************************
|
||||
const char *className (void) const {return "cdevGrpCollectionRequest";}
|
||||
|
||||
protected:
|
||||
// *********************************************************************
|
||||
// * These are the protected constructor and destructor for this object.
|
||||
// *********************************************************************
|
||||
cdevGrpCollectionRequest (char **devices, int nDevices, char *msg, cdevSystem& sys);
|
||||
virtual ~cdevGrpCollectionRequest (void);
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the syncCallback method. It will be used by the send
|
||||
// * method in order to detect the completion of the operation.
|
||||
// *********************************************************************
|
||||
static void syncCallback (int status, void * user, cdevRequestObject &, cdevData &data);
|
||||
|
||||
// *********************************************************************
|
||||
// * This callback function is used to receive the individual callbacks
|
||||
// * from the underlying cdevRequestObjects and is used by sendCallback.
|
||||
// *********************************************************************
|
||||
static void asyncCallback (int, void *, cdevRequestObject &, cdevData &);
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the asyncNoBlockCallback method. It will be used by the
|
||||
// * sendNoBlock method in order to detect the completion of the
|
||||
// * operation.
|
||||
// *********************************************************************
|
||||
static void asyncNoBlockCallback (int status, void * user, cdevRequestObject &, cdevData &data);
|
||||
|
||||
private:
|
||||
static SendStatus sendStatus;
|
||||
static int sendCheckSum;
|
||||
|
||||
// *********************************************************************
|
||||
// * These are the cdevCollectionRequest objects that are addressed by
|
||||
// * each call to this cdevGrpCollectionRequest. The nCollections
|
||||
// * variable contains the number of cdevRequestObjects that are
|
||||
// * represented.
|
||||
// *********************************************************************
|
||||
cdevCollectionRequest **collections;
|
||||
int nCollections;
|
||||
|
||||
// *********************************************************************
|
||||
// * This is a table of integers that identifies the order in which
|
||||
// * results from the incoming collections should be distributed to
|
||||
// * the outbound data.
|
||||
// *********************************************************************
|
||||
int * requestOrder;
|
||||
int nRequests;
|
||||
|
||||
// *********************************************************************
|
||||
// * This is the master data structure. It contains no actual data,
|
||||
// * however, it identifies the data structure that should exist when
|
||||
// * the request has been executed.
|
||||
// *
|
||||
// * This structure is inspected and updated at the completion of each
|
||||
// * callback, and is used to initially create the cdevData objects that
|
||||
// * are used for interim data storage.
|
||||
// *********************************************************************
|
||||
cdevData format;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevIOcontext header
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevIOcontext.h,v
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:06 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_IO_CONTEXT_H
|
||||
#define _CDEV_IO_CONTEXT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevData.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevIOcontext
|
||||
{
|
||||
public:
|
||||
// constructors and destructor
|
||||
virtual ~cdevIOcontext (void);
|
||||
|
||||
cdevData& getContext (void);
|
||||
// PURPOSE: get context represented by a cdevData
|
||||
|
||||
virtual int setContext (cdevData& ctx);
|
||||
// PURPOSE: set context from a cdevData
|
||||
// derived class may provide different setContext function
|
||||
// eg. channel access requestObject will use this function
|
||||
// to provide right request data type
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0
|
||||
|
||||
void setPrivate (void *userdata);
|
||||
// PURPOSE: set user provided data
|
||||
// REQUIRE: nothing. user handle memory management of userdata
|
||||
// PROMISE: user data will not be freeed when this is destroyed
|
||||
|
||||
void * getPrivate (void);
|
||||
// PURPOSE: get user provided data
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: something
|
||||
|
||||
virtual const char *className(void) const {return "cdevIOcontext";}
|
||||
|
||||
protected:
|
||||
// constructor, to prevent from direct instantiation
|
||||
cdevIOcontext (void);
|
||||
cdevData data_;
|
||||
void *userData_;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevIntHash: cdev hash table keyed by an integer
|
||||
// Open Hash with buckets implemented by single linked lists
|
||||
//
|
||||
// Note: void *s are stored inside the table. This class
|
||||
// will not manage these pointers. Callers have to
|
||||
// manage these pointers
|
||||
//
|
||||
// Author: Danjin Wu (Modified from cdevStrHash class)
|
||||
//
|
||||
// Revision History:
|
||||
// cdevIntHash.h,v
|
||||
// Revision 1.2 1996/08/26 21:12:35 akers
|
||||
// Added getData method to iterator
|
||||
//
|
||||
// Revision 1.1 1995/08/21 15:45:36 danjin
|
||||
// integer hash table
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_INT_HASH_H
|
||||
#define _CDEV_INT_HASH_H
|
||||
|
||||
#include <cdevSlist.h>
|
||||
|
||||
//======================================================================
|
||||
// One simple integer hash function
|
||||
// This hash function is used in cdevData.
|
||||
// It returns integer value between 0 to table size
|
||||
//======================================================================
|
||||
|
||||
typedef int cdevIntKeyItem;
|
||||
typedef void* cdevHashItem;
|
||||
//======================================================================
|
||||
// class cdevIntHash
|
||||
// collection of buckets indexed by hashed values
|
||||
//======================================================================
|
||||
class cdevIntHashIterator;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevIntHash
|
||||
{
|
||||
public:
|
||||
// constructor, construct a table with entry max
|
||||
cdevIntHash (unsigned int max);
|
||||
// destructor
|
||||
virtual ~cdevIntHash (void);
|
||||
|
||||
// operations
|
||||
|
||||
// is the table empty: return 1: yes. return 0: no
|
||||
virtual int isEmpty();
|
||||
|
||||
// clear the elements of the set
|
||||
virtual void deleteAllValues();
|
||||
|
||||
// add an element to the collection
|
||||
virtual void add (cdevIntKeyItem key, cdevHashItem ele);
|
||||
|
||||
// test to see whether this hash table includes one particular element
|
||||
virtual int find (cdevIntKeyItem key, cdevHashItem ele) const;
|
||||
|
||||
// remove an element. return 0: ele is not inside table. return 1: success
|
||||
virtual int remove (cdevIntKeyItem key, cdevHashItem ele);
|
||||
|
||||
// return a reference to a particular bucket according to the key
|
||||
cdevSlist& bucketRef (cdevIntKeyItem key);
|
||||
|
||||
protected:
|
||||
friend class cdevIntHashIterator;
|
||||
|
||||
// the actual table itself is a vector of buckets
|
||||
const unsigned int tablesize;
|
||||
cdevSlist* buckets;
|
||||
|
||||
// convert key into unsigned integer value in range
|
||||
unsigned int hash(const cdevIntKeyItem key) const;
|
||||
|
||||
};
|
||||
|
||||
//======================================================================
|
||||
// class cdevIntHashIterator
|
||||
// iterator protocol for hash tables
|
||||
//======================================================================
|
||||
class CDEV_CLASS_SPEC cdevIntHashIterator
|
||||
{
|
||||
public:
|
||||
// constructor and destructor
|
||||
cdevIntHashIterator (cdevIntHash& v);
|
||||
~cdevIntHashIterator (void);
|
||||
|
||||
// iterator protocol
|
||||
int init (void);
|
||||
cdevHashItem operator ()(void);
|
||||
cdevHashItem getData (void);
|
||||
int operator ! (void);
|
||||
int operator ++(void);
|
||||
void operator = (cdevHashItem value);
|
||||
|
||||
protected:
|
||||
cdevIntHash& base;
|
||||
unsigned int currentIndex;
|
||||
// Single iterator within a bucket
|
||||
cdevSlistIterator* itr;
|
||||
// getNextIterator used to set internal iterator pointer
|
||||
// return 1: got it. return 0: no more iterator
|
||||
int getNextIterator (void);
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdev Monitoring Object class (for service developer only)
|
||||
//
|
||||
// This class is for services that support monitoring capabilities.
|
||||
// It is very much like transanaction object but without being registered
|
||||
// in the groups. The transaction objects will be deleted after the first
|
||||
// callbacks. The monitor objects will stay around as long as the monitors
|
||||
// are on.
|
||||
//
|
||||
// Service developers may have to derive from this class to handle
|
||||
// service specific monitoring
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevMonitorObj.h,v
|
||||
// Revision 1.4 1998/02/06 15:29:08 chen
|
||||
// cosmatic change
|
||||
//
|
||||
// Revision 1.3 1998/01/30 14:25:18 akers
|
||||
// Ongoing development
|
||||
//
|
||||
// Revision 1.2 1998/01/30 13:49:19 akers
|
||||
// Ongoing development
|
||||
//
|
||||
// Revision 1.1 1998/01/14 14:26:39 chen
|
||||
// add cdevMonitorObj
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_MONITOR_OBJ_H
|
||||
#define _CDEV_MONITOR_OBJ_H
|
||||
|
||||
#include <cdevTranObj.h>
|
||||
|
||||
class cdevMonitorObj
|
||||
{
|
||||
public:
|
||||
// constructor and destructor
|
||||
cdevMonitorObj(cdevTranObj &tranObj):system_(tranObj.system_),
|
||||
reqObj_(tranObj.reqObj_), resultData_(tranObj.resultData_),
|
||||
userCallback_(tranObj.userCallback_), tobj_(&tranObj)
|
||||
{
|
||||
#ifdef _TRACE_OBJECTS
|
||||
printf("Create cdevMonitorObj Class Object\n");
|
||||
#endif
|
||||
// disable transaction from deleting the callback
|
||||
tobj_->disableDeleteCbk();
|
||||
}
|
||||
|
||||
virtual ~cdevMonitorObj(void)
|
||||
{
|
||||
#ifdef _TRACE_OBJECTS
|
||||
printf("Delete cdevMonitorObj Class Object\n");
|
||||
#endif
|
||||
if(userCallback_ != 0)
|
||||
{
|
||||
#ifdef _CMLOG_DEBUG
|
||||
printf("Delete userCallback inside cdevMonitorObj\n");
|
||||
#endif
|
||||
delete userCallback_;
|
||||
}
|
||||
userCallback_=0;
|
||||
}
|
||||
|
||||
virtual const char *className(void) const {return"cdevMonitorObj";}
|
||||
|
||||
// data area for requestObject to access
|
||||
cdevSystem *system_;
|
||||
cdevRequestObject *reqObj_;
|
||||
cdevData *resultData_;
|
||||
cdevCallback *userCallback_;
|
||||
|
||||
// pointer to transaction object
|
||||
cdevTranObj *tobj_;
|
||||
|
||||
private:
|
||||
// deny access to copy and assignment
|
||||
cdevMonitorObj(const cdevMonitorObj &);
|
||||
cdevMonitorObj &operator=(const cdevMonitorObj &);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,127 @@
|
||||
#ifndef _CDEV_REDIRECTOR_DEFINITION_H_
|
||||
#define _CDEV_REDIRECTOR_DEFINITION_H_
|
||||
|
||||
#ifndef _CDEV_DIRECTORY_TABLE_H_
|
||||
#error "You must include cdevDirectoryTable.h to load cdevRedirectorDefinition.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevRedirectorDefinition :
|
||||
// * This class is used to store the information that identifies the
|
||||
// * service and service data that is associated with a specific message.
|
||||
// * This class is only instanciated in a cdevClassDefinition that has
|
||||
// * been instanciated.
|
||||
// *
|
||||
// * To reduce the number of copies of extraneous data, this class will
|
||||
// * use the service data that is stored in the cdevElementDefinition.
|
||||
// *****************************************************************************
|
||||
class cdevRedirectorDefinition
|
||||
{
|
||||
private:
|
||||
char * name;
|
||||
cdevServiceDefinition * service;
|
||||
char ** serviceData;
|
||||
int nItems;
|
||||
|
||||
public:
|
||||
inline cdevRedirectorDefinition ( char *Name, cdevElementDefinition &def);
|
||||
inline ~cdevRedirectorDefinition ( void );
|
||||
inline void asciiDump ( FILE * fp = stdout );
|
||||
|
||||
// *********************************************************************
|
||||
// * Member access methods
|
||||
// *********************************************************************
|
||||
inline char * getName ( void );
|
||||
inline cdevServiceDefinition * getService ( void );
|
||||
inline char ** getServiceData ( void );
|
||||
inline int getDataCnt ( void );
|
||||
};
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevRedirectorDefinition::cdevRedirectorDefinition :
|
||||
// * This is the constructor for the cdevRedirectorDefinition class... The
|
||||
// * message parameter becomes the property of the class and should not
|
||||
// * be accessed again by the caller...
|
||||
// *****************************************************************************
|
||||
inline cdevRedirectorDefinition::cdevRedirectorDefinition
|
||||
( char *Name, cdevElementDefinition &def)
|
||||
: name (Name),
|
||||
service (def.getService()),
|
||||
serviceData(def.getServiceData()),
|
||||
nItems (def.getDataCnt())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevRedirectorDefinition::~cdevRedirectorDefinition :
|
||||
// * This is the destructor for the cdevRedirectorDefinition object.
|
||||
// *****************************************************************************
|
||||
inline cdevRedirectorDefinition::~cdevRedirectorDefinition ( void )
|
||||
{
|
||||
delete name;
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevRedirectorDefinition::asciiDump :
|
||||
// * This is a diagnostic method that allows the caller to dump the contents
|
||||
// * of the class redirection table that identifies which service will
|
||||
// * be used for each message.
|
||||
// *****************************************************************************
|
||||
inline void cdevRedirectorDefinition::asciiDump ( FILE * fp )
|
||||
{
|
||||
fprintf(fp, "\t\t\"%s\" %s", name, service->getName());
|
||||
if(serviceData!=NULL && nItems>0)
|
||||
{
|
||||
fprintf(fp, " {");
|
||||
for(int i=0; i<nItems; i++)
|
||||
{
|
||||
if(i<nItems-1) fprintf(fp, " %s,", serviceData[i]);
|
||||
else fprintf(fp, " %s }", serviceData[i]);
|
||||
}
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevRedirectorDefinition::getName :
|
||||
// * Allows the caller to retrieve the name of the message within the object.
|
||||
// *****************************************************************************
|
||||
inline char * cdevRedirectorDefinition::getName ( void )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevRedirectorDefinition::getService :
|
||||
// * Allows the caller to retrieve the service associated with the message.
|
||||
// *****************************************************************************
|
||||
inline cdevServiceDefinition * cdevRedirectorDefinition::getService ( void )
|
||||
{
|
||||
return service;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevRedirectorDefinition::getServiceData :
|
||||
// * Allows the caller to retrieve the service data associated with the
|
||||
// * messages.
|
||||
// *****************************************************************************
|
||||
inline char ** cdevRedirectorDefinition::getServiceData ( void )
|
||||
{
|
||||
return serviceData;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevRedirectorDefinition::getDataCnt :
|
||||
// * Allows the caller to retrieve the number of entries in the service data.
|
||||
// *****************************************************************************
|
||||
inline int cdevRedirectorDefinition::getDataCnt ( void )
|
||||
{
|
||||
return nItems;
|
||||
}
|
||||
|
||||
#endif /* _CDEV_REDIRECTOR_DEFINITION_H_ */
|
||||
@@ -0,0 +1,294 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevRequestObject class (abstract class)
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevRequestObject.h,v
|
||||
// Revision 1.12 1998/02/13 14:00:44 chen
|
||||
// add ref and deref
|
||||
//
|
||||
// Revision 1.11 1997/03/03 17:52:26 chen
|
||||
// add buffering mechanism to caService
|
||||
//
|
||||
// Revision 1.9 1996/11/21 17:03:17 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.8 1996/03/22 16:33:26 chen
|
||||
// fix inline decleration
|
||||
//
|
||||
// Revision 1.7 1995/12/08 15:39:06 chen
|
||||
// add inline functions + deferred execution mode
|
||||
//
|
||||
// Revision 1.6 1995/10/17 15:28:00 chen
|
||||
// change getState and getAccess to virtual
|
||||
//
|
||||
// Revision 1.5 1995/10/03 19:34:01 chen
|
||||
// change public interface for system
|
||||
//
|
||||
// Revision 1.4 1995/09/19 16:10:35 chen
|
||||
// minor change on bit monitoring mechanism
|
||||
//
|
||||
// Revision 1.3 1995/09/18 18:21:58 chen
|
||||
// add long/short monitoring method
|
||||
//
|
||||
// Revision 1.2 1995/07/05 18:40:40 chen
|
||||
// remove system dependence on attachPtr etc
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:06 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_REQUESTOBJECT_H
|
||||
#define _CDEV_REQUESTOBJECT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <cdevIOcontext.h>
|
||||
#include <cdevService.h>
|
||||
#include <cdevSystem.h>
|
||||
#include <cdevGroup.h>
|
||||
#include <cdevDevice.h>
|
||||
#include <cdevData.h>
|
||||
|
||||
class cdevExecGroup;
|
||||
|
||||
//=======================================================================
|
||||
// some useful bit mask manipulation routines
|
||||
//=======================================================================
|
||||
#define NUMBITS_PER_BYTE 8
|
||||
|
||||
#ifdef _CDEV_NO_INLINE
|
||||
//=======================================================================
|
||||
// clear a long mask, set every bit to 0
|
||||
//=======================================================================
|
||||
extern void cdevMaskZero (long& p);
|
||||
|
||||
//=======================================================================
|
||||
// turn on a bit at position n inside the mask p
|
||||
//=======================================================================
|
||||
extern void cdevMaskSet (long n, long& p);
|
||||
|
||||
//=======================================================================
|
||||
// turn off a bit at position n inside the mask p
|
||||
//=======================================================================
|
||||
extern void cdevMaskClr (long n, long& p);
|
||||
|
||||
//=======================================================================
|
||||
// check whether a bit n is set or not
|
||||
//=======================================================================
|
||||
extern int cdevMaskIsSet (long n, long p);
|
||||
#endif
|
||||
|
||||
|
||||
class CDEV_CLASS_SPEC cdevRequestObject: public cdevIOcontext
|
||||
{
|
||||
public:
|
||||
//======================================================================
|
||||
// Public Interface for Clients
|
||||
//======================================================================
|
||||
static cdevRequestObject& attachRef (char *deviceName, char *msg);
|
||||
static cdevRequestObject* attachPtr (char *deviceName, char *msg);
|
||||
|
||||
// PURPOSE: Create or Attach Pointer or reference to a requestObject
|
||||
// inside the default system
|
||||
// REQUIRE: deviceName != 0, msg != 0.
|
||||
// PROMISE: return a cdevRequestObject which may be an errorRequestObject
|
||||
// depending on the device and message pair
|
||||
|
||||
static void detach (cdevRequestObject& objRef);
|
||||
static void detach (cdevRequestObject* objPtr);
|
||||
// PURPOSE: Detach from a cdevRequestObject
|
||||
// REQUIRE: objPtr != 0
|
||||
// PROMISE: If objPtr is the last one attached to a cdevRequestObject,
|
||||
// the cdevRequestObject will be destroyed
|
||||
|
||||
char *message (void) const;
|
||||
// PURPOSE: return message of this requestObject
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: a message
|
||||
|
||||
cdevDevice& device (void) const;
|
||||
// PURPOSE: return a refence a device holding this request object
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: reference of a device
|
||||
|
||||
cdevSystem& system (void) const;
|
||||
// PURPOSE: return a reference of a system associated with this object
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: reference of a system
|
||||
|
||||
cdevService& service (void) const;
|
||||
// PURPOSE: return a reference of a service associated with this object
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: reference of a service
|
||||
|
||||
virtual int getState (void);
|
||||
// PURPOSE: return status information, derived classes implement this
|
||||
// REQUIRE: nothing
|
||||
// PROMISE:
|
||||
|
||||
virtual int getAccess (void);
|
||||
// PURPOSE: return access control information, derived classes implement this
|
||||
// REQUIRE: nothing
|
||||
// PROMISE:
|
||||
|
||||
virtual int send (cdevData& out, cdevData& result) = 0;
|
||||
virtual int send (cdevData *out, cdevData& result) = 0;
|
||||
virtual int send (cdevData& out, cdevData* result) = 0;
|
||||
virtual int send (cdevData *out, cdevData* result) = 0;
|
||||
// PURPOSE: pure virtual functions for synchronous IO operations
|
||||
// REQUIRE: derived classes implement those
|
||||
// PROMISE: return CDEV_SUCCESS: success. See cdevErrCode.h for detail
|
||||
|
||||
virtual int sendNoBlock (cdevData& out, cdevData& result) = 0;
|
||||
virtual int sendNoBlock (cdevData *out, cdevData& result) = 0;
|
||||
virtual int sendNoBlock (cdevData& out, cdevData* result) = 0;
|
||||
virtual int sendNoBlock (cdevData* out, cdevData* result) = 0;
|
||||
// PURPOSE: pure virtual functions for asynchronous IO operations
|
||||
// REQUIRE:
|
||||
// PROMISE: return CDEV_SUCCESS: success. See cdevErrCode.h for detail
|
||||
|
||||
virtual int sendCallback (cdevData& out, cdevCallback& callback) = 0;
|
||||
virtual int sendCallback (cdevData *out, cdevCallback& callback) = 0;
|
||||
// PURPOSE: pure virtual functions for asynchronous IO operations with
|
||||
// user provided callback functions
|
||||
// REQUIRE:
|
||||
// PROMISE: return CDEV_SUCCESS: success. See cdevErrCode.h for detail
|
||||
|
||||
virtual int setContext (cdevData& cxt);
|
||||
// PURPOSE: set context from a cdevData. Check longMask
|
||||
// tag to set the bit monitoring mask
|
||||
// derived class may provide different setContext function
|
||||
// eg. channel access requestObject will use this function
|
||||
// to provide right request data type.
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0
|
||||
|
||||
|
||||
// for subclasss of cdevDevice use only
|
||||
void ref (void);
|
||||
// PURPOSE: Increase reference count of this requestobject by one
|
||||
// REQUIRE: none
|
||||
// PROMISE: refcount will go up by 1
|
||||
|
||||
void deref (void);
|
||||
// PURPOSE: decrease reference count of this requestobject by one
|
||||
// REQUIRE: none
|
||||
// PROMISE: refcount will go down by 1
|
||||
|
||||
|
||||
virtual const char *className (void) const {return "cdevRequestObject";}
|
||||
|
||||
protected:
|
||||
//constructors and destructors
|
||||
cdevRequestObject (char *device, char *msg,
|
||||
cdevSystem& system = cdevSystem::defaultSystem() );
|
||||
cdevRequestObject (cdevDevice &device, char *msg,
|
||||
cdevSystem& system = cdevSystem::defaultSystem() );
|
||||
virtual ~cdevRequestObject (void);
|
||||
|
||||
// protected version of send for service layer
|
||||
virtual int execNoBlock (cdevData* out, cdevData* result, void* arg);
|
||||
virtual int execCallback (cdevData* out, cdevCallback& callback, void* arg);
|
||||
|
||||
// protected to prevent use of multiple systems for now
|
||||
static cdevRequestObject& attachRef (char *deviceName,
|
||||
char *msg, cdevSystem& system);
|
||||
// PURPOSE: Create reference to a requestObject within a given system
|
||||
// REQUIRE: deviceName != 0, msg != 0.
|
||||
// PROMISE: return a cdevRequestObject which may be an errorRequestObject
|
||||
// depending on the device and message pair
|
||||
static cdevRequestObject* attachPtr (char *deviceName,
|
||||
char *msg, cdevSystem& system);
|
||||
// PURPOSE: Create pointer to a requestObject within a given system
|
||||
// REQUIRE: deviceName != 0, msg != 0.
|
||||
// PROMISE: return a cdevRequestObject or NULL if not a valid combination
|
||||
|
||||
// following routine used only by cdevDevice, and is the real factory
|
||||
static cdevRequestObject* attachPtr (cdevDevice& dev,
|
||||
char *msg, cdevSystem& system);
|
||||
// PURPOSE: Create pointer to a NEW requestObject within a given system
|
||||
// REQUIRE: dev != 0, msg != 0.
|
||||
// PROMISE: return a cdevRequestObject or NULL if not a valid combination
|
||||
|
||||
virtual int bitValuesChanged (long value, long mask);
|
||||
// PURPOSE: Check any bit values of 'value' changed or not according
|
||||
// to the mask 'mask'. Any derived classes of cdevRequestObject
|
||||
// may use this routine to monitor any set of bits in a long
|
||||
// integer value.
|
||||
// REQUIRE: none
|
||||
// PROMISE: if any bit values changed, return 1, else return 0
|
||||
|
||||
// assign device to the object
|
||||
void device (cdevDevice *dev);
|
||||
// assign service to the object
|
||||
void service (cdevService *service);
|
||||
|
||||
// internal functions for service developer who wants to support
|
||||
// deferred execution mode inside groups
|
||||
|
||||
// callback will be duplicated if indeed one needs to do defferred ops
|
||||
int deferExecution (cdevData* out, cdevData* result);
|
||||
int deferExecution (cdevData* out, cdevCallback* callback);
|
||||
int executionMode (void);
|
||||
|
||||
// internal functions for service developer who wants to support
|
||||
// buffering mechanism to improve performance
|
||||
// note: buffer must be derived class of cdevGroup
|
||||
|
||||
// callback will be duplicated
|
||||
void bufferExecution (cdevData* out, cdevData* result,
|
||||
cdevGroup* buffer, void* arg);
|
||||
void bufferExecution (cdevData* out, cdevCallback* result,
|
||||
cdevGroup* buffer, void* arg);
|
||||
|
||||
// device pointer
|
||||
cdevDevice *device_;
|
||||
// system reference
|
||||
cdevSystem& system_;
|
||||
// device name
|
||||
char *deviceName_;
|
||||
// message name
|
||||
char *message_;
|
||||
// service pointer
|
||||
cdevService *service_;
|
||||
// flag to tell whether to unregister from a device on delete
|
||||
int unregOn_;
|
||||
// bit monitoring mask
|
||||
long longMask_;
|
||||
|
||||
private:
|
||||
// copy and assignment
|
||||
cdevRequestObject& operator = (const cdevRequestObject& object);
|
||||
cdevRequestObject (const cdevRequestObject& object);
|
||||
|
||||
// reference counting
|
||||
int refCount_;
|
||||
|
||||
// friend class declaration
|
||||
friend class cdevDevice;
|
||||
friend class cdevSystem;
|
||||
friend class cdevExecGroup;
|
||||
};
|
||||
|
||||
#undef INLINE
|
||||
#ifndef _CDEV_NO_INLINE
|
||||
#define INLINE inline
|
||||
#include "cdevRequestObject.i"
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,154 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevRequestObject implementation (abstract class)
|
||||
// inline functions
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevRequestObject.i,v
|
||||
// Revision 1.3 1998/02/13 14:00:44 chen
|
||||
// add ref and deref
|
||||
//
|
||||
// Revision 1.2 1997/03/03 17:52:28 chen
|
||||
// add buffering mechanism to caService
|
||||
//
|
||||
// Revision 1.1 1995/12/08 15:39:43 chen
|
||||
// inline functions
|
||||
//
|
||||
//
|
||||
|
||||
// Note: How to determine to buffer an exeution object?
|
||||
// If an execution object belongs to a group with
|
||||
// an immediate execution mode, this object will not be
|
||||
// buffered. If an execution object belongs to a group
|
||||
// with a deferred execution mode, this execution object
|
||||
// will be buffered
|
||||
|
||||
INLINE
|
||||
int
|
||||
cdevRequestObject::deferExecution (cdevData* out, cdevData* result)
|
||||
{
|
||||
if (executionMode () == CDEV_EXEC_DEFERRED) {
|
||||
// create a transaction object
|
||||
cdevExecObj* obj = new cdevExecObj (&system_, this, out, result, 0);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
INLINE
|
||||
int
|
||||
cdevRequestObject::deferExecution (cdevData* out, cdevCallback* callback)
|
||||
{
|
||||
if (executionMode () == CDEV_EXEC_DEFERRED) {
|
||||
// create a transaction object with new copy of callback
|
||||
// must clone the data, as the caller did not
|
||||
cdevCallback *ccbk = new cdevCallback (*callback);
|
||||
cdevData *cloned = new cdevData(*out);
|
||||
cdevExecObj* obj = new cdevExecObj (&system_, this, cloned, 0, ccbk);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
INLINE
|
||||
void
|
||||
cdevRequestObject::bufferExecution (cdevData* out, cdevData* result,
|
||||
cdevGroup* group, void* arg)
|
||||
{
|
||||
// create an execution object that is registered to the group
|
||||
// caller has already cloned the data, so don't need to
|
||||
cdevExecObj* obj = new cdevExecObj (&system_, this, out, result, 0,
|
||||
group, arg);
|
||||
}
|
||||
|
||||
INLINE
|
||||
void
|
||||
cdevRequestObject::bufferExecution (cdevData* out, cdevCallback* callback,
|
||||
cdevGroup* group, void* arg)
|
||||
{
|
||||
// create an execution object that is registered to the group
|
||||
// caller has already cloned the data, so don't need to
|
||||
cdevExecObj* obj = new cdevExecObj (&system_, this, out, 0, callback,
|
||||
group, arg);
|
||||
}
|
||||
|
||||
INLINE
|
||||
int
|
||||
cdevRequestObject::execNoBlock (cdevData*, cdevData*, void* )
|
||||
{
|
||||
// empty: derived class handles this
|
||||
return CDEV_SUCCESS;
|
||||
}
|
||||
|
||||
INLINE
|
||||
int
|
||||
cdevRequestObject::execCallback (cdevData*, cdevCallback&, void* )
|
||||
{
|
||||
// empty: derived class handles this
|
||||
return CDEV_SUCCESS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// clear a long mask, set every bit to 0
|
||||
//=======================================================================
|
||||
INLINE
|
||||
void cdevMaskZero (long& p)
|
||||
{
|
||||
::memset ((char *)&p, (char)0, sizeof (long));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// turn on a bit at position n inside the mask p
|
||||
//=======================================================================
|
||||
INLINE
|
||||
void cdevMaskSet (long n, long& p)
|
||||
{
|
||||
assert ((n >= 0) && (n < sizeof (long) * NUMBITS_PER_BYTE));
|
||||
p |= 1 << n;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// turn off a bit at position n inside the mask p
|
||||
//=======================================================================
|
||||
INLINE
|
||||
void cdevMaskClr (long n, long& p)
|
||||
{
|
||||
assert ((n >= 0) && (n < sizeof (long) * NUMBITS_PER_BYTE));
|
||||
p &= ~(1 << n);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// check whether a bit n is set or not
|
||||
//=======================================================================
|
||||
INLINE
|
||||
int cdevMaskIsSet (long n, long p)
|
||||
{
|
||||
assert ((n >= 0) && (n < sizeof (long) * NUMBITS_PER_BYTE));
|
||||
return (p & (1 << n));
|
||||
}
|
||||
|
||||
INLINE
|
||||
void cdevRequestObject::ref (void)
|
||||
{
|
||||
refCount_ ++;
|
||||
}
|
||||
|
||||
INLINE
|
||||
void cdevRequestObject::deref (void)
|
||||
{
|
||||
refCount_ --;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
//---------------------------------------------------------------------------
|
||||
// Copyright (c) 1991,1992 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// description: cdevSelector.h
|
||||
// The cdevSelector class provides a mechanism for cdevServices to provide
|
||||
// a locally changable file descriptor to the cdevSystem for select
|
||||
// operations.
|
||||
//
|
||||
// If the service does not support or require file descriptors to operate,
|
||||
// it may make one of these objects in its constructor and then provide
|
||||
// the 'readfd' to the cdevSystem when it calls the services getFD method.
|
||||
// The service may then 'insertEvents' into the object, which will in-turn
|
||||
// cause the cdevSystems select mechanism to call the service. Once the
|
||||
// service has responded to the events it should call 'removeEvents' to
|
||||
// prevent the select mechanism from being triggered again.
|
||||
//
|
||||
// Author: Walt Akers
|
||||
//
|
||||
// Revision History:
|
||||
// cdevSelector.h,v
|
||||
// Revision 1.3 1996/12/05 21:10:49 akers
|
||||
// Changes to support multiple CDEV DDL versions
|
||||
//
|
||||
// Revision 1.2 1995/10/19 20:16:55 akers
|
||||
// Added capability to test the read file descriptor for data before reading
|
||||
//
|
||||
// Revision 1.1 1995/08/18 16:23:41 akers
|
||||
// Mechanism for providing file descriptor selection for services.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef _CDEV_SELECTOR_H_
|
||||
#define _CDEV_SELECTOR_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if defined(solaris) || defined(SunOS)
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
class cdevSelector
|
||||
{
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
int readfd;
|
||||
int writefd;
|
||||
} SocketPair;
|
||||
SocketPair sp;
|
||||
char cbuf[21];
|
||||
|
||||
public:
|
||||
cdevSelector ( void );
|
||||
~cdevSelector ( void );
|
||||
int insertEvent ( int numEvents = 1 );
|
||||
int removeEvent ( int numEvents = 1 );
|
||||
void purge ( void );
|
||||
int writefd ( void );
|
||||
int readfd ( void );
|
||||
};
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevSelector::cdevSelector :
|
||||
// * Constructor for the cdevSelector class.
|
||||
// *****************************************************************************
|
||||
inline cdevSelector::cdevSelector ( void )
|
||||
{
|
||||
if(pipe((int *)&sp)!=0)
|
||||
{
|
||||
sp.readfd = -1;
|
||||
sp.writefd = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int val;
|
||||
|
||||
val = ::fcntl(sp.readfd, F_GETFL, 0);
|
||||
if(val>0) ::fcntl(sp.readfd, F_SETFL, val|O_NONBLOCK);
|
||||
|
||||
val = ::fcntl(sp.writefd, F_GETFL, 0);
|
||||
if(val>0) ::fcntl(sp.writefd, F_SETFL, val|O_NONBLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevSelector::~cdevSelector :
|
||||
// * Destructor for the cdevSelector class.
|
||||
// *****************************************************************************
|
||||
inline cdevSelector::~cdevSelector ( void )
|
||||
{
|
||||
if(sp.readfd != -1) close(sp.readfd);
|
||||
if(sp.writefd != -1) close(sp.writefd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevSelector::insertEvent :
|
||||
// * Adds one or more bytes (indicating events) to the pipe
|
||||
// *****************************************************************************
|
||||
inline int cdevSelector::insertEvent ( int numEvents )
|
||||
{
|
||||
int result = 0;
|
||||
char *cptr = cbuf;
|
||||
|
||||
// *********************************************************************
|
||||
// * If the write file descriptor is valid
|
||||
// *********************************************************************
|
||||
if(sp.writefd>0)
|
||||
{
|
||||
// *************************************************************
|
||||
// * If the user wants to add more bytes than the buffer can
|
||||
// * handle, allocated a sufficient buffer to hold the data.
|
||||
// *************************************************************
|
||||
if(numEvents>20) cptr = new char[numEvents];
|
||||
|
||||
// *************************************************************
|
||||
// * Write the specified number of bytes to the buffer.
|
||||
// *************************************************************
|
||||
write(sp.writefd, cptr, numEvents);
|
||||
|
||||
// *************************************************************
|
||||
// * Delete the buffer if it was allocated locally.
|
||||
// *************************************************************
|
||||
if(cptr!=cbuf) delete cptr;
|
||||
}
|
||||
else result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevSelector::removeEvent :
|
||||
// * Removes one or more bytes (indicating events) from the pipe.
|
||||
// *****************************************************************************
|
||||
inline int cdevSelector::removeEvent ( int numEvents )
|
||||
{
|
||||
int result = 0;
|
||||
char *cptr = cbuf;
|
||||
|
||||
// *********************************************************************
|
||||
// * If the read file descriptor is valid.
|
||||
// *********************************************************************
|
||||
if(sp.readfd>0)
|
||||
{
|
||||
int count;
|
||||
// *************************************************************
|
||||
// * Find out how many bytes are ready to read.
|
||||
// *************************************************************
|
||||
ioctl(sp.readfd, FIONREAD, &count);
|
||||
if(numEvents>count) numEvents = count;
|
||||
|
||||
if(numEvents>0)
|
||||
{
|
||||
// *****************************************************
|
||||
// * If the user wants to remove more bytes than the
|
||||
// * buffer can handle, allocated a sufficient buffer to
|
||||
// * hold the data.
|
||||
// *****************************************************
|
||||
if(numEvents>20) cptr = new char[numEvents];
|
||||
|
||||
// *****************************************************
|
||||
// * Read the specified number of bytes from the pipe.
|
||||
// *****************************************************
|
||||
read(sp.readfd, cptr, numEvents);
|
||||
|
||||
// *****************************************************
|
||||
// * Delete the buffer if it was allocated locally.
|
||||
// *****************************************************
|
||||
if(cptr!=cbuf) delete cptr;
|
||||
}
|
||||
}
|
||||
else result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevSelector::purge :
|
||||
// * This function removes all bytes from the pipe.
|
||||
// *****************************************************************************
|
||||
inline void cdevSelector::purge ( void )
|
||||
{
|
||||
int count;
|
||||
char * cptr = cbuf;
|
||||
|
||||
if(sp.readfd>0)
|
||||
{
|
||||
// *************************************************************
|
||||
// * Find out how many bytes are ready to read.
|
||||
// *************************************************************
|
||||
ioctl(sp.readfd, FIONREAD, &count);
|
||||
|
||||
if(count>0)
|
||||
{
|
||||
// *****************************************************
|
||||
// * If the user wants to remove more bytes than the
|
||||
// * buffer can handle, allocated a sufficient buffer to
|
||||
// * hold the data.
|
||||
// *****************************************************
|
||||
if(count>20) cptr = new char[count];
|
||||
|
||||
// *****************************************************
|
||||
// * Read the specified number of bytes from the pipe.
|
||||
// *****************************************************
|
||||
read(sp.readfd, cptr, count);
|
||||
|
||||
// *****************************************************
|
||||
// * Delete the buffer if it was allocated locally.
|
||||
// *****************************************************
|
||||
if(cptr!=cbuf) delete cptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevSelector::writefd
|
||||
// * Returns the write file descriptor associated with the pipe.
|
||||
// *****************************************************************************
|
||||
inline int cdevSelector::writefd ( void )
|
||||
{
|
||||
return sp.writefd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevSelector::readfd
|
||||
// * Returns the read file descriptor associated with the pipe.
|
||||
// *****************************************************************************
|
||||
inline int cdevSelector::readfd ( void )
|
||||
{
|
||||
return sp.readfd;
|
||||
}
|
||||
|
||||
#endif /* _CDEV_SELECTOR_H_ */
|
||||
@@ -0,0 +1,92 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevSerice class (Abstract class )
|
||||
//
|
||||
// Author: Jie Chen, Chip Watson & Walt Akers
|
||||
//
|
||||
// Revision History:
|
||||
// cdevService.h,v
|
||||
// Revision 1.3 1997/08/27 18:23:32 chen
|
||||
// Change error reporting to site specific scheme
|
||||
//
|
||||
// Revision 1.2 1996/11/21 17:03:32 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:08 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_SERVICE_H
|
||||
#define _CDEV_SERVICE_H
|
||||
|
||||
#include "cdevSystemBase.h"
|
||||
#include "cdevSystem.h"
|
||||
|
||||
class cdevCollectionRequest;
|
||||
|
||||
class cdevDevice;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevService: public cdevSystemBase
|
||||
{
|
||||
public:
|
||||
virtual int getFd (int* &fd, int &numFd) = 0;
|
||||
// PURPOSE: get service's IO file descriptors
|
||||
// REQUIRE: callers provide pointer (eg. int *fd = 0;) no memory. callers
|
||||
// should never free memory pointed by fd. fd should be cached
|
||||
// inside derived class for easy/quick access
|
||||
// PROMISE: numFd >= 0
|
||||
|
||||
virtual int getNameServer (cdevDevice* &server) = 0;
|
||||
// PURPOSE: get right name server associated with this service
|
||||
// REQUIRE: caller provide pointer only, derived class provides
|
||||
// an empty function for now
|
||||
// PROMISE: not implemented yet
|
||||
|
||||
virtual int registerFd (int fd, int opened = 1);
|
||||
// PURPOSE: updating file descriptor mask
|
||||
// REQUIRE: opend = 1 for adding, else removing
|
||||
// PROMISE: return 0
|
||||
|
||||
virtual char *name (void) const;
|
||||
// PURPOSE: return name of this service
|
||||
// REQUIRE: name must be unique in one system
|
||||
// PROMISE: name
|
||||
|
||||
virtual int getCollectionRequest (char ** devices, int nDevices,
|
||||
char * msg, cdevCollectionRequest * &req);
|
||||
// PURPOSE: return collection requestobject
|
||||
// REQUIRE: devices != NULL, ndevices > 0
|
||||
// PROMISE: CDEV_SUCCESS on success, CDEV_ERROR no request object
|
||||
|
||||
const int version (void) const;
|
||||
// PURPOSE: return version of service
|
||||
// REQUIRE: none
|
||||
// PROMISE: version number of this service
|
||||
|
||||
virtual const char *className (void) const {return "cdevService";}
|
||||
|
||||
protected:
|
||||
// constructor: deny access for direct instantiation
|
||||
cdevService (char *name, cdevSystem &system = cdevSystem::defaultSystem ());
|
||||
// destructor, all services must be created and destroyed by system
|
||||
virtual ~cdevService (void);
|
||||
|
||||
// data area
|
||||
cdevSystem &system_;
|
||||
char *serviceName_;
|
||||
// flag to tell whether one unregister itself from system
|
||||
int unregOn_;
|
||||
// friend class decleration
|
||||
friend class cdevSystem;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
#ifndef _CDEV_SERVICE_DEFINITION_H_
|
||||
#define _CDEV_SERVICE_DEFINITION_H_
|
||||
|
||||
#ifndef _CDEV_DIRECTORY_TABLE_H_
|
||||
#error "You must include cdevDirectoryTable.h to load cdevServiceDefinition.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevServiceDefinition :
|
||||
// * This class stores a single CDEV service definition as defined in the
|
||||
// * DDL file. This data is managed by the cdevServiceList.
|
||||
// *
|
||||
// * This class maintains a variety of internal data items for the following
|
||||
// * purposes...
|
||||
// *
|
||||
// * name - This is the name of the service as specified in the
|
||||
// * CDEV DDL file.
|
||||
// * tags - These are the tags that will be used as service data when
|
||||
// * loading elements that use this service.
|
||||
// * nTags - This is the number of tags in the tags array.
|
||||
// * next - This is the next service that was loaded from the CDEV DDL
|
||||
// * file. This list is maintained in the cdevDirectoryTable
|
||||
// * object.
|
||||
// *****************************************************************************
|
||||
class cdevServiceDefinition
|
||||
{
|
||||
private:
|
||||
cdevServiceDefinition * next;
|
||||
char * name;
|
||||
char ** tags;
|
||||
int nTags;
|
||||
public:
|
||||
inline cdevServiceDefinition ( char *Name=NULL, char ** Tags=NULL, int NTags=0);
|
||||
inline ~cdevServiceDefinition ( void );
|
||||
inline void asciiDump ( FILE * fp = stdout );
|
||||
|
||||
// *********************************************************************
|
||||
// * Member access methods.
|
||||
// *********************************************************************
|
||||
inline char * getName ( void );
|
||||
inline char ** getTags ( void );
|
||||
inline int getTagCnt ( void );
|
||||
inline cdevServiceDefinition * getNext ( void );
|
||||
inline void setNext ( cdevServiceDefinition * Next );
|
||||
};
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevServiceDefinition::cdevServiceDefinition :
|
||||
// * This is the constructor for the cdevService defintion. It uses the
|
||||
// * following parameters:
|
||||
// *
|
||||
// * Name - the name of the service being added.
|
||||
// * Tags - the service data tags that will be used by each device.
|
||||
// * NTags - the number of tags in the list.
|
||||
// *****************************************************************************
|
||||
inline cdevServiceDefinition::cdevServiceDefinition ( char *Name, char ** Tags, int NTags)
|
||||
: next(NULL), name(Name), tags(Tags), nTags(NTags)
|
||||
{
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevServiceDefinition::cdevServiceDefinition :
|
||||
// * This is the destructor for the cdevServiceDefinition class. It will
|
||||
// * delete all data items that were provided to the constructor.
|
||||
// *****************************************************************************
|
||||
inline cdevServiceDefinition::~cdevServiceDefinition ( void )
|
||||
{
|
||||
if(name) delete name;
|
||||
while(--nTags>=0) delete tags[nTags];
|
||||
if(tags) delete tags;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevServiceDefinition::asciiDump :
|
||||
// * This method is used to write the contents of the service definition
|
||||
// * object to an ouput file.
|
||||
// *****************************************************************************
|
||||
inline void cdevServiceDefinition::asciiDump ( FILE * fp )
|
||||
{
|
||||
fprintf(fp, "\nservice %s\n\t{\n\t", name);
|
||||
if(tags && nTags)
|
||||
{
|
||||
int idx;
|
||||
fprintf(fp, "tags {");
|
||||
for(idx=0; idx<nTags-1; idx++)
|
||||
{
|
||||
fprintf(fp, "%s, ", tags[idx]);
|
||||
}
|
||||
fprintf(fp, "%s}\n\t", tags[idx]);
|
||||
}
|
||||
fprintf(fp, "}\n");
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevServiceDefinition::getName :
|
||||
// * This method allows the caller to retrieve the name of the class.
|
||||
// *****************************************************************************
|
||||
inline char * cdevServiceDefinition::getName ( void )
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevServiceDefinition::getTags :
|
||||
// * This method allows the caller to retrieve the tag names.
|
||||
// *****************************************************************************
|
||||
inline char ** cdevServiceDefinition::getTags ( void )
|
||||
{
|
||||
return tags;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevServiceDefinition::getTagCnt :
|
||||
// * This method allows the caller to retrieve the number of tag names.
|
||||
// *****************************************************************************
|
||||
inline int cdevServiceDefinition::getTagCnt ( void )
|
||||
{
|
||||
return nTags;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevServiceDefinition::getNext :
|
||||
// * This method allows the caller to retrieve the next service definition
|
||||
// * in the list.
|
||||
// *****************************************************************************
|
||||
inline cdevServiceDefinition * cdevServiceDefinition::getNext ( void )
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * cdevServiceDefinition::setNext :
|
||||
// * This method allows the caller to set the next service definition in the
|
||||
// * list.
|
||||
// *****************************************************************************
|
||||
inline void cdevServiceDefinition::setNext ( cdevServiceDefinition * Next )
|
||||
{
|
||||
next = Next;
|
||||
}
|
||||
|
||||
#endif /* _CDEV_SERVICE_DEFINITION_H_ */
|
||||
@@ -0,0 +1,225 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// Single Linked List for pointers void *
|
||||
//
|
||||
// Note: remove and clean operations on the list
|
||||
// will only remove link nodes without removal of
|
||||
// the content inside the nodes. It is callers'
|
||||
// responsiblity to clean up those contents
|
||||
//
|
||||
// This is unsafe C++ practice, use this list at you own risk
|
||||
//
|
||||
// Reason for this list: It is very difficult to instantiate
|
||||
// a template class in a stand alone shared library
|
||||
//
|
||||
// Author: Jie Chen
|
||||
// CEBAF Data Acquisition Group
|
||||
//
|
||||
// Revision History:
|
||||
// cdevSlist.h,v
|
||||
// Revision 1.2 1996/11/21 17:03:09 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.1 1995/06/30 15:08:00 chen
|
||||
// single linked list for void *
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_SLIST_H
|
||||
#define _CDEV_SLIST_H
|
||||
|
||||
#include <cdevSpec.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef void* cdevSlistItem;
|
||||
|
||||
//======================================================================
|
||||
// class cdevGenSlist
|
||||
// Single Linked List for void* pointer
|
||||
//======================================================================
|
||||
class cdevSlistLink;
|
||||
class cdevSlistIterator;
|
||||
class cdevSlistCursor;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevSlist
|
||||
{
|
||||
public:
|
||||
// constructors
|
||||
cdevSlist (void);
|
||||
cdevSlist (const cdevSlist & source);
|
||||
virtual ~cdevSlist (void);
|
||||
|
||||
// operations
|
||||
|
||||
// add list item to the beginning of the list
|
||||
virtual void add(cdevSlistItem value);
|
||||
|
||||
// remove a list item from the list
|
||||
// return 0: nothing to remove
|
||||
// return 1: remove success
|
||||
virtual int remove (cdevSlistItem value);
|
||||
|
||||
// clean up the list.
|
||||
virtual void deleteAllValues();
|
||||
|
||||
// return first element of the list
|
||||
virtual cdevSlistItem firstElement() const;
|
||||
|
||||
// return last element of the list
|
||||
virtual cdevSlistItem lastElement() const;
|
||||
|
||||
// duplicate ths whole list
|
||||
virtual cdevSlist* duplicate() const;
|
||||
|
||||
// check whether this list contains a particular item
|
||||
// return 1: yes. return 0: no
|
||||
virtual int includes(cdevSlistItem value) const;
|
||||
|
||||
// Is list empty
|
||||
// return 1: yes. return 0: no
|
||||
virtual int isEmpty() const;
|
||||
|
||||
// remove first element of the list
|
||||
virtual void removeFirst();
|
||||
|
||||
// return number of elements inside the list
|
||||
virtual int count() const;
|
||||
|
||||
protected:
|
||||
// data field
|
||||
cdevSlistLink* ptrToFirstLink;
|
||||
|
||||
// friends
|
||||
friend class cdevSlistIterator;
|
||||
// cannot modify list in anyways
|
||||
friend class cdevSlistCursor;
|
||||
};
|
||||
|
||||
//======================================================================
|
||||
// class cdevSlistLink
|
||||
// Single linked list link node
|
||||
//======================================================================
|
||||
class CDEV_CLASS_SPEC cdevSlistLink
|
||||
{
|
||||
public:
|
||||
// insert a new element following the current value
|
||||
cdevSlistLink* insert (cdevSlistItem val);
|
||||
|
||||
private:
|
||||
// constructor
|
||||
cdevSlistLink (cdevSlistItem linkValue, cdevSlistLink * nextPtr);
|
||||
|
||||
// duplicate
|
||||
cdevSlistLink* duplicate (void);
|
||||
|
||||
// data areas
|
||||
cdevSlistItem value;
|
||||
cdevSlistLink* ptrToNextLink;
|
||||
|
||||
// friends
|
||||
friend class cdevSlist;
|
||||
friend class cdevSlistIterator;
|
||||
friend class cdevSlistCursor;
|
||||
};
|
||||
|
||||
//===================================================================
|
||||
// class cdevSlistIterator
|
||||
// implements iterator protocol for linked lists
|
||||
// also permits removal and addition of elements
|
||||
//===================================================================
|
||||
class CDEV_CLASS_SPEC cdevSlistIterator
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
cdevSlistIterator (cdevSlist& aList);
|
||||
|
||||
// iterator protocol
|
||||
virtual int init (void);
|
||||
virtual cdevSlistItem operator () (void);
|
||||
virtual int operator ! (void);
|
||||
virtual int operator ++ (void);
|
||||
virtual void operator = (cdevSlistItem value);
|
||||
|
||||
// new methods specific to list iterators
|
||||
|
||||
// remove current item pointed by the iterator from the list
|
||||
void removeCurrent(void);
|
||||
|
||||
// add an item to the list before the position pointed by the iterator
|
||||
void addBefore(cdevSlistItem newValue);
|
||||
|
||||
// add an item to the list after the position pointed by the iterator
|
||||
void addAfter(cdevSlistItem newValue);
|
||||
|
||||
// search an item and move the iterator to that position
|
||||
int searchSame(cdevSlistItem &value);
|
||||
|
||||
protected:
|
||||
// data areas
|
||||
cdevSlistLink * currentLink;
|
||||
cdevSlistLink * previousLink;
|
||||
cdevSlist& theList;
|
||||
};
|
||||
|
||||
//===================================================================
|
||||
// class cdevSlistCursor
|
||||
// implements cursor protocol for linked lists
|
||||
//===================================================================
|
||||
class CDEV_CLASS_SPEC cdevSlistCursor
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
cdevSlistCursor (const cdevSlist& aList);
|
||||
|
||||
// iterator protocol
|
||||
virtual int init (void);
|
||||
virtual cdevSlistItem operator () (void);
|
||||
virtual int operator ! (void);
|
||||
virtual int operator ++ (void);
|
||||
virtual void operator = (cdevSlistItem value);
|
||||
|
||||
int searchSame (cdevSlistItem &value);
|
||||
|
||||
protected:
|
||||
// data areas
|
||||
cdevSlistLink * currentLink;
|
||||
cdevSlistLink * previousLink;
|
||||
const cdevSlist& theList;
|
||||
};
|
||||
|
||||
//======================================================================
|
||||
// class doubleEndedList
|
||||
// Not only keeps a pointer to first node
|
||||
// but also keeps a pointer to last node
|
||||
//======================================================================
|
||||
class CDEV_CLASS_SPEC cdevDoubleEndedSlist: public cdevSlist{
|
||||
public:
|
||||
//constructor
|
||||
cdevDoubleEndedSlist (void);
|
||||
cdevDoubleEndedSlist (const cdevDoubleEndedSlist &v);
|
||||
|
||||
// override the following methods from the cdevSlist
|
||||
virtual void add (cdevSlistItem value);
|
||||
virtual void deleteAllValues (void);
|
||||
virtual void removeFirst (void);
|
||||
|
||||
// add new element to the end of the list
|
||||
virtual void addToEnd (cdevSlistItem value);
|
||||
|
||||
protected:
|
||||
cdevSlistLink *ptrToLastLink;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
*-----------------------------------------------------------------------------
|
||||
*
|
||||
* Description:
|
||||
* Cdev and API Specification
|
||||
*
|
||||
* Every class header file and C interface header should include
|
||||
* this header
|
||||
*
|
||||
* Authors: Jie Chen
|
||||
*
|
||||
* Revision History:
|
||||
* $Log: cdevSpec.h,v $
|
||||
* Revision 1.1.1.1 2000/05/23 15:13:04 pal
|
||||
* cdev_psi_1.7.2
|
||||
*
|
||||
* Revision 1.2 1999/01/15 17:30:20 akers
|
||||
* Adjustment
|
||||
*
|
||||
* Revision 1.1 1999/01/14 17:21:24 chen
|
||||
* CDEV Class and API Spec Class for WIN32
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef _CDEV_SPEC_H
|
||||
#define _CDEV_SPEC_H
|
||||
|
||||
#if defined (_WIN32)
|
||||
|
||||
#if !defined (DLLIMPORT)
|
||||
#define DLLIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if !defined (DLLEXPORT)
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
#if defined (_CDEV_CORE_EXPORTS_)
|
||||
#define CDEVAPI DLLEXPORT
|
||||
#define CDEV_CLASS_SPEC DLLEXPORT
|
||||
#define CDEVSVC_CLASS_SPEC
|
||||
#define CDEVSVCAPI
|
||||
#elif defined (_CDEV_BUILD_SVC)
|
||||
#define CDEVAPI DLLIMPORT
|
||||
#define CDEV_CLASS_SPEC DLLIMPORT
|
||||
#define CDEVSVC_CLASS_SPEC DLLEXPORT
|
||||
#define CDEVSVCAPI DLLEXPORT
|
||||
#else
|
||||
#define CDEVAPI DLLIMPORT
|
||||
#define CDEV_CLASS_SPEC DLLIMPORT
|
||||
#define CDEVSVC_CLASS_SPEC
|
||||
#define CDEVSVCAPI
|
||||
#endif
|
||||
|
||||
#else /* WIN32 */
|
||||
|
||||
#define CDEVAPI
|
||||
#define DLLIMPORT
|
||||
#define DLLEXPORT
|
||||
#define CDEV_CLASS_SPEC
|
||||
#define CDEVSVC_CLASS_SPEC
|
||||
#define CDEVSVCAPI
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
// CEBAF Data Acquisition Group, 12000 Jefferson Ave., Newport News, VA 23606
|
||||
// Email: coda@cebaf.gov Tel: (804) 249-7101 Fax: (804) 249-7363
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevStrHash: cdev hash table keyed by a variable length string
|
||||
// Open Hash with buckets implemented by single linked lists
|
||||
//
|
||||
// Note: void *s are stored inside the table. This class
|
||||
// will not manage these pointers. Callers have to
|
||||
// manage these pointers
|
||||
//
|
||||
// Note: this is unsafe C++ practice. Use at your own risk
|
||||
//
|
||||
// Reason: It is so difficult to use a template class inside
|
||||
// a shared library. (Cfront based C++ compiler cannot
|
||||
// instantiate a template class during compilation time
|
||||
//
|
||||
// Author: Jie Chen
|
||||
// CEBAF Data Acquisition Group
|
||||
//
|
||||
// Revision History:
|
||||
// cdevStrHash.h,v
|
||||
// Revision 1.3 1996/08/26 21:12:38 akers
|
||||
// Added getData method to iterator
|
||||
//
|
||||
// Revision 1.2 1995/07/05 18:38:30 chen
|
||||
// add simple str hash function
|
||||
//
|
||||
// Revision 1.1 1995/06/30 15:08:42 chen
|
||||
// string hash table
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_STR_HASH_H
|
||||
#define _CDEV_STR_HASH_H
|
||||
|
||||
#include <cdevSlist.h>
|
||||
|
||||
//======================================================================
|
||||
// One simple string hash function
|
||||
// This hash function is used in cdevDevice and caChannel.
|
||||
// It returns integer value between 0 to MAX_INTEGER_VALUE
|
||||
// and this value will be moded with the size of the hash
|
||||
// table.
|
||||
// It may be changed to a different hash function in
|
||||
// release 1.1
|
||||
//======================================================================
|
||||
extern CDEVAPI unsigned int cdevStrHashFunc (char *str);
|
||||
|
||||
typedef char* cdevKeyItem;
|
||||
typedef void* cdevHashItem;
|
||||
|
||||
//======================================================================
|
||||
// class cdevStrHash
|
||||
// collection of buckets indexed by hashed values
|
||||
//======================================================================
|
||||
class cdevStrHashIterator;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevStrHash
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
// construct a table with entry max and hash function *f
|
||||
// hash function return any integer from 0 to MAX_INT_VALUE
|
||||
cdevStrHash (unsigned int max, unsigned int (*f)(cdevKeyItem));
|
||||
// destructor
|
||||
virtual ~cdevStrHash (void);
|
||||
|
||||
// operations
|
||||
|
||||
// is the table empty: return 1: yes. return 0: no
|
||||
virtual int isEmpty();
|
||||
|
||||
// clear the elements of the set
|
||||
virtual void deleteAllValues();
|
||||
|
||||
// add an element to the collection
|
||||
virtual void add (cdevKeyItem key, cdevHashItem ele);
|
||||
|
||||
// test to see whether this hash table includes one particular element
|
||||
virtual int find (cdevKeyItem key, cdevHashItem ele) const;
|
||||
|
||||
// remove an element. return 0: ele is not inside table. return 1: success
|
||||
virtual int remove (cdevKeyItem key, cdevHashItem ele);
|
||||
|
||||
// return a reference to a particular bucket according to the key
|
||||
cdevSlist& bucketRef (cdevKeyItem key);
|
||||
|
||||
protected:
|
||||
friend class cdevStrHashIterator;
|
||||
|
||||
// the actual table itself is a vector of buckets
|
||||
const unsigned int tablesize;
|
||||
cdevSlist* buckets;
|
||||
|
||||
// convert key into unsigned integer value in range
|
||||
unsigned int hash(const cdevKeyItem& key) const;
|
||||
|
||||
private:
|
||||
unsigned int (*hashCode_)(cdevKeyItem);
|
||||
};
|
||||
|
||||
//======================================================================
|
||||
// class cdevStrHashIterator
|
||||
// iterator protocol for hash tables
|
||||
//======================================================================
|
||||
class CDEV_CLASS_SPEC cdevStrHashIterator
|
||||
{
|
||||
public:
|
||||
// constructor and destructor
|
||||
cdevStrHashIterator (cdevStrHash& v);
|
||||
~cdevStrHashIterator (void);
|
||||
|
||||
// iterator protocol
|
||||
int init (void);
|
||||
cdevHashItem operator ()(void);
|
||||
cdevHashItem getData (void);
|
||||
int operator ! (void);
|
||||
int operator ++(void);
|
||||
void operator = (cdevHashItem value);
|
||||
|
||||
protected:
|
||||
cdevStrHash& base;
|
||||
unsigned int currentIndex;
|
||||
// Single iterator within a bucket
|
||||
cdevSlistIterator* itr;
|
||||
// getNextIterator used to set internal iterator pointer
|
||||
// return 1: got it. return 0: no more iterator
|
||||
int getNextIterator (void);
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevSvcFinder class (Bind a service from a service name)
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevSvcFinder.h,v
|
||||
// Revision 1.5 1997/08/18 14:16:31 akers
|
||||
// Ongoing development of CDEV accounting
|
||||
//
|
||||
// Revision 1.4 1997/08/15 18:08:33 akers
|
||||
// Addition of CDEV Accounting
|
||||
//
|
||||
// Revision 1.3 1995/09/20 16:22:21 chen
|
||||
// Change findService to virtual
|
||||
//
|
||||
// Revision 1.2 1995/06/30 16:01:35 chen
|
||||
// use generic list
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:07 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_SVC_FINDER_H
|
||||
#define _CDEV_SVC_FINDER_H
|
||||
|
||||
#include <cdevSystem.h>
|
||||
#include <shObjLoader.h>
|
||||
#include <cdevSlist.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevSvcFinder
|
||||
{
|
||||
public:
|
||||
//constructor and destrcutor
|
||||
cdevSvcFinder(cdevSystem & system = cdevSystem::defaultSystem());
|
||||
~cdevSvcFinder (void);
|
||||
|
||||
int getService(char *serviceName, cdevService* &service);
|
||||
// PURPOSE: get or load a service into system
|
||||
// REQUIRE: serviceName != 0 and callers provide pointer service
|
||||
// PROMISE: return 0: service loaded. return -1: failure
|
||||
|
||||
private:
|
||||
// deny assignment and copy
|
||||
cdevSvcFinder (const cdevSvcFinder& src);
|
||||
cdevSvcFinder& operator = (const cdevSvcFinder& src);
|
||||
// internal functions
|
||||
|
||||
#ifdef SHOBJ
|
||||
cdevService *loadService (char *serviceName);
|
||||
#else
|
||||
virtual cdevService *findService (char *serviceName);
|
||||
#endif
|
||||
// data area
|
||||
cdevSlist ldList_;
|
||||
cdevSystem& system_;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,139 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevSync class (abstract base class)
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevSync.h,v
|
||||
// Revision 1.3 1997/02/18 15:45:43 chen
|
||||
// port to linux 2.0.x + addUserFdCallback
|
||||
//
|
||||
// Revision 1.2 1996/03/22 17:57:45 chen
|
||||
// change attach/detach ReadFd to virtual
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:08 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_SYNC_H
|
||||
#define _CDEV_SYNC_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevFdSet.h>
|
||||
#include <cdevTimeValue.h>
|
||||
|
||||
class CDEV_CLASS_SPEC cdevSync{
|
||||
public:
|
||||
// destructors
|
||||
virtual ~cdevSync (void);
|
||||
|
||||
virtual int flush (void) = 0;
|
||||
// PURPOSE: pure virtual function to define intreface for net flush
|
||||
// REQUIRE: derived class provide implementation
|
||||
// PROMISE: return CDEV_SUCCESS
|
||||
|
||||
virtual int poll (void) = 0;
|
||||
// PURPOSE: pure virtual function to define intreface for polling method
|
||||
// REQUIRE: derived class provide implementation
|
||||
// PROMISE: return CDEV_SUCCESS: OK. return -1: network error
|
||||
|
||||
virtual int pend (int fd = -1) = 0;
|
||||
// PURPOSR: pure virtual function to define interface for pending method
|
||||
// REQUIRE: derived class provide implementation
|
||||
// PROMISE: return CDEV_SUCCESS, OK, return -1: network error
|
||||
|
||||
virtual int pend (double seconds, int fd = -1) = 0;
|
||||
// PURPOSR: pure virtual function to define interface for pending method
|
||||
// REQUIRE: derived class provide implementation
|
||||
// PROMISE: return CDEV_SUCCESS, OK, return CDEV_TIMEOUT: timeout.
|
||||
// -1: network error
|
||||
|
||||
virtual const char *className (void) const {return "cdevSync";}
|
||||
|
||||
protected:
|
||||
// constructor
|
||||
cdevSync (void);
|
||||
|
||||
virtual int attachReadFd (int fd);
|
||||
// PURPOSE: add a new file descriptor to mask
|
||||
// REQURIE: fd > 3. You know what I mean
|
||||
// PROMISE: return 0 success
|
||||
|
||||
virtual int detachReadFd (int fd);
|
||||
// PURPOSE: remove a file descriptor from the mask
|
||||
// REQUIRE: fd > 3
|
||||
// PROMISE: return 0 success
|
||||
|
||||
int handleEvents (void);
|
||||
// PURPOSE: wait until IO events arrive and dispatch IO events
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0: success, -1: error
|
||||
|
||||
virtual int handleEvents (cdevTimeValue *tv);
|
||||
// PURPOSE: handle IO events for upto 'tv' long
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0: success at least one IO event occured, 1: timeout
|
||||
|
||||
int waitFor (cdevFdSet &rmaskret,
|
||||
cdevFdSet &wmaskret,
|
||||
cdevFdSet &emaskret,
|
||||
cdevTimeValue *how_long);
|
||||
// PURPOSE: Wait for IO events to occur upto time 'how_long'
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: >0 IO event ready. 0 nothing, timeout
|
||||
|
||||
void dispatch (int nfound,
|
||||
cdevFdSet &rmaskret,
|
||||
cdevFdSet &wmaskret,
|
||||
cdevFdSet &emaskret);
|
||||
// PURPOSE: dispath IO events to the appropriate service
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: dispatched
|
||||
|
||||
virtual void notifyService (int handle);
|
||||
// PURPOSE: notify low level service there are IO events
|
||||
// REQUIRE: derived class does real implementation
|
||||
// PROMISE: nothing
|
||||
|
||||
int handleError (void);
|
||||
// PURPOSE: handle interrupt error while waiting for IO events
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 1: interrupt or bad file descriptor, return -1: error
|
||||
|
||||
int checkFds (void);
|
||||
// PURPOSE: check whether file descriptors are valid
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 1 always
|
||||
|
||||
int checkFd (int fd);
|
||||
// PURPOSE: check whether file descriptor fd is valid
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 0 success, -1, failure
|
||||
|
||||
int maxHandle (int i, int j, int k);
|
||||
// PURPOSE: utility to calculate maximum of there integers
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: maximum of there integers
|
||||
|
||||
// File Descriptor Mask for IO Multiplexing
|
||||
cdevFdSet rdMask_;
|
||||
cdevFdSet wrMask_;
|
||||
cdevFdSet exMask_;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,466 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevSystem class
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevSystem.h,v
|
||||
// Revision 1.18 1998/02/13 14:23:06 chen
|
||||
// add fall through service behaviour
|
||||
//
|
||||
// Revision 1.17 1998/02/10 18:05:47 chen
|
||||
// add add/removeTimer to the system
|
||||
//
|
||||
// Revision 1.16 1997/12/12 16:39:42 chen
|
||||
// add fix for VMS
|
||||
//
|
||||
// Revision 1.15 1997/08/27 18:23:33 chen
|
||||
// Change error reporting to site specific scheme
|
||||
//
|
||||
// Revision 1.14 1997/08/07 13:36:33 akers
|
||||
// Converted CDEV_MAJOR_VERSION and CDEV_MINOR_VERSION to strings to support adding minor revision numbers
|
||||
//
|
||||
// Revision 1.13 1997/03/25 22:24:43 akers
|
||||
// Development in support of a new cdevDirectory
|
||||
//
|
||||
// Revision 1.12 1997/03/03 17:35:47 chen
|
||||
// add buffering to channel access connection
|
||||
//
|
||||
// Revision 1.10 1997/01/29 17:39:38 akers
|
||||
// Removed assertion from cdevSystem
|
||||
//
|
||||
// Revision 1.9 1996/11/21 17:03:34 akers
|
||||
// Ongoing Developement of CDEV 1.5
|
||||
//
|
||||
// Revision 1.8 1996/09/20 12:24:58 akers
|
||||
// Changes added for Release 1.4
|
||||
//
|
||||
// Revision 1.7 1996/04/05 22:02:24 chen
|
||||
// fix static enum problem with gcc
|
||||
//
|
||||
// Revision 1.6 1996/03/27 16:03:10 akers
|
||||
// Added CDEV_MAJOR_VERSION and CDEV_MINOR_VERSION to the cdevSystem object
|
||||
//
|
||||
// Revision 1.5 1996/03/22 17:57:00 chen
|
||||
// add cdevFdChangedCallback
|
||||
//
|
||||
// Revision 1.4 1995/10/05 18:40:45 chen
|
||||
// Move destructor to public, static needs it
|
||||
//
|
||||
// Revision 1.3 1995/07/05 18:45:41 chen
|
||||
// allow access to devices etc...
|
||||
//
|
||||
// Revision 1.2 1995/06/30 16:06:26 chen
|
||||
// remove all unnecessary files and use a genric list and hash
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:08 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_SYSTEM_H
|
||||
#define _CDEV_SYSTEM_H
|
||||
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevVersion.h>
|
||||
#include <cdevSlist.h>
|
||||
#include <cdevStrHash.h>
|
||||
#include <cdevSystemBase.h>
|
||||
#include <cdevTimerQueue.h>
|
||||
|
||||
#ifdef __VMS
|
||||
extern "C" {
|
||||
char* strdup (char *s);
|
||||
char* mkstemp (char *s);
|
||||
int htonl (int a);
|
||||
int ntohl (int a);
|
||||
};
|
||||
#endif
|
||||
|
||||
class cdevService;
|
||||
class cdevDevice;
|
||||
class cdevRequestObject;
|
||||
class cdevErrReqObject;
|
||||
class cdevDirectory;
|
||||
class cdevGroup;
|
||||
class cdevExecGroup;
|
||||
class cdevSvcFinder;
|
||||
class cdevTranObj;
|
||||
class cdevCallback;
|
||||
class cdevErrSvc;
|
||||
class cdevConfigFinder;
|
||||
|
||||
// maximum number of groups inside a system
|
||||
const int MAX_NUM_GROUPS = 5;
|
||||
|
||||
// file descriptor changed callback
|
||||
// opened = 1, newly opend fd, opened = 0, closed fd
|
||||
typedef void (*cdevFdChangedCallback) (int fd, int opened,
|
||||
void *arg);
|
||||
|
||||
// arbitrary user fd callback (user let cdev to minitor his/her's fd)
|
||||
// opened = 1, ok, opened = 0, fd is bad fd
|
||||
// user should return 0: for success reading, -1: for failure
|
||||
typedef int (*cdevUserFdCallback) (int opened, int fd, void *arg);
|
||||
|
||||
// define user fd callback handler id
|
||||
typedef long cdevUserFdCbkId;
|
||||
|
||||
|
||||
class CDEV_CLASS_SPEC cdevSystem: public cdevSystemBase
|
||||
{
|
||||
public:
|
||||
// ***************************************************************************
|
||||
// * The CDEV_MAJOR_VERSION and CDEV_MINOR_VERSION variables are used to
|
||||
// * identify the version of CDEV shared objects that should be used.
|
||||
// ***************************************************************************
|
||||
|
||||
// WARNING: these two strings are deprecated in 1.7.x, and will be
|
||||
// removed in 1.8, and replace with a single version string.
|
||||
|
||||
static const char *CDEV_MAJOR_VERSION;
|
||||
static const char *CDEV_MINOR_VERSION;
|
||||
|
||||
//==============================================================
|
||||
// Public interface for clients
|
||||
//==============================================================
|
||||
static cdevSystem& attachRef (char *name, char *prefix = 0);
|
||||
static cdevSystem* attachPtr (char *name, char *prefix = 0);
|
||||
// PURPOSE: cdevSystem creation factory
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return system reference or pointer
|
||||
|
||||
cdevDevice* getDevice (char *device);
|
||||
// PURPOSE: create a cdevDevice
|
||||
// REQUIRE: device != 0
|
||||
// PROMISE: return a pointer to a cdevDevice
|
||||
|
||||
char *name (void) const;
|
||||
// PURPOSE: return name of this system
|
||||
// REQUIRE: callers don't free memory
|
||||
// PROMISE: name of this system
|
||||
|
||||
char *prefix (void) const;
|
||||
// PURPOSE: return prefix of this system
|
||||
// REQUIRE: callers don't free memory
|
||||
// PROMISE: prefix of this syste,
|
||||
|
||||
void prefix (char *pre);
|
||||
// PURPOSE: set prefix to this system
|
||||
// REQUIRE: pre != 0
|
||||
// PROMISE: old prefix will be overwritten by new one
|
||||
|
||||
virtual int flush (void);
|
||||
// PURPOSE: flush all network request to all services
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return CDEV_SUCCESS
|
||||
|
||||
virtual int poll (void);
|
||||
// PURPOSE: poll all network services
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return CDEV_SUCCESS
|
||||
|
||||
virtual int pend (int fd = -1);
|
||||
// PURPOSE: pend all network services and dispatch IO event to right services
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return CDEV_SUCCESS
|
||||
|
||||
virtual int pend (double seconds, int fd = -1);
|
||||
// PURPOSE: pend all network services for 'seconds' time long.
|
||||
// Dispatch IO event to right services
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return CDEV_SUCCESS or CDEV_TIMEOUT
|
||||
|
||||
static cdevSystem &defaultSystem (void);
|
||||
// PURPOSE: Caller access to default system which is created automatically
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return the same system everytime one calls this
|
||||
|
||||
void finalize (void);
|
||||
// PURPOSE: clean up all system resources
|
||||
// REQUIRE: last routine to call before quitting
|
||||
// PROMISE: nothing
|
||||
|
||||
int getFd (int fd[], int &numFD);
|
||||
// PURPOSE: provide file descriptors to other system such as X window
|
||||
// REQUIRE: user provide big enough integer buffer and buffer size
|
||||
// PROMISE: numFD is real number of fds of success return CDEV_SUCCESS.
|
||||
// return CDEV_INVALIDARG: not big enoght buffer
|
||||
|
||||
int addFdChangedCallback (cdevFdChangedCallback cbk, void* arg);
|
||||
// PURPOSE: provide file descriptor callback mechanism
|
||||
// REQUIRE: none
|
||||
// PROMISE: if lower cdevServices provide system any notification of
|
||||
// fd changes, the system will call all registered callbacks
|
||||
|
||||
int addUserFdCallback (int fd, cdevUserFdCallback cbk, void* arg,
|
||||
cdevUserFdCbkId& id);
|
||||
// PURPOSE: add user fd to system fd list, when there is something
|
||||
// to be read at this fd, the user callback will be executed
|
||||
// REQUIRE: none
|
||||
// PROMISE: if fd is already inside the managed fd list, returns
|
||||
// CDEV_INVALIDARG. if fd is a bad fd, returns CDEV_IOFAILED.
|
||||
// CDEV_SUCCESS and valid id will denote a success
|
||||
|
||||
int removeUserFdCallback (cdevUserFdCbkId id);
|
||||
// PURPOSE: remove a user register fd callback with callback id
|
||||
// REQUIRE: none
|
||||
// PROMISE: return CDEV_NOTFOUND, if id is not found. return CDEV_SUCCESS
|
||||
// if id has been removed (system will close associated fd if it
|
||||
// is a not bad fd)
|
||||
|
||||
int addTimer (cdevTimerHandler* handler,
|
||||
const void* arg,
|
||||
double delay, double interval = 0.0);
|
||||
// PURPOSE: register a <cdevTimerHandler> 'handler' that will expire
|
||||
// after delay amount of seconds. If it expires then <arg> is
|
||||
// passed in the <timerCallback> function of handler. If
|
||||
// interval != 0.0, then this timer becomes a repetitive timer
|
||||
// with timer interval 'interval'.
|
||||
// REQUIRE: handler must have a real timerCallback function
|
||||
// PROMISE: A unique id will be returned. Callers can use this id
|
||||
// to cancel timer before it expires.
|
||||
|
||||
int removeTimer (cdevTimerHandler* handler);
|
||||
// PURPOSE: remove timers associated with a <cdevTimerHandler> 'handler'
|
||||
// REQUIRE: none
|
||||
// PROMISE: return CDEV_SUCCESS if all timers are removed. return CDEV_ERROR
|
||||
// if there is no timer associated with this handler
|
||||
|
||||
int removeTimer (int timerid);
|
||||
// PURPOSE: remove a timer with timer id 'timerid'
|
||||
// REQUIRE: none
|
||||
// PROMISE: return CDEV_SUCCESS if the timer is removed. return CDEV_ERROR
|
||||
// if this timer is not registered.
|
||||
|
||||
void enableDefaultSvc (void);
|
||||
void disableDefaultSvc (void);
|
||||
// PURPOSE: enable/disable using default service if a device msg pair cannot
|
||||
// match to any services
|
||||
// REQUIRE: none
|
||||
// PROMISE:
|
||||
|
||||
int defaultSvc (void) const;
|
||||
// PURPOSE: check whether a default service in used if a device msg pair
|
||||
// cannot match any services
|
||||
// REQUIRE: none
|
||||
// PROMISE: return 1 true. return 0 false
|
||||
|
||||
//===================================================================
|
||||
// Public interface for internal implementation use
|
||||
//===================================================================
|
||||
virtual int registerService (cdevService *service);
|
||||
// PURPOSE: register a service to the system
|
||||
// REQUIRE: service != 0
|
||||
// PROMISE: service only be registered once
|
||||
|
||||
virtual int removeService (cdevService *service);
|
||||
// PURPOSE: remove this service from the system
|
||||
// REQUIRE: service != 0
|
||||
// PROMISE: service will be removed, but service is sitll valid
|
||||
|
||||
virtual int serviceCreated (char *serviceName);
|
||||
// PURPOSE: check a service inside the system by name
|
||||
// REQUIRE: serviceName != 0
|
||||
// PROMISE: return 1: found, 0: not found
|
||||
|
||||
cdevService *service (char *serviceName);
|
||||
// PURPOSE: return a service pointer inside system by name
|
||||
// REQUIRE: serviceName != 0
|
||||
// PROMISE: return cdevService* != 0 on success, return 0: failure
|
||||
|
||||
cdevService *loadService (char *serviceName);
|
||||
// PURPOSE: load a new service by service name (shared library)
|
||||
// REQUIRE: serviceName != 0
|
||||
// PROMISE: return cdevService* != 0 on success, return 0: failure
|
||||
|
||||
virtual int suspendService (cdevService *service);
|
||||
// PURPOSE: temprarily suspend service
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: not implemented yet
|
||||
|
||||
virtual int resumeService (cdevService *service);
|
||||
// PURPOSE: resume a suspended service
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: not implemented yet
|
||||
|
||||
int registerDevice (cdevDevice *device);
|
||||
// PURPOSE: register a cdevDevice to the system
|
||||
// REQUIRE: device != 0
|
||||
// PROMISE: device will be registered once, CDEV_SUCCESS: success.
|
||||
// CDEV_ERROR: already here
|
||||
|
||||
int removeDevice (cdevDevice *);
|
||||
// PURPOSE: remove a device from the system
|
||||
// REQUIRE: device != 0
|
||||
// PROMISE: return CDEV_SUCCESS: rmoval success.
|
||||
// return CDEV_ERROR: not here
|
||||
|
||||
int deviceCreated (char *deviceName);
|
||||
// PURPOSE: check a device created in the system by name
|
||||
// REQUIRE: deviceName != 0
|
||||
// PROMISE: return 1: device is here, return 0: not here
|
||||
|
||||
cdevDevice *device (char *deviceName);
|
||||
// PURPOSE: return a device in the system by name
|
||||
// REQUIRE: deviceName != 0
|
||||
// PROMISE: return device !=0 on success, return 0: failure
|
||||
|
||||
virtual int getRequestObject (char *deviceName,
|
||||
char *msg,
|
||||
cdevRequestObject * &req);
|
||||
// PURPOSE: get a cdevRequestObject from system by devicename and message
|
||||
// REQUIRE: deviceName != 0 and msg != 0
|
||||
// PROMISE: return CDEV_SUCCESS: success.
|
||||
// return CDEV_ERROR: failure
|
||||
|
||||
int registerGroup (cdevGroup *grp);
|
||||
// PURPOSE: register a group into the system
|
||||
// REQUIRE: grp != 0
|
||||
// PROMISE: return CDEV_SUCCESS: success, CDEV_ERROR: already here
|
||||
|
||||
int removeGroup (cdevGroup *grp);
|
||||
// PURPOSE: remove a group from the system
|
||||
// REQUIRE: grp != 0
|
||||
// PROMISE: return CDEV_SUCCESS: removal success.
|
||||
// return CDEV_ERROR: not here. grp is still valid.
|
||||
|
||||
int registerActiveGroup (cdevGroup *grp);
|
||||
// PURPOSE: register an active group (group stared)
|
||||
// REQUIRE: grp != 0
|
||||
// PROMISE: return CDEV_SUCCESS: success,
|
||||
// CDEV_ERROR: already here
|
||||
|
||||
int removeActiveGroup (cdevGroup *grp);
|
||||
// PURPOSE: remove an active group
|
||||
// REQUIRE: grp != 0
|
||||
// PROMISE: return CDEV_SUCCESS: success.
|
||||
// return CDEV_ERROR: not here. grp is still valid
|
||||
|
||||
int activeGroups (cdevGroup **grps, int& numGroups);
|
||||
// PURPOSE: return active groups inside the system
|
||||
// REQUIRE: callers provide memory for grps (eg. grps = new cdevGroup*[5])
|
||||
// or cdevGroup grps[5]. numGroups is the buffer size of grps.
|
||||
// callers don't free grps[i] which is a pointer to internal rep.
|
||||
// PROMISE: numGrps is the real number of active groups
|
||||
|
||||
int activeGroups (void) const;
|
||||
// PURPOSE: check whether there are any active groups
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: 1: yes, 0: no
|
||||
|
||||
cdevDirectory& nameServer (void);
|
||||
// PURPOSE: default name server
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: always here
|
||||
|
||||
cdevRequestObject *errorRequestObject (void);
|
||||
// PURPOSE: return default error request object in case of error
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return error request object
|
||||
|
||||
void errorRequestObject (cdevRequestObject *obj);
|
||||
// PURPOSE: set default error request object in case of error
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: default error request object will be set
|
||||
|
||||
virtual ~cdevSystem (void);
|
||||
|
||||
protected:
|
||||
// constructor and destructor
|
||||
cdevSystem (char *systemName, char *prefix = 0);
|
||||
|
||||
// redefine attach/detach file descriptor to notify callback if there
|
||||
// any of them
|
||||
virtual int attachReadFd (int fd);
|
||||
virtual int detachReadFd (int fd);
|
||||
|
||||
// setup the read mask in preparation for pend operation.
|
||||
void setupMask ( void );
|
||||
|
||||
// free all memory
|
||||
void freeMemory (void);
|
||||
// interface to system collection
|
||||
static int remove (cdevSystem *);
|
||||
|
||||
// handle network I/O events
|
||||
virtual int handleEvents (cdevTimeValue* tv);
|
||||
|
||||
// calculate time out according to user request maximum timeout
|
||||
// and timer queue earliest timeout
|
||||
// returned pointer is a pointer to a static value
|
||||
cdevTimeValue* calculateTimeOut (cdevTimeValue* maxtimeout);
|
||||
|
||||
// notify lower level service object
|
||||
virtual void notifyService (int handle);
|
||||
// get individul service from file descriptor
|
||||
cdevService *getService (int handle);
|
||||
|
||||
private:
|
||||
// data area
|
||||
cdevSlist serviceList_;
|
||||
// hash table keep track all devices which are keyed by device name
|
||||
cdevStrHash deviceList_;
|
||||
// group list inside the system
|
||||
cdevSlist groupList_;
|
||||
// active group list inside the system
|
||||
cdevSlist activeGroupList_;
|
||||
// system list
|
||||
static cdevSlist& systemList_ (void);
|
||||
// flag to denote there are some active groups
|
||||
int activeGrps_;
|
||||
// this system name
|
||||
char *systemName_;
|
||||
// prefix name for this system
|
||||
char *prefix_;
|
||||
// default name server, cdevDirectory for now
|
||||
cdevDirectory *ns_;
|
||||
// cdevService name binding mechanism
|
||||
cdevSvcFinder *svcFinder_;
|
||||
// cdev site configuraton loader
|
||||
cdevConfigFinder *configFinder_;
|
||||
// Reference counting
|
||||
int refCount_;
|
||||
// callback list for fdChangedCallback
|
||||
cdevSlist fdCbkList_;
|
||||
cdevSlist fdCbkArgList_;
|
||||
// timer queue
|
||||
cdevTimerQueue timerQueue_;
|
||||
// fall through to a default service or not if no service is found
|
||||
int defaultSvc_;
|
||||
|
||||
//====================================================
|
||||
// The followings are for linked editor.
|
||||
// Try to trick the link editor to load those symbols
|
||||
// which otherwise will not be exported to library
|
||||
//====================================================
|
||||
// default cdevServiceError handler object
|
||||
cdevService *errSvcObj_;
|
||||
// touch cdevTranObj class and alot of more
|
||||
cdevTranObj *defXobj_;
|
||||
// touch cdevCallback class
|
||||
cdevCallback *defCallbackObj_;
|
||||
// default requestobject error handle object
|
||||
cdevRequestObject *errObj_;
|
||||
// an empty cdevExecGroup object
|
||||
cdevExecGroup* egroup_;
|
||||
//===================================================
|
||||
// Deny access since memeber-wise copy will not work
|
||||
// since this system is actually a memory manager
|
||||
//===================================================
|
||||
cdevSystem (const cdevSystem &);
|
||||
cdevSystem& operator = (const cdevSystem &);
|
||||
// friend class declaration
|
||||
friend class cdevService;
|
||||
friend class cdevErrReqObject;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevSystemBase class (abstract class)
|
||||
//
|
||||
// Author: Jie Chen & Chip Watson
|
||||
//
|
||||
// Revision History:
|
||||
// cdevSystemBase.h,v
|
||||
// Revision 1.2 1996/05/28 13:00:12 chen
|
||||
// minor changes
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:08 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_SYSTEM_BASE
|
||||
#define _CDEV_SYSTEM_BASE
|
||||
|
||||
#include "cdevError.h"
|
||||
#include "cdevSync.h"
|
||||
|
||||
class CDEV_CLASS_SPEC cdevSystemBase: public cdevSync, public cdevError
|
||||
{
|
||||
public:
|
||||
virtual ~cdevSystemBase (void);
|
||||
// PURPOSE: destructor for cdevSystemBase
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: it will be gone
|
||||
|
||||
virtual char *name (void) const = 0;
|
||||
// PURPOSE: pure virtual function
|
||||
// REQUIRE: derived class provides real implementation
|
||||
// PROMISE: nothing
|
||||
|
||||
virtual int getRequestObject (char *deviceName,
|
||||
char *msg,
|
||||
cdevRequestObject* &req) = 0;
|
||||
// PURPOSE: pure virtual function
|
||||
// REQUIRE: callers provide pointer to cdevRequestObject only, no memory
|
||||
// PROMISE: nothing
|
||||
virtual const char *className (void) const {return "cdevSystemBase";}
|
||||
|
||||
protected:
|
||||
//constructor, deny direct instantiation
|
||||
cdevSystemBase (void);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// description: cdevTagTable.h
|
||||
// cdevTagTable class manages tags within the cdev system.
|
||||
//
|
||||
// Author: Danjin Wu & Walt Akers
|
||||
//
|
||||
// Revision History:
|
||||
// cdevTagTable.h,v
|
||||
// Revision 1.12 1997/08/01 19:06:30 akers
|
||||
// Added addTag and tagExists feature to the library
|
||||
//
|
||||
// Revision 1.11 1996/10/25 20:10:02 chen
|
||||
// add asciiDump
|
||||
//
|
||||
// Revision 1.10 1996/08/26 19:14:07 akers
|
||||
// Adding cdevData.inserttag callback capabilities
|
||||
//
|
||||
// Revision 1.9 1996/07/17 13:57:56 chen
|
||||
// using CDEVTAGTABLE to find tags
|
||||
//
|
||||
// Revision 1.8 1995/10/03 19:37:11 chen
|
||||
// Change back to object instead of pointers
|
||||
//
|
||||
// Revision 1.7 1995/09/29 15:25:55 danjin
|
||||
// declare hash entry as pointer
|
||||
//
|
||||
// Revision 1.6 1995/09/28 19:01:48 danjin
|
||||
// change: declare a ptr to list -> declare a list
|
||||
//
|
||||
// Revision 1.5 1995/08/21 18:02:48 danjin
|
||||
// empty message
|
||||
//
|
||||
// Revision 1.3 1995/08/21 16:40:23 danjin
|
||||
// modify comment
|
||||
//
|
||||
// Revision 1.2 1995/08/21 16:38:10 danjin
|
||||
// modified big partion of this file
|
||||
//
|
||||
// Revision 1.1 1995/08/21 15:47:24 danjin
|
||||
// merge Slist and hash into one for cdev
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_TAG_TABLE_H
|
||||
#define _CDEV_TAG_TABLE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevIntHash.h>
|
||||
#include <cdevStrHash.h>
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * class cdevTagTableCallback :
|
||||
// * This class is used by the caller to post a callback to be notified
|
||||
// * when changes are posted to a cdevTagTable. The class also has
|
||||
// * a next pointer to allow it to be placed in a linked list within the
|
||||
// * cdevTagTable...
|
||||
// *
|
||||
// * Note: Since this is a abstract base class, the caller must create a
|
||||
// * class based on this class that has the callback method defined...
|
||||
// * Also the destructor here is defined as virtual to force the delete
|
||||
// * mechanism to work its way up the class hierarchy to the top level
|
||||
// * before calling the destructor...
|
||||
// *****************************************************************************
|
||||
class CDEV_CLASS_SPEC cdevTagTableCallback
|
||||
{
|
||||
friend class cdevTagTable;
|
||||
private:
|
||||
cdevTagTableCallback *next_;
|
||||
public:
|
||||
cdevTagTableCallback ( void ) : next_(NULL) {}
|
||||
virtual ~cdevTagTableCallback (void) {}
|
||||
virtual void callback (int newTag, char *newName) = 0;
|
||||
};
|
||||
|
||||
|
||||
struct cdevTagEle {
|
||||
char *tagName;
|
||||
int tagId;
|
||||
};
|
||||
typedef struct cdevTagEle cdevTagEle;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevTagTable
|
||||
{
|
||||
public:
|
||||
cdevTagTable ( void );
|
||||
|
||||
~cdevTagTable ( void )
|
||||
{
|
||||
freeMemory ();
|
||||
#ifdef _CDEV_DEBUG
|
||||
printf("Destroying a cdevTagTable object\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
int tagC2I (char* ctag, int* tag);
|
||||
int tagI2C (int tag, char* &ctag);
|
||||
void insertTag (int tag, char* ctag);
|
||||
int tagExists (char *ctag);
|
||||
int tagExists (int tag);
|
||||
int addTag (char *ctag);
|
||||
|
||||
// *************************************************
|
||||
// * addTagCallback :
|
||||
// * This method will add a cdevTagTableCallback
|
||||
// * object to the list of classes that should be
|
||||
// * notified each time a tag is added to the
|
||||
// * cdevTagTable.
|
||||
// *************************************************
|
||||
void addTagCallback ( cdevTagTableCallback * cb );
|
||||
|
||||
// *************************************************
|
||||
// * delTagCallback :
|
||||
// * This method will remote a cdevTagTableCallback
|
||||
// * object that was previously added to the list
|
||||
// * of callback classes.
|
||||
// *
|
||||
// * Note: This method does not actually delete
|
||||
// * the cdevTagTableCallback object, it
|
||||
// * merely removes it from the list. It
|
||||
// * is the responsibility of the owner to
|
||||
// * delete the object when it is no longer
|
||||
// * needed.
|
||||
// *************************************************
|
||||
void delTagCallback ( cdevTagTableCallback * cb );
|
||||
|
||||
// *************************************************
|
||||
// * readTagTable :
|
||||
// * This method allows the caller to obtain a list
|
||||
// * of tag names and integers that are currently
|
||||
// * stored in this tag table.
|
||||
// *
|
||||
// * Note: This method will allocate an array of
|
||||
// * integers and an array of character
|
||||
// * string pointers. The strings that
|
||||
// * are stored in the string array will be
|
||||
// * the actual strings from within the
|
||||
// * tag table and should not be deleted...
|
||||
// *
|
||||
// * The data allocated becomes the property
|
||||
// * of the caller and must be deleted when
|
||||
// * it is no longer needed... the correct
|
||||
// * syntax to delete these items is...
|
||||
// *
|
||||
// * delete tags;
|
||||
// * delete ctags;
|
||||
// *
|
||||
// * This will delete the array, however,
|
||||
// * it will leave the individual array
|
||||
// * elements intact.
|
||||
// *************************************************
|
||||
int readTagTable ( int * &tags, char ** &ctags, int &ntags );
|
||||
|
||||
// *************************************************
|
||||
// * asciiDump (FILE* fp = stdout);
|
||||
// * dump information of tag table to a file with two columns
|
||||
// * left column is tag value, right column is tag string
|
||||
// *************************************************
|
||||
void asciiDump (FILE* fp = stdout);
|
||||
|
||||
protected:
|
||||
void freeMemory (void);
|
||||
void initialize ( void );
|
||||
// data area
|
||||
cdevIntHash itagList_;
|
||||
cdevStrHash stagList_;
|
||||
cdevTagTableCallback * callbacks_;
|
||||
int highestTag;
|
||||
|
||||
private:
|
||||
// default tag name if there is no tag file
|
||||
static char* defaultTags[];
|
||||
static unsigned int numberDefTags;
|
||||
static char* defaultTagTableLocation;
|
||||
static char* tagTableEnv;
|
||||
|
||||
// parse tag table file, return 0: failure, return 1: success
|
||||
// caller free all memory upon success
|
||||
static int parseTagTable (char* file, char** &tags, int* &tagvalues,
|
||||
unsigned int &numTags);
|
||||
};
|
||||
#endif /* _CDEV_TAG_TABLE_H */
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// C++ Class for timeval structure
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevTimeValue.h,v
|
||||
// Revision 1.2 1998/02/10 18:04:57 chen
|
||||
// add cdevSystem timer handler
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:02 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_TIME_VALUE_H
|
||||
#define _CDEV_TIME_VALUE_H
|
||||
|
||||
#include <cdevSpec.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <sys/types.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
class CDEV_CLASS_SPEC cdevTimeValue
|
||||
{
|
||||
public:
|
||||
cdevTimeValue (long sec = 0, long usec = 0);
|
||||
cdevTimeValue (double sec);
|
||||
#ifdef _WIN32
|
||||
cdevTimeValue (const struct _timeb &t);
|
||||
#endif
|
||||
cdevTimeValue (const timeval &t);
|
||||
cdevTimeValue (const cdevTimeValue &tv);
|
||||
cdevTimeValue& operator = (const cdevTimeValue& tv);
|
||||
|
||||
#ifdef _WIN32
|
||||
void set (const struct _timeb &t);
|
||||
#endif
|
||||
|
||||
void set (const timeval &t);
|
||||
long sec (void) const;
|
||||
void sec (long sec);
|
||||
long usec (void) const;
|
||||
void usec (long usec);
|
||||
operator double () const;
|
||||
#ifdef _WIN32
|
||||
operator struct _timeb () const;
|
||||
#endif
|
||||
operator timeval () const;
|
||||
|
||||
void operator += (const cdevTimeValue& val);
|
||||
void operator -= (const cdevTimeValue& val);
|
||||
|
||||
friend cdevTimeValue operator + (cdevTimeValue tv1, cdevTimeValue tv2);
|
||||
friend cdevTimeValue operator - (cdevTimeValue tv1, cdevTimeValue tv2);
|
||||
friend int operator < (cdevTimeValue tv1, cdevTimeValue tv2);
|
||||
friend int operator > (cdevTimeValue tv1, cdevTimeValue tv2);
|
||||
friend int operator <= (cdevTimeValue tv1, cdevTimeValue tv2);
|
||||
friend int operator >= (cdevTimeValue tv1, cdevTimeValue tv2);
|
||||
friend int operator == (cdevTimeValue tv1, cdevTimeValue tv2);
|
||||
friend int operator != (cdevTimeValue tv1, cdevTimeValue tv2);
|
||||
|
||||
static const cdevTimeValue zero;
|
||||
static cdevTimeValue currentTime (void);
|
||||
|
||||
private:
|
||||
void normalize (void);
|
||||
|
||||
long tv_sec_;
|
||||
long tv_usec_;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevTimerHandler Class
|
||||
//
|
||||
// This class is a base class for handling timer based event.
|
||||
// Derived classes implement the real function.
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevTimerHandler.h,v
|
||||
// Revision 1.1 1998/02/10 18:04:57 chen
|
||||
// add cdevSystem timer handler
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_TIMER_HANDLER_H
|
||||
#define _CDEV_TIMER_HANDLER_H
|
||||
|
||||
#include <cdevTimeValue.h>
|
||||
|
||||
class cdevTimerHandler
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
cdevTimerHandler (void) {}
|
||||
// destructor
|
||||
virtual ~cdevTimerHandler (void) {}
|
||||
|
||||
virtual int timerCallback (double /* time */,
|
||||
const void* /* arg */ = 0) {return 0;}
|
||||
// PURPOSE: this function is called when timer is expired
|
||||
// REQUIRE: none
|
||||
// PROMISE: if return -1: all timers associated with this handler
|
||||
// will be removed. return 0: everything is ok.
|
||||
|
||||
virtual const char* className (void) const {return "cdevTimerHandler";}
|
||||
|
||||
private:
|
||||
// deny access to copy and assignment operator
|
||||
cdevTimerHandler (const cdevTimerHandler& handler);
|
||||
cdevTimerHandler& operator = (const cdevTimerHandler& handler);
|
||||
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,128 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevTimerQueue Class
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevTimerQueue.h,v
|
||||
// Revision 1.1 1998/02/10 18:04:58 chen
|
||||
// add cdevSystem timer handler
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_TIMER_QUEUE_H
|
||||
#define _CDEV_TIMER_QUEUE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cdevTimerHandler.h>
|
||||
#include <cdevSlist.h>
|
||||
|
||||
class cdevTimerQueue;
|
||||
|
||||
class cdevTimerQNode
|
||||
{
|
||||
private:
|
||||
|
||||
friend class cdevTimerQueue;
|
||||
|
||||
cdevTimerQNode (cdevTimerHandler* h,
|
||||
const void* arg,
|
||||
const cdevTimeValue& t,
|
||||
const cdevTimeValue& i,
|
||||
int id);
|
||||
|
||||
// data area
|
||||
cdevTimerHandler* handler_;
|
||||
|
||||
// user argument
|
||||
const void* arg_;
|
||||
|
||||
// first time interval to expire
|
||||
cdevTimeValue timer_;
|
||||
|
||||
// timer interval: if this is not zero this holds the time until the next
|
||||
// timeout
|
||||
cdevTimeValue interval_;
|
||||
|
||||
// int timer id
|
||||
int tid_;
|
||||
};
|
||||
|
||||
|
||||
class CDEV_CLASS_SPEC cdevTimerQueue
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
cdevTimerQueue (void);
|
||||
// destructor
|
||||
virtual ~cdevTimerQueue (void);
|
||||
|
||||
int isEmpty (void) const;
|
||||
// PURPOSE: check whether this queue is empty or not
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: return 1, empty, 0, not empty
|
||||
|
||||
const cdevTimeValue& earliestTime (void) const;
|
||||
// PURPOSE: return earliestTime in the timer queue
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: time value denoted the earliest time in the queue
|
||||
|
||||
int scheduleTimer (cdevTimerHandler* handler,
|
||||
const void* arg,
|
||||
const cdevTimeValue& delay,
|
||||
const cdevTimeValue& interval = cdevTimeValue::zero);
|
||||
// PURPOSE: Schedule an <cdevTimerHandler> that will expire after <delay>
|
||||
// amount of time. If it expires then <arg> is passed in as the value to
|
||||
// the <cdevTimerHandler>'s <timerCallback> callback method. If
|
||||
// <interval> is != to <cdevTimeValue::zero> then it is used to
|
||||
// reschedule the <cdevTimerHandler> automatically. This method
|
||||
// returns a timer handle that uniquely identifies the
|
||||
// <cdevTimerhandler> in an internal list. This timer handle can be
|
||||
// used to cancel an <cdevTimerhandler> before it expires. The
|
||||
// cancellation ensures that timer_ids are unique up to values of
|
||||
// greater than 2 billion timers. As long as timers don't stay
|
||||
// around longer than this there should be no problems with
|
||||
// accidentally deleting the wrong timer.
|
||||
|
||||
int cancel (cdevTimerHandler* handler);
|
||||
// PURPOSE: cancel all timers associated with handler
|
||||
// REQUIRE: handler != 0
|
||||
// PROMISE: all timer is canceled. return 0
|
||||
|
||||
int cancel (int id);
|
||||
// PURPOSE: cancel a single timer with id
|
||||
// REQUIRE: id must be valid
|
||||
// PROMISE: if id is found, the timer is canceled.
|
||||
|
||||
int expire (const cdevTimeValue& current_time);
|
||||
// PURPOSE: run the <timerCallback> method for all timers whose values are
|
||||
// <= current_time
|
||||
|
||||
private:
|
||||
void reschedule (cdevTimerQNode* node);
|
||||
// reschedule a "interval" timer
|
||||
|
||||
cdevSlist queue_;
|
||||
// real linked list as a queue
|
||||
|
||||
int timerId_;
|
||||
// run time timer id
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdev Transaction Object class (for service developer only)
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevTranObj.h,v
|
||||
// Revision 1.4 1996/05/02 14:17:44 chen
|
||||
// handle unfinished transaction
|
||||
//
|
||||
// Revision 1.3 1995/12/08 15:35:57 chen
|
||||
// handle deferred mode
|
||||
//
|
||||
// Revision 1.2 1995/10/03 19:34:52 chen
|
||||
// disable/enable deleting callback
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:07 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_TRANOBJ_H
|
||||
#define _CDEV_TRANOBJ_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <cdevSpec.h>
|
||||
#include <cdevSystem.h>
|
||||
#include <cdevData.h>
|
||||
#include <cdevCallback.h>
|
||||
|
||||
class cdevGroup;
|
||||
class cdevRequestObject;
|
||||
|
||||
class CDEV_CLASS_SPEC cdevTranObj
|
||||
{
|
||||
public:
|
||||
// constructors and destructor
|
||||
cdevTranObj (void);
|
||||
cdevTranObj (cdevSystem *sys,
|
||||
cdevRequestObject *reqObj,
|
||||
cdevData *data,
|
||||
cdevCallback *callback);
|
||||
~cdevTranObj (void);
|
||||
|
||||
int status (void) const;
|
||||
// PURPOSE: return status of transaction object
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: -1: not registered into any group, 1: registered into groups
|
||||
|
||||
int operator == (const cdevTranObj& rsc);
|
||||
int operator != (const cdevTranObj& rsc);
|
||||
// PURPOSE: equality operator
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: obvious
|
||||
|
||||
int removeFromGrps (void);
|
||||
// PURPOSE: remove this transaction object from all groups
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: status = -1
|
||||
|
||||
void disableDeleteCbk (void);
|
||||
void enableDeleteCbk (void);
|
||||
// PURPOSE: enable/disable delete callback flag
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: you know
|
||||
|
||||
void trash (cdevGroup* grp);
|
||||
int isTrash (void) const;
|
||||
// PURPOSE: throw this transaction object into a trash dump
|
||||
// REQUIRE: nothing;
|
||||
// PROMISE: this transaction object will not attempt to call any callback
|
||||
// function
|
||||
|
||||
// data area for requestObject to access
|
||||
cdevSystem *system_;
|
||||
cdevRequestObject *reqObj_;
|
||||
cdevData *resultData_;
|
||||
cdevCallback *userCallback_;
|
||||
int status_;
|
||||
cdevGroup *activeGroups_[MAX_NUM_GROUPS];
|
||||
int numGroups_;
|
||||
// pointer entries to all active groups
|
||||
cdevTranObj **entryPtr_[MAX_NUM_GROUPS];
|
||||
|
||||
const char *className (void) const {return "cdevTranObj";}
|
||||
|
||||
private:
|
||||
// deny copy and assignment operation
|
||||
// It makes no sense for two identical transaction objects
|
||||
cdevTranObj (const cdevTranObj& rsc);
|
||||
cdevTranObj& operator = (const cdevTranObj& rsc);
|
||||
|
||||
// flag of deleting callback or not.
|
||||
// Reason: callback may need stay after the transaction object goes away
|
||||
int deleteCallback_;
|
||||
|
||||
// flag of garbage transaction object (do not care any callbacks)
|
||||
int trash_;
|
||||
|
||||
// friend class
|
||||
friend class cdevGroup;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
* Copyright (c) 1991,1992 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*----------------------------------------------------------------------------
|
||||
*
|
||||
* description: cdevDataEntry.h
|
||||
* Self describing data class. Designed to hold individual tagged data
|
||||
* items within a cdevData class.
|
||||
*
|
||||
* Author: Walt Akers & Danjin Wu
|
||||
*
|
||||
* Revision History:
|
||||
* cdevTypes.h,v
|
||||
* Revision 1.5 1998/03/10 19:57:39 chen
|
||||
* change to C style comment
|
||||
*
|
||||
* Revision 1.4 1998/03/10 18:54:27 chen
|
||||
* cdevTypes.h
|
||||
*
|
||||
* Revision 1.3 1995/09/06 18:35:11 danjin
|
||||
* added time stamp structure type
|
||||
*
|
||||
* Revision 1.2 1995/07/14 13:25:32 akers
|
||||
* Header files added to support the changes specified at June 95 Review
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef _CDEV_TYPES_H
|
||||
#define _CDEV_TYPES_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
enum cdevDataTypes
|
||||
{
|
||||
CDEV_BYTE,
|
||||
CDEV_INT16,
|
||||
CDEV_UINT16,
|
||||
CDEV_INT32,
|
||||
CDEV_UINT32,
|
||||
CDEV_FLOAT,
|
||||
CDEV_DOUBLE,
|
||||
CDEV_STRING,
|
||||
CDEV_TIMESTAMP,
|
||||
CDEV_INVALID
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t offset;
|
||||
size_t length;
|
||||
} cdevBounds;
|
||||
|
||||
/* cdev time struct */
|
||||
typedef struct {
|
||||
unsigned long secPastEpoch; /* seconds since Jan. 1, 1970 */
|
||||
unsigned long nsec; /* nanoseconds within second */
|
||||
} cdev_TS_STAMP;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,105 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// cdevFdServive (Arbitrary user file descriptor service)
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevUserFdService.h,v
|
||||
// Revision 1.1 1997/02/18 15:45:48 chen
|
||||
// port to linux 2.0.x + addUserFdCallback
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef _CDEV_USER_FD_SERVICE_H
|
||||
#define _CDEV_USER_FD_SERVICE_H
|
||||
|
||||
#include <cdevService.h>
|
||||
|
||||
class cdevUserFdService: public cdevService
|
||||
{
|
||||
public:
|
||||
cdevUserFdService (int fd, cdevUserFdCallback cbk, void* arg,
|
||||
char* name,
|
||||
cdevSystem& system = cdevSystem::defaultSystem ()
|
||||
);
|
||||
// PURPOSE: construction of fdService
|
||||
// REQUIRE: none
|
||||
// PROMISE: A fd servive with a unique name
|
||||
|
||||
~cdevUserFdService (void);
|
||||
// PURPOSE: destruction of fdService
|
||||
// REQUIRE: none
|
||||
// PROMISE: this object is gone forever
|
||||
|
||||
int getFd (int* &fd, int &numFd);
|
||||
// PURPOSE: get service's IO file descriptors
|
||||
// REQUIRE: callers provide pointer (eg. int *fd = 0;) no memory. callers
|
||||
// should never free memory pointed by fd. fd should be cached
|
||||
// inside derived class for easy/quick access
|
||||
// PROMISE: numFd >= 0
|
||||
|
||||
int getNameServer (cdevDevice* &server);
|
||||
// PURPOSE: get right name server associated with this service
|
||||
// REQUIRE: caller provide pointer only, derived class provides
|
||||
// an empty function for now
|
||||
// PROMISE: not implemented yet
|
||||
|
||||
int flush (void);
|
||||
// PURPOSE: pure virtual function to define intreface for net flush
|
||||
// REQUIRE: derived class provide implementation
|
||||
// PROMISE: return CDEV_SUCCESS
|
||||
|
||||
int poll (void);
|
||||
// PURPOSE: pure virtual function to define intreface for polling method
|
||||
// REQUIRE: derived class provide implementation
|
||||
// PROMISE: return CDEV_SUCCESS: OK. return -1: network error
|
||||
|
||||
int pend (int fd = -1);
|
||||
// PURPOSR: pure virtual function to define interface for pending method
|
||||
// REQUIRE: derived class provide implementation
|
||||
// PROMISE: return CDEV_SUCCESS, OK, return -1: network error
|
||||
|
||||
int pend (double seconds, int fd = -1);
|
||||
// PURPOSR: pure virtual function to define interface for pending method
|
||||
// REQUIRE: derived class provide implementation
|
||||
// PROMISE: return CDEV_SUCCESS, OK, return CDEV_TIMEOUT: timeout.
|
||||
// -1: network error
|
||||
|
||||
static char* prefixName (void);
|
||||
// PURPOSE: return common prefix name for all services
|
||||
// REQUIRE: none
|
||||
// PROMISE: return common prefix name
|
||||
|
||||
const char *className (void) const {return "cdevUserFdService";}
|
||||
|
||||
protected:
|
||||
// hide request object creation method
|
||||
int getRequestObject (char *deviceName,
|
||||
char *msg,
|
||||
cdevRequestObject* &req);
|
||||
// PURPOSE: get request object: this service return 0
|
||||
// REQUIRE: callers provide pointer to cdevRequestObject only, no memory
|
||||
// PROMISE: nothing
|
||||
|
||||
private:
|
||||
// associated fd
|
||||
int* fd_;
|
||||
// user function and usr argument
|
||||
cdevUserFdCallback cbk_;
|
||||
void* arg_;
|
||||
|
||||
// unique name for fd services
|
||||
static char* fdsvcname_;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// CDEV VERSION Information
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// cdevVersion.h,v
|
||||
// Revision 1.3 1997/12/22 18:23:06 akers
|
||||
// Ongoing development of 1.6.2
|
||||
//
|
||||
// Revision 1.2 1997/10/17 17:27:18 chen
|
||||
// set right version number
|
||||
//
|
||||
// Revision 1.1 1997/08/27 18:23:33 chen
|
||||
// Change error reporting to site specific scheme
|
||||
//
|
||||
//
|
||||
//
|
||||
*/
|
||||
#ifndef _CDEV_VERSION_H
|
||||
#define _CDEV_VERSION_H
|
||||
|
||||
#define CDEV_MAJOR_VERS 1
|
||||
#define CDEV_MINOR_VERS 7
|
||||
#define CDEV_REVISION 2
|
||||
|
||||
#define CDEV_VERSION (CDEV_MAJOR_VERS*10000 + CDEV_MINOR_VERS*100 + CDEV_REVISION)
|
||||
|
||||
#define CDEV_VERSION_STRING "1.7.2"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* defCallbackCollector : This class is used to collect the callbacks from a
|
||||
* a single cdevDefCollectionRequest. This is an
|
||||
* implementation class that is only associated with the
|
||||
* default cdevCollectionObject if the developer's
|
||||
* service does not provide specific support for
|
||||
* collections.
|
||||
*
|
||||
* The cdevCollectionRequest object will obtain the
|
||||
* cdevData object from this object and will return it
|
||||
* to the caller or to an interim
|
||||
* cdevGrpCollectionRequest object.
|
||||
*
|
||||
* Author: Walt Akers
|
||||
*
|
||||
* Revision History:
|
||||
* defCallbackCollector.h,v
|
||||
* Revision 1.1 1996/11/12 20:32:37 akers
|
||||
* New collection device source code
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _DEF_CALLBACK_COLLECTOR_H_
|
||||
#define _DEF_CALLBACK_COLLECTOR_H_
|
||||
|
||||
#include <cdevData.h>
|
||||
#include <cdevTranObj.h>
|
||||
#include <cdevCollectionRequest.h>
|
||||
|
||||
class defCallbackCollector
|
||||
{
|
||||
public:
|
||||
typedef struct
|
||||
{
|
||||
int index;
|
||||
int processed;
|
||||
defCallbackCollector * parent;
|
||||
} Request;
|
||||
|
||||
int counter;
|
||||
cdevData result;
|
||||
cdevData & format;
|
||||
cdevTranObj * xobj;
|
||||
Request * requests;
|
||||
int nRequests;
|
||||
|
||||
defCallbackCollector ( int NRequests, cdevData &Format, cdevTranObj &XObj );
|
||||
~defCallbackCollector ( void );
|
||||
int finished ( void );
|
||||
void processRequest ( int idx, int status, cdevData *data = NULL );
|
||||
void mergeData ( cdevData &to, cdevData &from, int arraySize, int idx);
|
||||
void copyItemToArray ( cdevData &to, cdevData &from, int tag, int idx);
|
||||
void installEmptyArray ( cdevData &data, int tag, cdevDataTypes type, int size);
|
||||
};
|
||||
|
||||
#endif /* _DEF_CALLBACK_COLLECTOR_H_ */
|
||||
@@ -0,0 +1,64 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
*
|
||||
* This software was developed under a United States Government license
|
||||
* described in the NOTICE file included as part of this distribution.
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* grpCallbackCollector : This class is used to collect the callbacks from a
|
||||
* a group of collections and then compile the results
|
||||
* into a single cdevData object.
|
||||
*
|
||||
* The cdevCollectionRequest object will obtain the
|
||||
* cdevData object from this object and will return it
|
||||
* to the caller.
|
||||
*
|
||||
* Author: Walt Akers
|
||||
*
|
||||
* Revision History:
|
||||
* grpCallbackCollector.h,v
|
||||
* Revision 1.1 1996/11/12 20:32:41 akers
|
||||
* New collection device source code
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef _GRP_CALLBACK_COLLECTOR_H_
|
||||
#define _GRP_CALLBACK_COLLECTOR_H_
|
||||
|
||||
#include <cdevData.h>
|
||||
#include <cdevTranObj.h>
|
||||
#include <cdevCollectionRequest.h>
|
||||
|
||||
class grpCallbackCollector
|
||||
{
|
||||
public:
|
||||
typedef struct
|
||||
{
|
||||
int index;
|
||||
int elements;
|
||||
int processed;
|
||||
grpCallbackCollector * parent;
|
||||
} Request;
|
||||
|
||||
int counter;
|
||||
cdevData result;
|
||||
cdevData & format;
|
||||
cdevTranObj * xobj;
|
||||
Request * collections;
|
||||
int nCollections;
|
||||
int * requestOrder;
|
||||
int nRequests;
|
||||
|
||||
grpCallbackCollector (int NCollections, int * RequestOrder, int NRequests,
|
||||
cdevData &Format, cdevTranObj &XObj);
|
||||
~grpCallbackCollector ( void );
|
||||
int finished ( void );
|
||||
void processCollection ( int idx, int status, cdevData *data = NULL );
|
||||
void mergeData ( cdevData &to, cdevData &from, int idx );
|
||||
void copyItemsToArray ( cdevData &to, cdevData &from, int tag, int idx );
|
||||
void installEmptyArray ( cdevData &data, int tag, cdevDataTypes type, int size );
|
||||
};
|
||||
|
||||
#endif /* _GRP_CALLBACK_COLLECTOR_H_ */
|
||||
@@ -0,0 +1,2 @@
|
||||
SHOBJ=YES
|
||||
include $(CDEV)/include/makeinclude/Makefile.linux
|
||||
@@ -0,0 +1,189 @@
|
||||
TARGET = WINNT
|
||||
OS_MAJOR = 4
|
||||
OS_MINOR = 0
|
||||
OS_VERSION_DEF = /D "_OS_MAJOR_=$(OS_MAJOR)" /D "_OS_MINOR_=$(OS_MINOR)"
|
||||
|
||||
!IF "$(DEBUG)" == ""
|
||||
TARGETDIR = $(TARGET)-$(OS_MAJOR).$(OS_MINOR)
|
||||
!ELSE
|
||||
TARGETDIR = $(TARGET)-$(OS_MAJOR).$(OS_MINOR)-DEBUG
|
||||
!ENDIF
|
||||
|
||||
CDEVVERSION = 1.7.2
|
||||
CDEVINCLUDES = /I $(CDEV)\include
|
||||
CDEVLIB = $(CDEV)\lib\$(TARGETDIR)
|
||||
CDEVBIN = $(CDEV)\bin\$(TARGETDIR)
|
||||
|
||||
!IF "$(BINDIR)" == ""
|
||||
BINDIR = $(CDEVBIN)
|
||||
!ENDIF
|
||||
|
||||
!IF "$(LIBDIR)" == ""
|
||||
LIBDIR = $(CDEVLIB)
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CDEVSHOBJ)" == ""
|
||||
CDEVSHOBJ = $(CDEVLIB)
|
||||
!ENDIF
|
||||
|
||||
!IF "$(SHOBJ)" == "NO"
|
||||
OBJDIR = .obj\$(TARGETDIR)
|
||||
!ELSE
|
||||
SHOBJ = YES
|
||||
OBJDIR = .shobj\$(TARGETDIR)
|
||||
!ENDIF
|
||||
|
||||
CC = cl
|
||||
CXX = cl
|
||||
LIB32 = link
|
||||
LINK = link
|
||||
|
||||
CC_ALL_EXE = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /Fo".exec\$(TARGETDIR)/"\
|
||||
$(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) /TC /c
|
||||
CXX_ALL_EXE = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /Fo".exec\$(TARGETDIR)/"\
|
||||
$(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) /TP /c
|
||||
CXX_DEBUG_EXE = /MDd /Z7 /Od /D "_DEBUG" /GZ
|
||||
CXX_RELEASE_EXE = /MD /O2 /D "NDEBUG"
|
||||
LINK_ALL_EXE = kernel32.lib user32.lib gdi32.lib winspool.lib \
|
||||
comdlg32.lib advapi32.lib shell32.lib ole32.lib \
|
||||
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib \
|
||||
ws2_32.lib /nologo /subsystem:console /pdb:NONE
|
||||
LINK_DEBUG_EXE = /debug
|
||||
LINK_RELEASE_EXE =
|
||||
|
||||
CC_ALL_LIB = /nologo /D "WIN32" /D "_MBCS" /D "_LIB" /Fo"$(OBJDIR)/"\
|
||||
$(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) /TC /c
|
||||
CXX_ALL_LIB = /nologo /D "WIN32" /D "_MBCS" /D "_LIB" /Fo"$(OBJDIR)/"\
|
||||
$(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) /TP /c
|
||||
CXX_DEBUG_LIB = /MDd /Z7 /Od /D "_DEBUG" /GZ
|
||||
CXX_RELEASE_LIB = /MD /O2 /D "NDEBUG"
|
||||
LINK_ALL_LIB = -lib /nologo
|
||||
LINK_DEBUG_LIB =
|
||||
LINK_RELEASE_LIB =
|
||||
|
||||
CC_ALL_DLL = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Fo"$(OBJDIR)/"\
|
||||
$(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) /TC /c
|
||||
CXX_ALL_DLL = /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Fo"$(OBJDIR)/"\
|
||||
$(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) /TP /c
|
||||
CXX_DEBUG_DLL = /MDd /Z7 /Od /D "_DEBUG" /GZ
|
||||
CXX_RELEASE_DLL = /MD /O2 /D "NDEBUG"
|
||||
LINK_ALL_DLL = kernel32.lib user32.lib gdi32.lib winspool.lib \
|
||||
comdlg32.lib advapi32.lib shell32.lib ole32.lib \
|
||||
oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib \
|
||||
/nologo /dll /pdb:NONE
|
||||
LINK_DEBUG_DLL = /debug
|
||||
LINK_RELEASE_DLL =
|
||||
|
||||
!IF "$(DEBUG)" != ""
|
||||
CC_EXE_FLAGS = $(CC_ALL_EXE) $(CXX_DEBUG_EXE)
|
||||
CC_LIB_FLAGS = $(CC_ALL_LIB) $(CXX_DEBUG_LIB)
|
||||
CC_DLL_FLAGS = $(CC_ALL_DLL) $(CXX_DEBUG_DLL)
|
||||
CXX_EXE_FLAGS = $(CXX_ALL_EXE) $(CXX_DEBUG_EXE)
|
||||
CXX_LIB_FLAGS = $(CXX_ALL_LIB) $(CXX_DEBUG_LIB)
|
||||
CXX_DLL_FLAGS = $(CXX_ALL_DLL) $(CXX_DEBUG_DLL)
|
||||
LINK_EXE_FLAGS = $(LINK_ALL_EXE) $(LINK_DEBUG_EXE)
|
||||
LINK_LIB_FLAGS = $(LINK_ALL_LIB) $(LINK_DEBUG_LIB)
|
||||
LINK_DLL_FLAGS = $(LINK_ALL_DLL) $(LINK_DEBUG_DLL)
|
||||
!ELSE
|
||||
CC_EXE_FLAGS = $(CC_ALL_EXE) $(CXX_RELEASE_EXE)
|
||||
CC_LIB_FLAGS = $(CC_ALL_LIB) $(CXX_RELEASE_LIB)
|
||||
CC_DLL_FLAGS = $(CC_ALL_DLL) $(CXX_RELEASE_DLL)
|
||||
CXX_EXE_FLAGS = $(CXX_ALL_EXE) $(CXX_RELEASE_EXE)
|
||||
CXX_LIB_FLAGS = $(CXX_ALL_LIB) $(CXX_RELEASE_LIB)
|
||||
CXX_DLL_FLAGS = $(CXX_ALL_DLL) $(CXX_RELEASE_DLL)
|
||||
LINK_EXE_FLAGS = $(LINK_ALL_EXE) $(LINK_RELEASE_EXE)
|
||||
LINK_LIB_FLAGS = $(LINK_ALL_LIB) $(LINK_RELEASE_LIB)
|
||||
LINK_DLL_FLAGS = $(LINK_ALL_DLL) $(LINK_RELEASE_DLL)
|
||||
!ENDIF
|
||||
|
||||
!IF "$(HAIL)" != "NO"
|
||||
HAILTARGET = hail
|
||||
!ENDIF
|
||||
|
||||
!IF "$(FAIRWELL)" != "NO"
|
||||
BYETARGET = fairwell
|
||||
!ENDIF
|
||||
|
||||
# ******************************************************************************
|
||||
# * Master rules for building cdevGenericServer objects
|
||||
# ******************************************************************************
|
||||
all : $(HAILTARGET) targets $(BYETARGET)
|
||||
|
||||
hail:
|
||||
@echo ----------------------------------------------------------------
|
||||
@echo Building $(APPNAME) for Target: $(TARGETDIR)
|
||||
@echo ----------------------------------------------------------------
|
||||
|
||||
fairwell:
|
||||
@echo ----------------------------------------------------------------
|
||||
@echo Finished Building $(APPNAME) for Target: $(TARGETDIR)
|
||||
@echo ----------------------------------------------------------------
|
||||
|
||||
clean:
|
||||
!IF "$(HAIL)" != "NO"
|
||||
@echo =^> Cleaning $(APPNAME) for Target: $(TARGETDIR)
|
||||
!ENDIF
|
||||
-@for %x in (.obj\$(TARGET)-$(OS_MAJOR).$(OS_MINOR)-DEBUG \
|
||||
.obj\$(TARGET)-$(OS_MAJOR).$(OS_MINOR) \
|
||||
.shobj\$(TARGET)-$(OS_MAJOR).$(OS_MINOR)-DEBUG \
|
||||
.shobj\$(TARGET)-$(OS_MAJOR).$(OS_MINOR) \
|
||||
.exec\$(TARGET)-$(OS_MAJOR).$(OS_MINOR)-DEBUG \
|
||||
.exec\$(TARGET)-$(OS_MAJOR).$(OS_MINOR)) DO \
|
||||
@if exist %x rmdir /s /q %x
|
||||
-@for %x in ($(BINARIES) $(TARGETS)) DO @if exist %x erase %x
|
||||
!IF "$(FAIRWELL)" != "NO"
|
||||
@echo ^<= Done...
|
||||
!ENDIF
|
||||
|
||||
purge:
|
||||
!IF "$(HAIL)" != "NO"
|
||||
@echo =^> Purging $(APPNAME) for Target: $(TARGETDIR)
|
||||
!ENDIF
|
||||
-@for %x in (.shobj .obj .exec) DO @if exist %x rmdir /s /q %x
|
||||
-@for %x in ($(BINARIES) $(TARGETS) $(TEMPLINKS)) DO @if exist %x erase %x
|
||||
!IF "$(FAIRWELL)" != "NO"
|
||||
@echo ^<= Done...
|
||||
!ENDIF
|
||||
|
||||
|
||||
.cc{.obj\$(TARGETDIR)}.obj::
|
||||
@echo =^> Compiling $<
|
||||
-@if not exist .obj\$(TARGETDIR) mkdir .obj\$(TARGETDIR)
|
||||
-@if not exist $(BINDIR) mkdir $(BINDIR)
|
||||
-@if not exist $(LIBDIR) mkdir $(LIBDIR)
|
||||
@$(CXX) $(CXX_LIB_FLAGS) $<
|
||||
|
||||
.cc{.shobj\$(TARGETDIR)}.obj::
|
||||
@echo =^> Compiling $<
|
||||
-@if not exist .shobj\$(TARGETDIR) mkdir .shobj\$(TARGETDIR)
|
||||
-@if not exist $(BINDIR) mkdir $(BINDIR)
|
||||
-@if not exist $(LIBDIR) mkdir $(LIBDIR)
|
||||
@$(CXX) $(CXX_DLL_FLAGS) $<
|
||||
|
||||
.cc{.exec\$(TARGETDIR)}.obj::
|
||||
@echo =^> Compiling $<
|
||||
-@if not exist .exec\$(TARGETDIR) mkdir .exec\$(TARGETDIR)
|
||||
-@if not exist $(BINDIR) mkdir $(BINDIR)
|
||||
-@if not exist $(LIBDIR) mkdir $(LIBDIR)
|
||||
@$(CXX) $(CXX_EXE_FLAGS) $<
|
||||
|
||||
.c{.obj\$(TARGETDIR)}.obj::
|
||||
@echo =^> Compiling $<
|
||||
-@if not exist .obj\$(TARGETDIR) mkdir .obj\$(TARGETDIR)
|
||||
-@if not exist $(BINDIR) mkdir $(BINDIR)
|
||||
-@if not exist $(LIBDIR) mkdir $(LIBDIR)
|
||||
@$(CC) $(CC_LIB_FLAGS) $<
|
||||
|
||||
.c{.shobj\$(TARGETDIR)}.obj::
|
||||
@echo =^> Compiling $<
|
||||
-@if not exist .shobj\$(TARGETDIR) mkdir .shobj\$(TARGETDIR)
|
||||
-@if not exist $(BINDIR) mkdir $(BINDIR)
|
||||
-@if not exist $(LIBDIR) mkdir $(LIBDIR)
|
||||
@$(CC) $(CC_DLL_FLAGS) $<
|
||||
|
||||
.c{.exec\$(TARGETDIR)}.obj::
|
||||
@echo =^> Compiling $<
|
||||
-@if not exist .exec\$(TARGETDIR) mkdir .exec\$(TARGETDIR)
|
||||
-@if not exist $(BINDIR) mkdir $(BINDIR)
|
||||
-@if not exist $(LIBDIR) mkdir $(LIBDIR)
|
||||
@$(CC) $(CC_EXE_FLAGS) $<
|
||||
@@ -0,0 +1,55 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.hpux : This is the platform specific Makefile for HPUX.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = aix
|
||||
OS_MAJOR := $(shell uname -v)
|
||||
OS_MAJOR_NUM := $(shell awk 'BEGIN {VAL=$(OS_MAJOR); print VAL; exit; }')
|
||||
OS_MINOR := $(shell uname -r)
|
||||
OS_MINOR_NUM := $(shell awk 'BEGIN {VAL=$(OS_MINOR); print VAL; exit; }')
|
||||
OS_VERSION_DEF := -D_OS_MAJOR_=$(OS_MAJOR_NUM) -D_OS_MINOR_=$(OS_MINOR_NUM)
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * All CDEV and service libaries required by archived applications
|
||||
# ******************************************************************************
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
endif
|
||||
|
||||
CXX = xlC
|
||||
CC = xlC
|
||||
CXXFLAGS = $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) \
|
||||
$(BASEINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG) -DAIX -qNOro
|
||||
CFLAGS = $(CCEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) \
|
||||
$(BASEINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG) -DAIX -qNOro
|
||||
LDFLAGS =
|
||||
AR = ar
|
||||
ARFLAGS = ruv
|
||||
RANLIB = true
|
||||
OSLIBS = -L/lib -lm
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = @echo "Shared objects not supported on AIX"
|
||||
COMPILE.c = $(CC) -c $(CFLAGS) $^ -o $@
|
||||
COMPILE.c.so = @echo "Shared objects not supported on AIX"
|
||||
LINK.cc = $(CXX) $(CXXFLAGS)
|
||||
LINK.a = $(AR) $(ARFLAGS)
|
||||
@@ -0,0 +1,9 @@
|
||||
# ***********************************************************************
|
||||
# * Makefile.archive *
|
||||
# * The ARCHIVELIBS variable should contain a complete list of *
|
||||
# * all libraries that will be needed by an ARCHIVE cdev program. *
|
||||
# * The variable should contain the path specification and the *
|
||||
# * name of the library in the format that is required by your *
|
||||
# * platform's linker. *
|
||||
# ***********************************************************************
|
||||
ARCHIVELIBS = -L$(CDEVLIB) -lcaService
|
||||
@@ -0,0 +1,94 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.common : This is the community makefile for the CDEV distribution.
|
||||
# * It contains the definitions that are common for all
|
||||
# * Makefiles in this distribution.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# * CDEVVERSION : The version of cdev being used
|
||||
# * TARGET : The name of the target platform
|
||||
# * OS_MAJOR : The major version number of the target OS
|
||||
# ******************************************************************************
|
||||
ifdef OS_MAJOR
|
||||
TARGETDIR = $(TARGET)-$(OS_MAJOR).$(OS_MINOR)
|
||||
else
|
||||
TARGETDIR = $(TARGET)
|
||||
endif
|
||||
|
||||
CDEVINCLUDES = -I$(CDEV)/include
|
||||
CDEVLIB = $(CDEV)/lib/$(TARGETDIR)
|
||||
CDEVBIN = $(CDEV)/bin/$(TARGETDIR)
|
||||
|
||||
# ******************************************************************************
|
||||
# * Set the CDEV Version if it has not been specified.
|
||||
# ******************************************************************************
|
||||
ifeq ($(CDEVVERSION), )
|
||||
CDEVVERSION = 1.7.2
|
||||
endif
|
||||
|
||||
# ******************************************************************************
|
||||
# * Set the CDEV shared object directory to a default location if not specified.
|
||||
# ******************************************************************************
|
||||
ifeq ($(CDEVSHOBJ), )
|
||||
CDEVSHOBJ = $(CDEVLIB)
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Set the object directory appropriately to the SHOBJ flag (default YES)
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), YES)
|
||||
OBJDIR = .shobj/$(TARGETDIR)
|
||||
else
|
||||
SHOBJ = NO
|
||||
OBJDIR = .obj/$(TARGETDIR)
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Rule for compiling archive C++ files.
|
||||
# ******************************************************************************
|
||||
.obj/$(TARGETDIR)/%.o : %.cc
|
||||
@rm -f $@
|
||||
@echo "=> $(CXX) -c $(^F) -o $(@F)"
|
||||
@mkdir -p .obj/$(TARGETDIR)
|
||||
@$(COMPILE.cc)
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Rule for compiling shared C++ files.
|
||||
# ******************************************************************************
|
||||
.shobj/$(TARGETDIR)/%.o : %.cc
|
||||
@rm -f $@
|
||||
@echo "=> $(CXX) -c $(^F) -o $(@F)"
|
||||
@mkdir -p .shobj/$(TARGETDIR)
|
||||
@$(COMPILE.cc.so)
|
||||
|
||||
# ******************************************************************************
|
||||
# * Generic rules for makefiles.
|
||||
# ******************************************************************************
|
||||
all: hail targets fairwell
|
||||
|
||||
hail:
|
||||
@echo
|
||||
@echo ----------------------------------------------------------------
|
||||
@echo Building $(APPNAME) for Target: $(TARGET)
|
||||
@echo ----------------------------------------------------------------
|
||||
|
||||
fairwell:
|
||||
@echo ----------------------------------------------------------------
|
||||
@echo Finished Building $(APPNAME) for Target: $(TARGET)
|
||||
@echo ----------------------------------------------------------------
|
||||
@echo
|
||||
|
||||
clean:
|
||||
@echo "=> Cleaning $(APPNAME) on $(TARGETDIR)"
|
||||
@rm -rf .o .a core .obj/$(TARGETDIR) .shobj/$(TARGETDIR) .exec/$(TARGETDIR) *.?.? TC.Cache $(BINARIES) $(TARGETS) ./ptrepository
|
||||
@echo "<= Done...\n"
|
||||
|
||||
purge:
|
||||
@echo "=> Purging $(APPNAME)"
|
||||
@rm -rf .shobj .obj .exec $(BINARIES) $(TARGETS) $(TEMPLINKS) .o .a core *.?.? TC.Cache ./ptrepository
|
||||
@echo "<= Done...\n"
|
||||
@@ -0,0 +1,74 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.hpux : This is the platform specific Makefile for HPUX.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = hpux
|
||||
OS_MAJOR := $(shell uname -r | awk -F "." '{print $$2; exit}')
|
||||
OS_MAJOR_NUM := $(shell awk 'BEGIN {VAL=$(OS_MAJOR); print VAL; exit; }')
|
||||
OS_MINOR := $(shell uname -r | awk -F "." '{print $$3; exit}')
|
||||
OS_MINOR_NUM := $(shell awk 'BEGIN {VAL=$(OS_MINOR); print VAL; exit; }')
|
||||
OS_VERSION_DEF := -D_OS_MAJOR_=$(OS_MAJOR_NUM) -D_OS_MINOR_=$(OS_MINOR_NUM)
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Due to a change in the operating system, the CXX compiler for HP-UX may
|
||||
# * be different depending on which platform is used.
|
||||
# ******************************************************************************
|
||||
ifeq ($(OS_MAJOR), 09)
|
||||
CXX := /usr/bin/CC
|
||||
HPCXX_FLAGS := -Aa -pta -ptb
|
||||
HPCXX_SHLIB_PATH := -Wl,+s
|
||||
else
|
||||
CXX := /opt/aCC/bin/aCC
|
||||
HPCXX_FLAGS := +W302,392,469,495,655,829
|
||||
HPCXX_SHLIB_PATH := -Wl,+s
|
||||
|
||||
ifeq ($(OS_MAJOR).$(OS_MINOR), 10.10)
|
||||
HP_FLAGS = -Dvolatile=""
|
||||
endif
|
||||
endif
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
else
|
||||
DEBUGFLAG = +O2
|
||||
endif
|
||||
|
||||
CXXFLAGS = -z $(HPCXX_FLAGS) $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) \
|
||||
$(OS_VERSION_DEF) $(DEBUGFLAG) $(HP_FLAGS)
|
||||
PIC = +z
|
||||
OSLIBS = -L/lib -lm
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) -c $(CXXFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -rf $@; echo "=> $(CXX) -o $(@F) $(^F)";$(CXX) $(CXXFLAGS) $(HPCXX_SHLIB_PATH) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.hpux-cl: This is the platform specific Makefile for HPUX using
|
||||
# * the CenterLine C++ compiler.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = hpux-cl
|
||||
SHOBJ = NO
|
||||
OS_MAJOR := $(shell uname -r | awk -F "." '{print $$2; exit}')
|
||||
OS_MAJOR_NUM := $(shell awk 'BEGIN {VAL=$(OS_MAJOR); print VAL; exit; }')
|
||||
OS_MINOR := $(shell uname -r | awk -F "." '{print $$3; exit}')
|
||||
OS_MINOR_NUM := $(shell awk 'BEGIN {VAL=$(OS_MINOR); print VAL; exit; }')
|
||||
OS_VERSION_DEF := -D_OS_MAJOR_=$(OS_MAJOR_NUM) -D_OS_MINOR_=$(OS_MINOR_NUM)
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
ifeq ($(OS_MAJOR_NUM), 10)
|
||||
HP_FLAGS = -Dvolatile=""
|
||||
endif
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
endif
|
||||
|
||||
CXX = /usr/csite4/CenterLine/bin/CC
|
||||
CXXFLAGS = -z -pta -D__CENTERLINE__ $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) \
|
||||
$(OS_VERSION_DEF) $(DEBUGFLAG) $(HP_FLAGS)
|
||||
PIC =
|
||||
OSLIBS = -lm
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications. The developer
|
||||
# * is required to add the list of service specific libraries.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = echo "Shared Object Compilation is NOT Supported by CenterLine"
|
||||
LINK.cc = rm -rf $@; echo "=> $(CXX) -o $(@F) $(^F)";$(PROOF) $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,2 @@
|
||||
SHOBJ=YES
|
||||
include $(CDEV)/include/makeinclude/Makefile.hpux-cl
|
||||
@@ -0,0 +1,2 @@
|
||||
SHOBJ=YES
|
||||
include $(CDEV)/include/makeinclude/Makefile.hpux
|
||||
@@ -0,0 +1,47 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.hpux : This is the platform specific Makefile for HPUX.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = SGI
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
endif
|
||||
|
||||
CXX = CC
|
||||
CXXFLAGS = $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG)
|
||||
PIC = -DSHM
|
||||
OSLIBS = -lm
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) -c $(CXXFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -rf $@; echo "=> $(CXX) -o $(@F) $(^F)";$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,2 @@
|
||||
SHOBJ=YES
|
||||
include $(CDEV)/include/makeinclude/Makefile.irix5
|
||||
@@ -0,0 +1,61 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.Linux : This is the platform specific Makefile for Linux.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = Linux
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
else
|
||||
DEBUGFLAG = -O2
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CC = gcc
|
||||
CXXFLAGS = -DLinux -DCDEV_HAS_UNDERSCORE_FDBITS -fno-for-scope $(DEBUGFLAG) $(CXXEXTRA) $(CXXINCLUDES) \
|
||||
$(CDEVINCLUDES)
|
||||
CFLAGS = -DLinux -DCDEV_HAS_UNDERSCORE_FDBITS $(DEBUGFLAG) $(CEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES)
|
||||
PIC = -fpic
|
||||
OSLIBS = -lm -ldl
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications. The developer
|
||||
# * is required to add the list of service specific libraries.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
#CDEVLIBS = -Xlinker -rpath -Xlinker $(CDEVLIB) -L$(CDEVLIB) -lcdev
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) $(CXXFLAGS) $(PIC) -c -o $@ $^
|
||||
COMPILE.c = $(CC) -c $(CFLAGS) $^ -o $@
|
||||
COMPILE.c.so = $(CC) -c $(CFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -f $@; $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.Linux : This is the platform specific Makefile for Linux.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = Linux
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
else
|
||||
DEBUGFLAG = -O2
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CC = gcc
|
||||
CXXFLAGS = -DLinux -DCDEV_HAS_64BIT_LONGS -fno-for-scope $(DEBUGFLAG) $(CXXEXTRA) $(CXXINCLUDES) \
|
||||
$(CDEVINCLUDES)
|
||||
CFLAGS = -DLinux -DCDEV_HAS_64BIT_LONGS $(DEBUGFLAG) $(CEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES)
|
||||
PIC = -fpic
|
||||
OSLIBS = -lm -ldl
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications. The developer
|
||||
# * is required to add the list of service specific libraries.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -Xlinker -rpath -Xlinker $(CDEVLIB) -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) $(CXXFLAGS) $(PIC) -c -o $@ $^
|
||||
COMPILE.c = $(CC) -c $(CFLAGS) $^ -o $@
|
||||
COMPILE.c.so = $(CC) -c $(CFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -f $@; $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,56 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.Linux : This is the platform specific Makefile for Linux.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = Linux
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
else
|
||||
DEBUGFLAG = -O2
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CC = gcc
|
||||
CXXFLAGS = -DLinux -fno-for-scope $(DEBUGFLAG) $(CXXEXTRA) $(CXXINCLUDES) \
|
||||
$(CDEVINCLUDES)
|
||||
CFLAGS = -DLinux $(DEBUGFLAG) $(CEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES)
|
||||
PIC = -fpic
|
||||
OSLIBS = -lm -ldl
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications. The developer
|
||||
# * is required to add the list of service specific libraries.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
#CDEVLIBS = -Xlinker -rpath -Xlinker $(CDEVLIB) -L$(CDEVLIB) -lcdev
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) $(CXXFLAGS) $(PIC) -c -o $@ $^
|
||||
COMPILE.c = $(CC) -c $(CFLAGS) $^ -o $@
|
||||
COMPILE.c.so = $(CC) -c $(CFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -f $@; $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,55 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.Linux : This is the platform specific Makefile for Linux.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = Linux
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
else
|
||||
DEBUGFLAG = -O2
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CC = gcc
|
||||
CXXFLAGS = -DLinux -DCDEV_HAS_UNDERSCORE_FDBITS -DCDEV_HAS_64BIT_LONGS -fno-for-scope $(DEBUGFLAG) $(CXXEXTRA) $(CXXINCLUDES) \
|
||||
$(CDEVINCLUDES)
|
||||
CFLAGS = -DLinux -DCDEV_HAS_UNDERSCORE_FDBITS -DCDEV_HAS_64BIT_LONGS $(DEBUGFLAG) $(CEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES)
|
||||
PIC = -fpic
|
||||
OSLIBS = -lm -ldl
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications. The developer
|
||||
# * is required to add the list of service specific libraries.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -Xlinker -rpath -Xlinker $(CDEVLIB) -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) $(CXXFLAGS) $(PIC) -c -o $@ $^
|
||||
COMPILE.c = $(CC) -c $(CFLAGS) $^ -o $@
|
||||
COMPILE.c.so = $(CC) -c $(CFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -f $@; $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,61 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.Linux : This is the platform specific Makefile for Linux.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = Linux
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
else
|
||||
DEBUGFLAG = -O2
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CC = gcc
|
||||
CXXFLAGS = -DLinux -DCDEV_HAS_UNDERSCORE_FDBITS -fno-for-scope $(DEBUGFLAG) $(CXXEXTRA) $(CXXINCLUDES) \
|
||||
$(CDEVINCLUDES)
|
||||
CFLAGS = -DLinux -DCDEV_HAS_UNDERSCORE_FDBITS $(DEBUGFLAG) $(CEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES)
|
||||
PIC = -fpic
|
||||
OSLIBS = -lm -ldl
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications. The developer
|
||||
# * is required to add the list of service specific libraries.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
#CDEVLIBS = -Xlinker -rpath -Xlinker $(CDEVLIB) -L$(CDEVLIB) -lcdev
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) $(CXXFLAGS) $(PIC) -c -o $@ $^
|
||||
COMPILE.c = $(CC) -c $(CFLAGS) $^ -o $@
|
||||
COMPILE.c.so = $(CC) -c $(CFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -f $@; $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.Linux : This is the platform specific Makefile for Linux.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = Linux
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
else
|
||||
DEBUGFLAG = -O2
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CC = gcc
|
||||
CXXFLAGS = -DLinux -DCDEV_HAS_UNDERSCORE_FDBITS -fno-for-scope $(DEBUGFLAG) $(CXXEXTRA) $(CXXINCLUDES) \
|
||||
$(CDEVINCLUDES)
|
||||
CFLAGS = -DLinux -DCDEV_HAS_UNDERSCORE_FDBITS $(DEBUGFLAG) $(CEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES)
|
||||
PIC = -fpic
|
||||
OSLIBS = -lm -ldl
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications. The developer
|
||||
# * is required to add the list of service specific libraries.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
#CDEVLIBS = -Xlinker -rpath -Xlinker $(CDEVLIB) -L$(CDEVLIB) -lcdev
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) $(CXXFLAGS) $(PIC) -c -o $@ $^
|
||||
COMPILE.c = $(CC) -c $(CFLAGS) $^ -o $@
|
||||
COMPILE.c.so = $(CC) -c $(CFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -f $@; $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
SHOBJ=YES
|
||||
include $(CDEV)/include/makeinclude/Makefile.linux
|
||||
@@ -0,0 +1,47 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.hpux : This is the platform specific Makefile for HPUX.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = solaris
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
endif
|
||||
|
||||
CXX = CC
|
||||
CXXFLAGS = $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG) -Dsolaris -DSYSV -DSVR4
|
||||
PIC = -Kpic
|
||||
OSLIBS = -lsocket -lnsl -lm
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -R$(CDEVLIB) -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) -c $(CXXFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -rf $@; echo "=> $(CXX) -o $(@F) $(^F)";$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,47 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.hpux : This is the platform specific Makefile for HPUX.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = solaris-gnu
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CXXFLAGS = $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG)
|
||||
PIC = -fpic
|
||||
OSLIBS = -lsocket -lnsl -lm
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) -c $(CXXFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -rf $@; echo "=> $(CXX) -o $(@F) $(^F)";$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,2 @@
|
||||
SHOBJ=YES
|
||||
include $(CDEV)/include/makeinclude/Makefile.solaris-gcc
|
||||
@@ -0,0 +1,2 @@
|
||||
SHOBJ=YES
|
||||
include $(CDEV)/include/makeinclude/Makefile.solaris
|
||||
@@ -0,0 +1,47 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.hpux : This is the platform specific Makefile for HPUX.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = SunOs-gnu
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CXXFLAGS = $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG)
|
||||
PIC = -fpic
|
||||
OSLIBS = -lm
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = $(CXX) -c $(CXXFLAGS) $(PIC) $^ -o $@
|
||||
LINK.cc = rm -rf $@; echo "=> $(CXX) -o $(@F) $(^F)";$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,2 @@
|
||||
SHOBJ=YES
|
||||
include $(CDEV)/include/makeinclude/Makefile.sunos4-gcc
|
||||
@@ -0,0 +1,47 @@
|
||||
# ******************************************************************************
|
||||
# * Makefile.hpux : This is the platform specific Makefile for HPUX.
|
||||
# *
|
||||
# * Externals : This Makefile relies on the developer defining the
|
||||
# * following external definitions...
|
||||
# *
|
||||
# * CDEV : The base directory of the CDEV distribution
|
||||
# ******************************************************************************
|
||||
TARGET = ULTRIX
|
||||
|
||||
include $(CDEV)/include/makeinclude/Makefile.common
|
||||
include $(CDEV)/include/makeinclude/Makefile.archive
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link options.
|
||||
# ******************************************************************************
|
||||
|
||||
# ******************************************************************************
|
||||
# * Only define the DEBUGFLAG if DEBUG has been specified by the caller.
|
||||
# ******************************************************************************
|
||||
ifdef DEBUG
|
||||
DEBUGFLAG = -g
|
||||
endif
|
||||
|
||||
CXX = g++
|
||||
CXXFLAGS = $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG)
|
||||
PIC =
|
||||
OSLIBS = -lm
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * These definitions define the names and locations of libraries that are
|
||||
# * required by CDEV for a shared and archive applications.
|
||||
# ******************************************************************************
|
||||
ifeq ($(SHOBJ), NO)
|
||||
CDEVLIBS = $(CDEVLIB)/libcdev.a $(ARCHIVELIBS)
|
||||
else
|
||||
CDEVLIBS = -L$(CDEVLIB) -lcdev
|
||||
endif
|
||||
|
||||
|
||||
# ******************************************************************************
|
||||
# * Platform specific compile and link macros.
|
||||
# ******************************************************************************
|
||||
COMPILE.cc = $(CXX) -c $(CXXFLAGS) $^ -o $@
|
||||
COMPILE.cc.so = @echo "Shared Object Compilation is NOT Supported on ULTRIX"
|
||||
LINK.cc = rm -rf $@; echo "=> $(CXX) -o $(@F) $(^F)";$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -o $@ $(CDEVLIBS) $(OSLIBS)
|
||||
@@ -0,0 +1,169 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 1994,1995 Southeastern Universities Research Association,
|
||||
// Continuous Electron Beam Accelerator Facility
|
||||
//
|
||||
// This software was developed under a United States Government license
|
||||
// described in the NOTICE file included as part of this distribution.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Description:
|
||||
// shObjLoader class (for hp ,sun (SunOs 4.x) , sgi (irix),
|
||||
// solaris 2.x and linux only)
|
||||
//
|
||||
// Author: Jie Chen
|
||||
//
|
||||
// Revision History:
|
||||
// shObjLoader.h,v
|
||||
// Revision 1.6 1996/03/22 16:32:09 chen
|
||||
// support solaris
|
||||
//
|
||||
// Revision 1.5 1995/11/14 17:35:17 chen
|
||||
// better header
|
||||
//
|
||||
// Revision 1.4 1995/11/14 17:33:37 chen
|
||||
// fix to work under irix5.3
|
||||
//
|
||||
// Revision 1.3 1995/10/18 17:45:06 chen
|
||||
// To work under SunOs
|
||||
//
|
||||
// Revision 1.2 1995/10/17 13:25:18 chen
|
||||
// Change load (int flag) to load (void)
|
||||
//
|
||||
// Revision 1.1.1.1 1995/06/16 17:14:02 epics
|
||||
// initial import of cdev
|
||||
//
|
||||
//
|
||||
#ifndef _SH_OBJ_LOADER_H
|
||||
#define _SH_OBJ_LOADER_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __hpux
|
||||
#ifdef _CENTERLINE
|
||||
#include <dl.h>
|
||||
#define HP_SHOBJ_LOADER ::shl_load
|
||||
#define HP_SHOBJ_UNLOADER ::shl_unload
|
||||
#elif (_OS_MAJOR==9 || (_OS_MAJOR==10 && _OS_MINOR==10))
|
||||
#include <cxxdl.h>
|
||||
#define HP_SHOBJ_LOADER ::cxxshl_load
|
||||
#define HP_SHOBJ_UNLOADER ::cxxshl_unload
|
||||
#else
|
||||
#include <dl.h>
|
||||
#define HP_SHOBJ_LOADER ::shl_load
|
||||
#define HP_SHOBJ_UNLOADER ::shl_unload
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef sunos4
|
||||
// sun header file dlfunc.h is not defined for cplusplus
|
||||
extern "C"
|
||||
{
|
||||
void *dlopen (char* path, int mode);
|
||||
void *dlsym (void* handle, char* symbol);
|
||||
char *dlerror (void);
|
||||
int dlclose (void* handle);
|
||||
};
|
||||
#define RTLD_LAZY 1
|
||||
#endif
|
||||
|
||||
#if defined (sgi) || defined (solaris) || defined (aix) || defined (__linux)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef SHOBJ
|
||||
#define SHOBJ 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
class shObjLoader
|
||||
{
|
||||
public:
|
||||
//constructors and destructor
|
||||
shObjLoader (char *path);
|
||||
virtual ~shObjLoader (void);
|
||||
|
||||
virtual int open (char *name);
|
||||
// PURPOSE: open a shared library by a given name
|
||||
// REQUIRE: name != 0
|
||||
// PROMISE: library path name will be stored
|
||||
|
||||
virtual int load (void);
|
||||
// PURPOSE: load a shared library in verbose mode if possible
|
||||
// REQUIRE: call open first
|
||||
// PROMISE: return 0: success loaded. return -1: load failed
|
||||
|
||||
virtual int findProcedureSym (const char * sym, void** value);
|
||||
// PURPOSE: find procedure address given by symbol
|
||||
// REQUIRE: call load first
|
||||
// PROMISE: value will be the address. return 0: success, -1: failure
|
||||
|
||||
#ifdef __hpux
|
||||
virtual int findDataSym (const char * sym, void * value);
|
||||
// PURPOSE: find data address given by symbol
|
||||
// REQUIRE: call load first
|
||||
// PROMISE: value will be the address
|
||||
|
||||
virtual int findSym (const char * sym, void * value);
|
||||
// PURPOSE: find address given by symbol
|
||||
// REQUIRE: call load first
|
||||
// PROMISE: value will be the address. return 0: success, -1: failure
|
||||
|
||||
unsigned long textStartAddr (void);
|
||||
// PURPOSE: find text section start address
|
||||
// REQUIRE: call load first
|
||||
// PROMISE: return address, 0: failure
|
||||
|
||||
unsigned long textEndAddr (void);
|
||||
// PURPOSE: find text section end address
|
||||
// REQUIRE: call load first
|
||||
// PROMISE: return address, 0: failure
|
||||
|
||||
unsigned long dataStartAddr (void);
|
||||
// PURPOSE: find data section start address
|
||||
// REQUIRE: call load first
|
||||
// PROMISE: return address, 0: failure
|
||||
|
||||
unsigned long dataEndAddr (void);
|
||||
// PURPOSE: find data section end address
|
||||
// REQUIRE: call load first
|
||||
// PROMISE: return address, 0: failure
|
||||
#endif // end __hpux
|
||||
|
||||
const char *filename (void);
|
||||
// PURPOSE: loaded shared library path name
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: 0: means nothing loaded
|
||||
|
||||
virtual int close (void);
|
||||
// PURPOSE: remove shared library from memory
|
||||
// REQUIRE: nothing
|
||||
// PROMISE: Shared library will be removed from memory
|
||||
// filename () return 0
|
||||
|
||||
virtual const char *className (void) const {return "shObjLoader";}
|
||||
|
||||
private:
|
||||
#ifdef __hpux
|
||||
shl_t libHandler_;
|
||||
struct shl_descriptor *desc_;
|
||||
#endif // endif __hpux
|
||||
|
||||
#if defined (sunos4) || defined (sgi) || defined (solaris) || defined (aix) || defined (__linux)
|
||||
void* libHandler_;
|
||||
#endif // endif sun or sgi
|
||||
|
||||
#if defined (_WIN32)
|
||||
HINSTANCE libHandler_;
|
||||
#endif
|
||||
|
||||
char *libName_;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,450 @@
|
||||
#ifndef _XDR_CLASS_H_
|
||||
#define _XDR_CLASS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined (ultrix) || defined (sgi) || defined (solaris)
|
||||
#include <rpc/types.h>
|
||||
#endif
|
||||
|
||||
// Under TGV Multinet and VMS, before you can #include rpc/xdr.h (below),
|
||||
// rpc/types.h must be included, so that bool_t is defined and sys/types.h is
|
||||
// #included.
|
||||
//
|
||||
// Under TGV Multinet and VMS, if you want sys/types.h, you need to have
|
||||
// types.h already pulled in because sys/types.h makes it look like types.h
|
||||
// is loaded. Then when types.h does get loaded, it is ignored because it
|
||||
// looks like it is already loaded.
|
||||
//
|
||||
// rpc/types.h defines bool_t, required by rpc/xdr.h
|
||||
// rpc/types.h #includes sys/types.h
|
||||
// sys/types.h defines caddr_t, required by rpc/xdr.h and
|
||||
// defines u_int,u_short required by netinet/in.h
|
||||
// --Mr. Daniel Van Olst at SLAC vanolst@slc.slac.stanford.edu
|
||||
|
||||
#ifdef __VMS
|
||||
#ifdef _TGV_MULTINET
|
||||
#include <types.h>
|
||||
#include <rpc/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#include <rpc/xdr.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "xdr.h"
|
||||
#else
|
||||
#include <rpc/rpc.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <cdevTypes.h>
|
||||
|
||||
static bool_t xdr_timestamp( XDR * xdrs, cdev_TS_STAMP * ts) {
|
||||
if ( xdr_u_long (xdrs, &ts->secPastEpoch) == 0) return 0;
|
||||
return (xdr_u_long (xdrs, &ts->nsec));
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
// * XDR_Size_of :
|
||||
// * Functions used to determine the size of a data element once translated
|
||||
// * and placed into an XDR stream.
|
||||
// *****************************************************************************
|
||||
#if !defined( NO_TEMPLATES )
|
||||
template <class T> inline unsigned XDR_Sizeof( T t ) {
|
||||
return (RNDUP(sizeof(t))); }
|
||||
#else
|
||||
inline unsigned XDR_Sizeof(char x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(unsigned char x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(short x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(unsigned short x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(int x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(unsigned int x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(long x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(unsigned long x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(float x) { return (RNDUP(sizeof(x))); }
|
||||
inline unsigned XDR_Sizeof(double x) { return (RNDUP(sizeof(x))); }
|
||||
|
||||
#endif
|
||||
|
||||
inline unsigned XDR_Sizeof( char * s ) {
|
||||
return (RNDUP(strlen(s)) + BYTES_PER_XDR_UNIT); }
|
||||
|
||||
inline unsigned XDR_Sizeof( char *, unsigned len ) {
|
||||
return (RNDUP(len) + BYTES_PER_XDR_UNIT); }
|
||||
|
||||
inline unsigned XDR_Sizeof( void *, unsigned len ) {
|
||||
return (RNDUP(len) + BYTES_PER_XDR_UNIT); }
|
||||
|
||||
inline unsigned XDR_Sizeof( cdev_TS_STAMP ts ) {
|
||||
return (RNDUP(sizeof(ts))); }
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned bufLen;
|
||||
char * buf;
|
||||
} XDR_DataBlock;
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * This is the XDR_Data class. It allows the user to pass the data associated
|
||||
// * with the XDR_Writer and XDR_Reader classes in a format that is not
|
||||
// * restricted to XDR read or XDR write.
|
||||
// *****************************************************************************
|
||||
class XDR_Data : public XDR_DataBlock
|
||||
{
|
||||
public:
|
||||
XDR_Data ( void )
|
||||
{ buf = NULL; bufLen = 0; }
|
||||
|
||||
XDR_Data ( char * Buf, unsigned Len )
|
||||
{ buf = NULL; bufLen = 0; assign(Buf, Len); }
|
||||
|
||||
XDR_Data ( XDR_Data & x )
|
||||
{ buf = NULL; bufLen = 0; assign(x.buf, x.bufLen); }
|
||||
|
||||
~XDR_Data ( void ) { deallocate(); }
|
||||
unsigned & size ( void ) { return bufLen; }
|
||||
char * & buffer ( void ) { return buf; }
|
||||
int ready ( void ) { return (buf!=NULL && bufLen>0)?1:0; }
|
||||
|
||||
void allocate ( unsigned Len )
|
||||
{
|
||||
if(Len==0) XDR_Data::deallocate();
|
||||
else if(Len!=bufLen || buf==NULL)
|
||||
{
|
||||
XDR_Data::deallocate();
|
||||
bufLen = Len;
|
||||
buf = new char[bufLen];
|
||||
XDR_Data::clear();
|
||||
}
|
||||
else XDR_Data::clear();
|
||||
}
|
||||
|
||||
void deallocate ( void )
|
||||
{
|
||||
if(buf!=NULL)
|
||||
{
|
||||
delete buf;
|
||||
buf = NULL;
|
||||
}
|
||||
bufLen = 0;
|
||||
}
|
||||
|
||||
void assign ( char * Buf, unsigned Len)
|
||||
{
|
||||
XDR_Data::allocate(Len);
|
||||
memcpy(buf, Buf, bufLen);
|
||||
}
|
||||
|
||||
void clear ( void )
|
||||
{
|
||||
memset(buf, 0, bufLen);
|
||||
}
|
||||
|
||||
void attachData ( XDR_Data & data )
|
||||
{
|
||||
attachData(data.buf, data.bufLen);
|
||||
}
|
||||
|
||||
void attachData ( char * Buf, unsigned BufLen )
|
||||
{
|
||||
XDR_Data::deallocate();
|
||||
buf = Buf;
|
||||
bufLen = BufLen;
|
||||
}
|
||||
|
||||
void detachData ( void )
|
||||
{
|
||||
buf = 0;
|
||||
bufLen = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * This is the XDR_Base class. It provides the basic mechanism for generating
|
||||
// * character streams that contain XDR data storage.
|
||||
// *****************************************************************************
|
||||
class XDR_Base : public XDR_Data
|
||||
{
|
||||
protected:
|
||||
XDR xdrs;
|
||||
const enum xdr_op op;
|
||||
|
||||
XDR_Base (enum xdr_op xop ) : XDR_Data(), op(xop) {}
|
||||
XDR_Base (XDR_Data & xdrData, enum xdr_op xop) : op(xop)
|
||||
{
|
||||
allocate(xdrData.size());
|
||||
memcpy(buf, xdrData.buffer(), xdrData.size());
|
||||
xdr_setpos(xdr(), 0);
|
||||
}
|
||||
~XDR_Base ( void ) { deallocate(); }
|
||||
|
||||
public:
|
||||
XDR * xdr ( void ) { return &xdrs; }
|
||||
unsigned position ( void ) { return ready()?xdr_getpos(&xdrs):0L; }
|
||||
|
||||
void allocate ( unsigned Len)
|
||||
{
|
||||
if(Len==0) XDR_Base::deallocate();
|
||||
else if(Len!=bufLen || buf==NULL)
|
||||
{
|
||||
XDR_Base::deallocate();
|
||||
XDR_Data::allocate(Len);
|
||||
xdrmem_create(&xdrs, buf, bufLen, op);
|
||||
}
|
||||
else XDR_Data::clear();
|
||||
}
|
||||
|
||||
void deallocate ( void )
|
||||
{
|
||||
if(ready())
|
||||
{
|
||||
xdr_destroy(&xdrs);
|
||||
XDR_Data::deallocate();
|
||||
}
|
||||
}
|
||||
|
||||
void clear ( void )
|
||||
{
|
||||
if(ready())
|
||||
{
|
||||
XDR_Data::clear();
|
||||
xdr_setpos(&xdrs, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void attachData ( XDR_Data & data )
|
||||
{
|
||||
XDR_Base::attachData(data.buf, data.bufLen);
|
||||
}
|
||||
|
||||
void attachData ( char * Buf, unsigned BufLen )
|
||||
{
|
||||
XDR_Base::deallocate();
|
||||
XDR_Data::attachData(Buf, BufLen);
|
||||
xdrmem_create(&xdrs, buf, bufLen, op);
|
||||
}
|
||||
|
||||
void detachData ( void )
|
||||
{
|
||||
XDR_Data::detachData();
|
||||
XDR_Base::deallocate();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * This is the XDR_Writer class. It provides the mechanisms for creating and
|
||||
// * managing an outgoing stream of XDR data.
|
||||
// *****************************************************************************
|
||||
class XDR_Writer : public XDR_Base
|
||||
{
|
||||
public:
|
||||
XDR_Writer (unsigned len = 0) : XDR_Base(XDR_ENCODE) { XDR_Base::allocate(len); }
|
||||
XDR_Writer (XDR_Data & xdrData ) : XDR_Base(xdrData, XDR_ENCODE) {}
|
||||
|
||||
int put_char ( char x )
|
||||
{ return ready()?xdr_char(&xdrs, &x):0; }
|
||||
|
||||
int put_u_char ( unsigned char x )
|
||||
#ifndef sunos4
|
||||
{ return ready()?xdr_u_char(&xdrs, &x):0; }
|
||||
#else
|
||||
{ return ready()?xdr_u_char(&xdrs, (char *)&x):0; }
|
||||
#endif
|
||||
|
||||
int put_int ( int x )
|
||||
{ return ready()?xdr_int(&xdrs, &x):0; }
|
||||
|
||||
int put_u_int ( unsigned int x )
|
||||
{ return ready()?xdr_u_int(&xdrs, &x):0; }
|
||||
|
||||
int put_short ( short x )
|
||||
{ return ready()?xdr_short(&xdrs, &x):0; }
|
||||
|
||||
int put_u_short( unsigned short x )
|
||||
{ return ready()?xdr_u_short(&xdrs, &x):0; }
|
||||
|
||||
int put_long ( long x )
|
||||
{ return ready()?xdr_long(&xdrs, &x):0; }
|
||||
|
||||
int put_u_long ( unsigned long x )
|
||||
{ return ready()?xdr_u_long(&xdrs, &x):0; }
|
||||
|
||||
int put_float ( float x )
|
||||
{ return ready()?xdr_float(&xdrs, &x):0; }
|
||||
|
||||
int put_double ( double x )
|
||||
{ return ready()?xdr_double(&xdrs, &x):0; }
|
||||
|
||||
int put_bytes ( char ** bytes, unsigned int num )
|
||||
{ return ready()?
|
||||
xdr_bytes(&xdrs, bytes, &num, size()-position()):
|
||||
0; }
|
||||
|
||||
int put_string ( char * str )
|
||||
{ return ready()?
|
||||
xdr_string(&xdrs, &str, size()-position()):
|
||||
0; }
|
||||
|
||||
int put_opaque ( void * data, unsigned len )
|
||||
{ int status = 0;
|
||||
if(ready())
|
||||
{
|
||||
status=xdr_u_int (&xdrs, &len);
|
||||
if(status) status=xdr_opaque(&xdrs, (char *)data, len);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int put_timestamp ( cdev_TS_STAMP ts )
|
||||
{ return ready()?xdr_timestamp(&xdrs, &ts):0; }
|
||||
|
||||
int put ( char x ) { return put_char(x); }
|
||||
int put ( unsigned char x ) { return put_u_char(x); }
|
||||
int put ( int x ) { return put_int(x); }
|
||||
int put ( unsigned int x ) { return put_u_int(x); }
|
||||
int put ( short x ) { return put_short(x); }
|
||||
int put ( unsigned short x ) { return put_u_short(x); }
|
||||
int put ( long x ) { return put_long(x); }
|
||||
int put ( unsigned long x ) { return put_u_long(x); }
|
||||
int put ( float x ) { return put_float(x); }
|
||||
int put ( double x ) { return put_double(x); }
|
||||
int put ( char * str ) { return put_string(str); }
|
||||
int put ( void * x, unsigned len ) { return put_opaque(x, len); }
|
||||
int put ( cdev_TS_STAMP ts ) { return put_timestamp(ts); }
|
||||
};
|
||||
|
||||
|
||||
// *****************************************************************************
|
||||
// * This is the XDR_Reader class. It provides the mechanisms for creating and
|
||||
// * managing an incoming stream of XDR data.
|
||||
// *****************************************************************************
|
||||
class XDR_Reader : public XDR_Base
|
||||
{
|
||||
public:
|
||||
XDR_Reader (unsigned len = 0) : XDR_Base(XDR_DECODE) { XDR_Base::allocate(len); }
|
||||
XDR_Reader (XDR_Data & xdrData ) : XDR_Base(xdrData, XDR_DECODE) {}
|
||||
|
||||
int get_char ( char & x )
|
||||
{ return ready()?xdr_char(&xdrs, &x):0; }
|
||||
|
||||
int get_u_char ( unsigned char & x )
|
||||
#ifndef sunos4
|
||||
{ return ready()?xdr_u_char(&xdrs, &x):0; }
|
||||
#else
|
||||
{ return ready()?xdr_u_char(&xdrs, (char *)&x):0; }
|
||||
#endif
|
||||
|
||||
int get_int ( int & x )
|
||||
{ return ready()?xdr_int(&xdrs, &x):0; }
|
||||
|
||||
int get_u_int ( unsigned int & x )
|
||||
{ return ready()?xdr_u_int(&xdrs, &x):0; }
|
||||
|
||||
int get_short ( short & x )
|
||||
{ return ready()?xdr_short(&xdrs, &x):0; }
|
||||
|
||||
int get_u_short ( unsigned short & x )
|
||||
{ return ready()?xdr_u_short(&xdrs, &x):0; }
|
||||
|
||||
int get_long ( long & x )
|
||||
{ return ready()?xdr_long(&xdrs, &x):0; }
|
||||
|
||||
int get_u_long ( unsigned long & x )
|
||||
{ return ready()?xdr_u_long(&xdrs, &x):0; }
|
||||
|
||||
int get_float ( float & x )
|
||||
{ return ready()?xdr_float(&xdrs, &x):0; }
|
||||
|
||||
int get_double ( double & x )
|
||||
{ return ready()?xdr_double(&xdrs, &x):0; }
|
||||
|
||||
int get_bytes ( char ** bytes, unsigned int & num, unsigned int max )
|
||||
{ return ready()?xdr_bytes(&xdrs, bytes, &num, max):0; }
|
||||
|
||||
int get_string_len ( void )
|
||||
{ return ready()?ntohl(*(long *)((char *)buf+xdr_getpos(&xdrs))):0; }
|
||||
|
||||
int get_string ( char ** str, unsigned int max = -1U )
|
||||
{
|
||||
int result = 0;
|
||||
int slen = get_string_len()+1;
|
||||
char * s = new char[slen];
|
||||
if(ready())
|
||||
{
|
||||
result = xdr_string(&xdrs, &s, slen);
|
||||
if(str!=NULL)
|
||||
{
|
||||
if(max==-1U || *str==NULL)
|
||||
{
|
||||
*str = s;
|
||||
s = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(*str, s, max);
|
||||
str[max-1] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(s!=NULL) delete s;
|
||||
return result;
|
||||
}
|
||||
|
||||
int get_opaque ( void ** data, unsigned int * len, unsigned int max = -1U)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if(ready())
|
||||
{
|
||||
unsigned int slen;
|
||||
char * s;
|
||||
|
||||
if((result=xdr_u_int(&xdrs, &slen))!=0)
|
||||
{
|
||||
s = new char[slen];
|
||||
result=xdr_opaque(&xdrs, s, slen);
|
||||
}
|
||||
if(result!=0)
|
||||
{
|
||||
if(*data==NULL || max==-1U)
|
||||
{
|
||||
*len = slen;
|
||||
*data = s;
|
||||
s = NULL;
|
||||
}
|
||||
else {
|
||||
*len = (slen<max)?slen:max;
|
||||
memcpy(*data, s, *len);
|
||||
}
|
||||
}
|
||||
if(s!=NULL) delete s;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int get_timestamp ( cdev_TS_STAMP & ts )
|
||||
{ return ready()?xdr_timestamp(&xdrs, &ts):0; }
|
||||
|
||||
int get ( char & x ) { return get_char(x); }
|
||||
int get ( unsigned char & x ) { return get_u_char(x); }
|
||||
int get ( int & x ) { return get_int(x); }
|
||||
int get ( unsigned int & x ) { return get_u_int(x); }
|
||||
int get ( short & x ) { return get_short(x); }
|
||||
int get ( unsigned short & x ) { return get_u_short(x); }
|
||||
int get ( long & x ) { return get_long(x); }
|
||||
int get ( unsigned long & x ) { return get_u_long(x); }
|
||||
int get ( float & x ) { return get_float(x); }
|
||||
int get ( double & x ) { return get_double(x); }
|
||||
int get ( char ** s, unsigned max = -1U) { return get_string(s, max); }
|
||||
int get ( void ** x, unsigned *len, unsigned max = -1U) { return get_opaque(x, len, max); }
|
||||
int get ( cdev_TS_STAMP & ts ) { return get_timestamp(ts); }
|
||||
};
|
||||
|
||||
|
||||
#endif // _XDR_CLASS_H_
|
||||
Reference in New Issue
Block a user