Files
redAcore/FunctionCore.h
Charl Wentzel 1aa0d98b35 Important Update:
- Add bidirectional flag for AddInput/AddOutput methods on FunctionCore
2016-05-31 07:24:51 +02:00

90 lines
2.2 KiB
C++

/*
* FunctionCore.h
*
* Created on: 18 May 2016
* Author: wentzelc
*/
#ifndef REDACORE_FUNCTIONCORE_H_
#define REDACORE_FUNCTIONCORE_H_
// redA Libraries
#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;
// Manage IO
inline TLocalIO * GetLocalIO( const char * Name ) {
TLocalIO * LocalIO = FirstIO;
while (LocalIO && strcmp( Name, LocalIO->Name )) {
LocalIO = LocalIO->Next;
}
return LocalIO;
}
public:
// Life cycle
CFunctionCore( const char * ObjectName );
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_ */