Files
redAcore/FunctionCore.h
Charl Wentzel ee29625b9a Important update:
- DataTree->GetStr return Member->Value or NULL if not found
- Rename DeviceCore EDataType to EMBDataType, avoid conflict with JSONpaser
- Add DataTree to FunctionCore with LoadConfig() method
- Change ProcessName to char * (from char[])
- JSONparse:
  - Rename RootPath to BasePath on all methods to reduce confusion
  - Allow FilePath to be NULL, add '/' if not present
  - Fixed Parsing sequence in ParseObject & ParseArray
2017-04-10 21:33:14 +02:00

106 lines
2.7 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"
#include "DataTreeCore.h"
// Standard C/C++ Libraries
#include <string.h>
#include <sys/time.h>
//---------------------------------------------------------------------------
// Preview
typedef struct SChannel TChannel;
typedef struct SChannelLink TChannelLink;
class CFunctionCore;
//---------------------------------------------------------------------------
struct SChannel
{
char * Name;
TChannelLink * FirstInput;
TChannelLink * FirstOutput;
TChannel * Next;
};
//---------------------------------------------------------------------------
struct SChannelLink
{
CFunctionCore * Function;
char * Name;
SChannelLink * Next;
};
//---------------------------------------------------------------------------
class CFunctionCore
{
protected:
// Function Definition
char * Name;
// Configuration
CDataTree * DataTree;
TDataMember * BaseMember;
// Channels
TChannel * FirstChannel;
// Output
CLogCore * Log;
EDebugLevel DebugLevel;
int OutputDisplay;
// Manage Channel
inline TChannel * GetChannel( const char * Name ) {
TChannel * Channel = FirstChannel;
while (Channel && strcmp( Name, Channel->Name )) {
Channel = Channel->Next;
}
return Channel;
}
// Manual Data Input/Output
virtual int Output( const TChannel * Channel, const char * Data, int Len );
public:
// Life cycle
CFunctionCore( const char * FunctionName, CLogCore * pLog, EDebugLevel pDebugLevel, int pOuputDisplay );
virtual ~CFunctionCore();
virtual bool LoadConfig( CDataTree * DataTree, const char * BasePath );
// Miscellaneous
inline const char * GetName() { return Name; };
// Manage Channels
virtual TChannel * AddChannel( const char * ChannelName );
// Manual Data Input/Output
virtual int Input( const char * ChannelName, const char * Data, int MaxLen = -1 );
virtual int Output( const char * ChannelName, const char * Data, int Len = -1 );
// Automated Data Input/Output
virtual bool LinkInputChannel( const char * ChannelName, CFunctionCore * OutFunction, const char * OutChannelName, bool Bidirectional );
virtual bool LinkOutputChannel( const char * ChannelName, CFunctionCore * InFunction, const char * InChannelName, bool Bidirectional );
virtual bool Process() = 0;
};
//---------------------------------------------------------------------------
#endif /* REDACORE_FUNCTIONCORE_H_ */