- Merged SelectCore and PortCore into new SelectableCore Single well integrated Class - Rename SelectCore.h to SelectableCore.h - Create new TFileHandle structure for Ports/Sockets - Moved buffer and Input Timeout from FunctionCore to TFileHandle - Moved Read, Write and ProcessBuffer from FunctionCore to TFileHandle Bug Fixes: - malloc correct size for names - Calculate MaxFD correctly when closing FDs
75 lines
1.7 KiB
C++
75 lines
1.7 KiB
C++
/*
|
|
* FunctionCore.cpp
|
|
*
|
|
* Created on: 18 May 2016
|
|
* Author: wentzelc
|
|
*/
|
|
|
|
// redA Libraries
|
|
#include "FunctionCore.h"
|
|
#include "TimingCore.h"
|
|
#include "LogCore.h"
|
|
|
|
// Standard C/C++ Libraries
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Life cycle
|
|
CFunctionCore::CFunctionCore( const char * FunctionName )
|
|
{
|
|
// Set name
|
|
if (FunctionName) {
|
|
Name = (char*)malloc( strlen(FunctionName)+1 );
|
|
strcpy( Name, FunctionName );
|
|
}
|
|
else {
|
|
Name = NULL;
|
|
}
|
|
|
|
// IO Functions
|
|
OutFunction = NULL;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
CFunctionCore::~CFunctionCore()
|
|
{
|
|
// Destroy pointers
|
|
if (Name) {
|
|
free( Name );
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Manual Data Input/Output
|
|
int CFunctionCore::Input( int InputID, const char * Buffer, int MaxLen )
|
|
{
|
|
return 0;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
int CFunctionCore::Output( int OutputID, const char * Buffer, int Len )
|
|
{
|
|
return 0;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Automated Data Input/Output
|
|
bool CFunctionCore::AddInput( int InputID, CFunctionCore * OutFunction, int OutputID )
|
|
{
|
|
return false;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
bool CFunctionCore::AddOutput( int OutputID, CFunctionCore * InFunction, int InputID )
|
|
{
|
|
OutFunction = InFunction;
|
|
|
|
return true;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
|
|
|