Important Update:
- Split SelectableCore.cpp into two classes: SelectableBare & SelectableCore
This commit is contained in:
107
SelectableCore.h
107
SelectableCore.h
@@ -45,10 +45,11 @@ typedef struct SSelectHandle TSelectHandle;
|
||||
typedef struct SHandle THandle;
|
||||
|
||||
class CSelect;
|
||||
class CSelectableBare;
|
||||
class CSelectableCore;
|
||||
|
||||
// Callback function for handle events
|
||||
typedef void (*FHandleCallback)( CSelectableCore * Function, THandle * Handle, EConnectState State );
|
||||
typedef void (*FHandleCallback)( CSelectableBare * Function, THandle * Handle, EConnectState State );
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -61,7 +62,7 @@ struct SSelectHandle {
|
||||
|
||||
// Event Object
|
||||
THandle * Handle;
|
||||
CSelectableCore * Function;
|
||||
CSelectableBare * Function;
|
||||
|
||||
// List
|
||||
TSelectHandle * Next;
|
||||
@@ -164,7 +165,7 @@ public:
|
||||
|
||||
// Manage FDs
|
||||
void Clear();
|
||||
void Add( int FD, bool Read, bool Write, THandle * Handle, CSelectableCore * Function = NULL);
|
||||
void Add( int FD, bool Read, bool Write, THandle * Handle, CSelectableBare * Function = NULL);
|
||||
void Remove( int FD, bool Read, bool Write );
|
||||
|
||||
// Testing FDs
|
||||
@@ -180,7 +181,7 @@ CFunctionCore * NewSelectableCore( const char * Name );
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class CSelectableCore : public CFunctionCore
|
||||
class CSelectableBare : public CFunctionCore
|
||||
{
|
||||
protected:
|
||||
// FDs
|
||||
@@ -208,35 +209,10 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
// Port Operations
|
||||
THandle * OpenSerialPort( THandle * Handle );
|
||||
bool WriteSerialConfig( THandle * Handle );
|
||||
bool ReadSerialConfig( THandle * Handle );
|
||||
|
||||
THandle * OpenLinePrinterPort( THandle * Handle );
|
||||
|
||||
// File Socket Operations
|
||||
THandle * OpenForkPipe( THandle * Handle );
|
||||
THandle * OpenUNIXserverSocket( THandle * Handle );
|
||||
THandle * OpenUNIXclientSocket( THandle * Handle );
|
||||
THandle * OpenUNIXremoteSocket( THandle * Handle );
|
||||
|
||||
// Socket Operations
|
||||
bool ResolveAddress( THandle * Handle, bool DelayResolve );
|
||||
THandle * OpenUDPserverSocket( THandle * Handle, bool DelayResolve );
|
||||
THandle * OpenUDPremoteSocket( THandle * Handle, char * RemoteAddr, char * RemotePort );
|
||||
THandle * OpenUDPclientSocket( THandle * Handle, bool DelayResolve );
|
||||
THandle * OpenTCPserverSocket( THandle * Handle, bool DelayResolve );
|
||||
THandle * OpenTCPremoteSocket( THandle * Handle );
|
||||
THandle * OpenTCPclientSocket( THandle * Handle, bool DelayResolve );
|
||||
|
||||
// Mutual Operations
|
||||
int ReadFromFD( int FD, char * Data, int MaxLen );
|
||||
int WriteToFD( int FD, const char * Data, int Len, bool Force );
|
||||
|
||||
int ReadFromUDP( THandle * Handle, char * RemoteAddr, char * RemotePort, char * Data, int MaxLen );
|
||||
int WriteToUDP( THandle * Handle, const char * Data, int Len, bool Force );
|
||||
|
||||
// Buffer operations
|
||||
virtual bool ProcessInputBuffer( THandle * Handle, bool Force );
|
||||
|
||||
@@ -252,11 +228,11 @@ protected:
|
||||
|
||||
public:
|
||||
// Life Cycle
|
||||
CSelectableCore( const char * Name, const char * Type = TYPE_SELECTABLE );
|
||||
virtual ~CSelectableCore();
|
||||
CSelectableBare( const char * Name, const char * Type = TYPE_SELECTABLE );
|
||||
virtual ~CSelectableBare();
|
||||
|
||||
// Configuration
|
||||
virtual bool Init( CDataMember * FunctionConfig );
|
||||
virtual bool Init( CDataMember * FunctionConfig ) = 0;
|
||||
|
||||
// Finding Handles
|
||||
inline THandle * GetHandle( const char * HandleName )
|
||||
@@ -285,17 +261,10 @@ public:
|
||||
bool SetOutBuffer( THandle * Handle, int OutBufSize );
|
||||
|
||||
// Specific port parameters
|
||||
bool SetSerialHandle( THandle * Handle, const char * FileName );
|
||||
bool SetSerialHandleConfig( THandle * Handle, int Baudrate, short DataBits, short Parity, short StopBits, short FlowCtrl, int DataWait );
|
||||
bool SetLinePrinterHandle( THandle * Handle, const char * FileName );
|
||||
bool SetForkPipeHandle( THandle * Handle, const char * ExecPath );
|
||||
bool SetUnixHandle( THandle * Handle, EConnectType Type, const char * FileName, short Queue );
|
||||
bool SetSocketHandle( THandle * Handle, EConnectType Type, const char * HostName, const char * PortName, short Queue, long ResolveDelay );
|
||||
|
||||
bool ClearHandle( THandle * Handle );
|
||||
|
||||
// FD Operations
|
||||
virtual int Open( THandle * Handle, bool DelayResolve = false );
|
||||
virtual int Open( THandle * Handle, bool DelayResolve = false ) = 0;
|
||||
virtual bool Close( THandle * Handle, bool QuickReopen );
|
||||
virtual bool Read( THandle * Handle );
|
||||
virtual bool Write( THandle * Handle );
|
||||
@@ -330,4 +299,62 @@ public:
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class CSelectableCore : public CSelectableBare
|
||||
{
|
||||
protected:
|
||||
// Port Operations
|
||||
THandle * OpenSerialPort( THandle * Handle );
|
||||
bool WriteSerialConfig( THandle * Handle );
|
||||
bool ReadSerialConfig( THandle * Handle );
|
||||
|
||||
THandle * OpenLinePrinterPort( THandle * Handle );
|
||||
|
||||
// File Socket Operations
|
||||
THandle * OpenForkPipe( THandle * Handle );
|
||||
THandle * OpenUNIXserverSocket( THandle * Handle );
|
||||
THandle * OpenUNIXclientSocket( THandle * Handle );
|
||||
THandle * OpenUNIXremoteSocket( THandle * Handle );
|
||||
|
||||
// Socket Operations
|
||||
bool ResolveAddress( THandle * Handle, bool DelayResolve );
|
||||
THandle * OpenUDPserverSocket( THandle * Handle, bool DelayResolve );
|
||||
THandle * OpenUDPremoteSocket( THandle * Handle, char * RemoteAddr, char * RemotePort );
|
||||
THandle * OpenUDPclientSocket( THandle * Handle, bool DelayResolve );
|
||||
THandle * OpenTCPserverSocket( THandle * Handle, bool DelayResolve );
|
||||
THandle * OpenTCPremoteSocket( THandle * Handle );
|
||||
THandle * OpenTCPclientSocket( THandle * Handle, bool DelayResolve );
|
||||
|
||||
// Mutual Operations
|
||||
int ReadFromUDP( THandle * Handle, char * RemoteAddr, char * RemotePort, char * Data, int MaxLen );
|
||||
int WriteToUDP( THandle * Handle, const char * Data, int Len, bool Force );
|
||||
|
||||
public:
|
||||
// Life Cycle
|
||||
CSelectableCore( const char * Name, const char * Type = TYPE_SELECTABLE );
|
||||
virtual ~CSelectableCore();
|
||||
|
||||
// Configuration
|
||||
virtual bool Init( CDataMember * FunctionConfig );
|
||||
|
||||
// Specific port parameters
|
||||
bool SetSerialHandle( THandle * Handle, const char * FileName );
|
||||
bool SetSerialHandleConfig( THandle * Handle, int Baudrate, short DataBits, short Parity, short StopBits, short FlowCtrl, int DataWait );
|
||||
bool SetLinePrinterHandle( THandle * Handle, const char * FileName );
|
||||
bool SetForkPipeHandle( THandle * Handle, const char * ExecPath );
|
||||
bool SetUnixHandle( THandle * Handle, EConnectType Type, const char * FileName, short Queue );
|
||||
bool SetSocketHandle( THandle * Handle, EConnectType Type, const char * HostName, const char * PortName, short Queue, long ResolveDelay );
|
||||
|
||||
// FD Operations
|
||||
virtual int Open( THandle * Handle, bool DelayResolve = false );
|
||||
virtual bool Close( THandle * Handle, bool QuickReopen );
|
||||
virtual bool Read( THandle * Handle );
|
||||
virtual bool Write( THandle * Handle );
|
||||
|
||||
// Function Interface
|
||||
int OutputHandle( THandle * Handle, const char * Data, int Len );
|
||||
virtual bool Process();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#endif /* REDACORE_SELECTABLECORE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user