Files
redAcore/FunctionCore.h
Charl Wentzel 1a9f825b25 Major Update:
- Minor fix: Set correct names in comments at top of file
- New FileCore Class:
  - Writing data to output file
- BufferCore:
  - Check for "EAGAIN" on write and retry write
- FunctionCore:
  - Add new Output method that references LocalIO directly
- SelectableCore:
  - New method SetAutomanage to specify auto re-open parameters
  - Re-open timer implemented to slow re-open events
  - Only call ProcessBuffer() if data received on socket
  - Force processing input data when no input marker set
  - Use new Output method to simplify code
  - Bug fix: Read correctly from buffer on multiple reads/writes on FD
  - Check for "EAGAIN" on write to FD and retry write
2016-07-20 09:37:25 +02:00

98 lines
2.4 KiB
C++

/*
* FunctionCore.h
*
* Created on: 18 May 2016
* Author: wentzelc
*/
#ifndef REDACORE_FUNCTIONCORE_H_
#define REDACORE_FUNCTIONCORE_H_
// redA Libraries
#include "LogCore.h"
#include "BufferCore.h"
// Standard C/C++ Libraries
#include <string.h>
#include <sys/time.h>
//---------------------------------------------------------------------------
// Preview
typedef struct SLocalIO TLocalIO;
typedef struct SLinkedIO TLinkedIO;
class CFunctionCore;
//---------------------------------------------------------------------------
struct SLocalIO
{
char * Name;
TLinkedIO * FirstInput;
TLinkedIO * FirstOutput;
TLocalIO * Next;
};
//---------------------------------------------------------------------------
struct SLinkedIO
{
CFunctionCore * Function;
char * IOName;
SLinkedIO * Next;
};
//---------------------------------------------------------------------------
class CFunctionCore
{
protected:
// Function Definition
char * Name;
// IOs
TLocalIO * FirstIO;
// Output
EDebugLevel DebugLevel;
int OutputDisplay;
// Manage IO
inline TLocalIO * GetLocalIO( const char * Name ) {
TLocalIO * LocalIO = FirstIO;
while (LocalIO && strcmp( Name, LocalIO->Name )) {
LocalIO = LocalIO->Next;
}
return LocalIO;
}
// Low Level Local IO interfaces
virtual int Output( const TLocalIO * LocalIO, const char * Data, int Len );
public:
// Life cycle
CFunctionCore( const char * ObjectName, EDebugLevel pDebugLevel, int pOuputDisplay );
virtual ~CFunctionCore();
// Miscellaneous
inline const char * GetName() { return Name; };
// Manage IOs
virtual TLocalIO * AddLocalIO( const char * IOName );
// Manual Data Input/Output
virtual int Input( const char * IOName, const char * Data, int MaxLen = -1 );
virtual int Output( const char * IOName, const char * Data, int Len = -1 );
// Automated Data Input/Output
virtual bool AddInput( const char * IOName, CFunctionCore * OutFunction, const char * OutputName, bool Bidirectional );
virtual bool AddOutput( const char * IOName, CFunctionCore * InFunction, const char * InputName, bool Bidirectional );
virtual bool Process() = 0;
};
//---------------------------------------------------------------------------
#endif /* REDACORE_FUNCTIONCORE_H_ */