Important update:

- EventBufferCore: (new)
  - Defines Events and related functions
  - Defines Event Buffer
- ItemBuffer:
  - Specify "Keep" parameter for Delete, to override CopyEntries
This commit is contained in:
Charl Wentzel
2017-08-21 20:51:10 +02:00
parent 2830b8dd6d
commit 5f5e89e7cd
6 changed files with 502 additions and 8 deletions

99
EventBufferCore.h Normal file
View File

@@ -0,0 +1,99 @@
/*
* EventBufferCore.h
* *
* Created on: 20 Aug 2017
* Author: wentzelc
*/
#ifndef REDACORE_EVENTBUFFERCORE_H_
#define REDACORE_EVENTBUFFERCORE_H_
//---------------------------------------------------------------------------
// Standard C/C++ Libraries
/* none */
// redA Libraries
#include "ItemBufferCore.h"
//---------------------------------------------------------------------------
// Prototypes
class CEventBuffer;
typedef struct SEventEntry TEventEntry;
typedef struct SEventType TEventType;
//---------------------------------------------------------------------------
// Data Structures
struct SEventEntry {
unsigned EventNo;
char * EventType;
char * Parent;
char * DeviceName;
char * ParamName;
char * Value;
char DateTime[20];
char * SourceName;
};
struct SEventType {
char * Name;
TEventType * Next;
};
//---------------------------------------------------------------------------
// General Event life cycle functions
TEventEntry * CreateEvent();
TEventEntry * CreateEvent( const char * EventType, const char * Parent, const char * DeviceName, const char * ParamName,
long Value, const char * DateTimeStr, const char * SourceName );
TEventEntry * CreateEvent( const char * EventType, const char * Parent, const char * DeviceName, const char * ParamName,
double Value, const char * DateTimeStr, const char * SourceName );
TEventEntry * CreateEvent( const char * EventType, const char * Parent, const char * DeviceName, const char * ParamName,
const char * Value, const char * DateTimeStr, const char * SourceName );
TEventEntry * CopyEvent( TEventEntry * Event );
bool DestroyEvent( TEventEntry ** Event );
//---------------------------------------------------------------------------
// Event buffer abstract object (base class)
class CEventBuffer : protected CItemBuffer
{
protected:
char Name[31];
CEventBuffer * PeerBuffer;
TEventType * FirstEventType;
public:
CEventBuffer( const char * BufferName );
virtual ~CEventBuffer();
// Markers
TEventEntry * CurrentEvent;
unsigned int EventCount;
char * GetName() { return Name; };
// Initialisation
bool SetPeerBuffer( CEventBuffer *pPeerBuffer );
// Filter List
bool SetEventFilter( int n, ... );
bool PassEventFilter( TEventEntry * Event );
// Buffering
virtual bool AddEvent( TEventEntry * Event, unsigned int EventNo = 0 );
virtual TEventEntry * GetNextEvent( bool &Error );
virtual bool ClearCurrentEvent();
virtual bool ClearLastEvent( bool FreeEvent );
virtual bool DestroyEntry( void ** Entry );
};
//---------------------------------------------------------------------------
#endif /*REDACORE_EVENTBUFFERCORE_H_*/