Files
redAcore/FunctionCore.h
Charl Wentzel 5ea05d119e Major update:
- Logging
  - Created LogCore Class
  - Updated LogCore to use file descriptors instead of stdout
  - Add Log object reference to constructors for:
    FunctionCore, SelectCore
  - Use extern Log() object in SignalCore
- SelectableCore
  - Added new connection type: ForkedPipe
    Create pipe, fork process, connect pipe out to child stdin, exec
2016-08-22 12:14:53 +02:00

99 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
CLogCore * Log;
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;
}
// Manual Data Input/Output
virtual int Output( const TLocalIO * LocalIO, const char * Data, int Len );
public:
// Life cycle
CFunctionCore( const char * ObjectName, CLogCore * pLog, 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_ */