Files
redAcore/ApplicationCore.h
Charl Wentzel 851a911c6d Minor updates:
- Rename function ApplicationCore::GetProcessName -> GetFileName
- Correct misspelled variable "Persistent" in CSelectableCore::Init
- Clear compiler warning: Persistent not initialised
2023-07-07 11:01:56 +02:00

113 lines
2.9 KiB
C++

/*
* Application.h
*
* Created on: 13 Jul 2017
* Author: wentzelc
*/
#ifndef REDACORE_APPLICATIONCORE_H_
#define REDACORE_APPLICATIONCORE_H_
// Standard C/C++ Libraries
/* none */
// redA Libraries
#include "SignalCore.h"
#include "TimingCore.h"
#include "LogCore.h"
#include "DataTreeCore.h"
#include "JSONparseCore.h"
#include "FunctionCore.h"
#include "SelectableCore.h"
//---------------------------------------------------------------------------
// Preview
typedef struct SFunctionType TFunctionType;
typedef struct SFunctionItem TFunctionItem;
typedef CFunctionCore * (*FFuncConstructor)( const char * Name );
class Application;
//---------------------------------------------------------------------------
struct SFunctionType {
char * Name;
FFuncConstructor Constructor;
TFunctionType * Next;
};
//---------------------------------------------------------------------------
struct SFunctionItem {
CFunctionCore * Function;
SFunctionItem * Next;
};
//---------------------------------------------------------------------------
class CApplication
{
protected:
// Variables used for configuration
char * ConfigFile;
char * DefinitionFile;
char * AddressFile;
// Configuration
CDataMember * DataTree;
CJSONparse * JSONparser = NULL;
// List
TFunctionType * FirstFunctionType;
TFunctionItem * FirstFunction;
// Output
int LogBufSize;
EDebugLevel LogLevel;
int LogOutput;
public:
// Public function vars
CLogCore * Log;
CSelect * Selector;
// Configuration
CDataMember * Config;
CDataMember * Definition;
CDataMember * AddressList;
// Life Cycle
CApplication( EDebugLevel pDebugLevel );
virtual ~CApplication();
// Manage Config File
bool ReadParam( int argc, char *argv[] );
void GetFileName( char ** ProcessName, char * pFilePath );
bool LoadConfig();
bool SaveConfig();
// Manually set configuration
bool SetLogParam( int pLogBufferSize, EDebugLevel pDebugLevel, int pOutputDisplay );
inline void WriteToScreen( const char * BasePath, const int Indent = 2 ) { JSONparser->WriteToScreen( BasePath, Indent ); };
// Init application
bool InitApplication();
bool InitFunctions();
bool InitFunction( CFunctionCore * Function );
bool InitFunctionLinks();
// Manage Functions
bool AddFunctionType( const char * Type, FFuncConstructor Constructor );
CFunctionCore * AddFunction( const char * Type, const char * Name );
CFunctionCore * GetFunction( const char * Name );
CDataMember * GetAddress( const char * SearchAddress );
// Run Application
bool Run( bool TerminateOnError );
};
//---------------------------------------------------------------------------
#endif /* REDACORE_APPLICATIONCORE_H_ */