C++ TargetRTS
Loading...
Searching...
No Matches
RTMain.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2021. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __RTMain_h__
11#define __RTMain_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTConfig_h__
18#include <RTConfig.h>
19#endif
20
21#if OTRTSDEBUG != DEBUG_NONE
22#include <stdarg.h>
23
24typedef void (*DEBUG_ERROR_FUNC_PTR)(const char*);
25
26// Enables compile-time verification of printf-style format strings
27#ifndef FORMAT_CHECK
28 #if defined (__GNUC__) && !defined (DISABLE_FORMATCHECKING)
29 #if defined(__MINGW32__) && !defined(__clang__)
30 #define FORMAT_CHECK(f,s) __attribute__((__format__(gnu_printf, f, s)))
31 #else
32 #define FORMAT_CHECK(f,s) __attribute__((__format__(printf, f, s)))
33 #endif
34 #else
35 #define FORMAT_CHECK(f,s)
36 #endif
37#endif//FORMAT_CHECK
38#endif // OTRTSDEBUG != DEBUG_NONE
39
40class RTActor;
41class RTActorRef;
42class RTController;
43class RTSuperActor;
45
46class RTMain
47{
48private:
49 friend class RTSuperActor;
50 friend class RTTracer;
51
52 static int execute( void );
53 static int mainLine( void );
54
55 static void targetStartup( void );
56 static void installHandlers( void );
57 static void installOneHandler( int,
58 void (*)( int ) );
59 static void removeHandlers( void );
60 static void removeOneHandler( int );
61 static void targetShutdown( void );
62
63#if OTRTSDEBUG != DEBUG_NONE
64
68 static void invokeOrDiagInternal(const char* format, va_list args);
69
74 static DEBUG_ERROR_FUNC_PTR debugErrorFunctionPtr;
75#endif // OTRTSDEBUG != DEBUG_NONE
76
77 static const RTSystemDescriptor * _system;
78 static int _exitCode;
79 static int _argc;
80 static const char * const * _argv;
81
82 static RTController * _controller;
83 static RTActor * _superActor;
84 static RTActorRef * _topReference;
85
86#if USE_THREADS && OTRTSDEBUG != DEBUG_NONE
87 static int debugPriority;
88 static int debugStackSize;
89#endif
90
91public:
92 // entryPoint must be provided by the generated code
93 static int entryPoint( int, const char * const * );
94
95 static int shutdown( RTController * );
96 static const char * debugName( void );
97
98#if OTRTSDEBUG != DEBUG_NONE
103 static void registerDebugErrorFunction(DEBUG_ERROR_FUNC_PTR pFunc);
104
108 static DEBUG_ERROR_FUNC_PTR getDebugErrorFunction();
109
115 static FORMAT_CHECK(1, 2) void invokeOrDiag(const char* format, ...);
116#endif // OTRTSDEBUG != DEBUG_NONE
117
118 static RTS_INLINE RTController * controller( void );
119 static RTS_INLINE RTActorRef * topReference( void );
120 static RTS_INLINE RTActor * topActor( void );
121
122 static RTS_INLINE
123 const RTSystemDescriptor * systemInfo( void );
124 static RTS_INLINE int argCount( void );
125 static RTS_INLINE const char * const * argStrings( void );
126 static RTS_INLINE void setExitCode(int code);
127 static RTS_INLINE int getExitCode(void);
128
129#if USE_THREADS
130 static void lock( void );
131 static void unlock( void );
132#else
133 static RTS_INLINE void lock( void );
134 static RTS_INLINE void unlock( void );
135#endif
136};
137
138#if RTS_INLINES
139#include <RTMain.inl>
140#endif
141
142#endif // __RTMain_h__
An instance of this class represents a capsule instance.
Definition: RTActor.h:44
Represents a capsule part.
Definition: RTActorRef.h:39
A controller manages a group of capsule instances that all run in the same physical thread (i....
Definition: RTController.h:56
Definition: RTMain.h:47
static FORMAT_CHECK(1, 2) void invokeOrDiag(const char *format
Call the user defined warning function OR RTDiag::out if no user defined.
static DEBUG_ERROR_FUNC_PTR getDebugErrorFunction()
Return the currently registered debug error function, or nullptr if none.
static void registerDebugErrorFunction(DEBUG_ERROR_FUNC_PTR pFunc)
Register a user-defined debug error function.
Definition: RTSuperActor.h:37
Definition: RTTracer.h:20
Definition: RTSystemDescriptor.h:26