ADTF  3.18.2
runtime.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <a_utils.h>
12 #include <adtfucom3/object.h>
17 #include <functional>
18 
19 namespace adtf
20 {
21 namespace ucom
22 {
23 namespace ant
24 {
25 namespace detail
26 {
31 class tRuntimeResult : public tResult
32 {
33  protected:
34 
35  tRuntimeResult(const tRuntimeResult&) = delete;
36  tRuntimeResult& operator=(const tRuntimeResult&) = delete;
37  tRuntimeResult& operator=(tRuntimeResult&&) = delete;
38 
39  public:
40  tRuntimeResult() = delete;
41  tRuntimeResult(const tResult& oResultToDeepCopy) : tResult(oResultToDeepCopy.GetErrorCode(),
42  oResultToDeepCopy.GetDescription(),
43  oResultToDeepCopy.GetLine(),
44  oResultToDeepCopy.GetFile(),
45  oResultToDeepCopy.GetFunction())
46  {
47  }
48  tRuntimeResult(tResult&& oResultToDeepCopy) : tResult(oResultToDeepCopy.GetErrorCode(),
49  oResultToDeepCopy.GetDescription(),
50  oResultToDeepCopy.GetLine(),
51  oResultToDeepCopy.GetFile(),
52  oResultToDeepCopy.GetFunction())
53  {
54  }
55 
56  tRuntimeResult(tRuntimeResult&& oResultToDeepCopy) : tRuntimeResult(static_cast<tResult&&>(oResultToDeepCopy))
57  {
58  }
59 
60  tRuntimeResult& operator=(const tResult& oResultToDeepCopy)
61  {
62  //create a copy
63  tRuntimeResult oCopyResult(oResultToDeepCopy);
64  //move the copy
65  tResult::operator=(static_cast<tResult>(oCopyResult));
66  return *this;
67  }
68 };
72 class DOEXPORT cRuntime : public catwo::object<IRuntime>
73 {
76 
77  public:
78  cRuntime(int8_t nLastRunlevel);
79 
86  cRuntime(int8_t nLastRunlevel, const adtf::util::cCommandLine& oCommandline);
87 
88  protected:
92  virtual ~cRuntime();
93 
99  virtual const char* GetRunLevelString(int8_t i8Runlevel) const = 0;
100 
101  virtual tResult ChangeRunLevel(int8_t i8RunLevelToChangeTo);
102 
103  tResult CallRuntimeHooks(int nHookId,
104  uint32_t ui32Param1=0,
105  uint32_t ui32Param2=0,
106  void* pvData=NULL,
107  int szData=0,
108  const iobject_ptr<IObject>& pObject=object_ptr<IObject>());
109 
110  tResult NotifyAllObjects(int nEventId,
111  uint32_t ui32Param1=0,
112  uint32_t ui32Param2=0,
113  void* pvData=NULL,
114  int szData=0,
115  bool bBackwards=false);
116 
117  void SetEventFilter(std::function<tResult(int, uint32_t, uint32_t, void*, int, const iobject_ptr<IObject>&)> fnHookFilter,
118  std::function<tResult(int, uint32_t, uint32_t, void*, int, bool)> fnEventFilter);
119 
120  bool StartedCompletedImplementation() const;
121 
122  public:
123  tResult Exec(int8_t i8FirstRunlevelToChange, std::function<void()> fnStartup);
124 
125  public: // implements IRuntime
126 
127  // runlevel control
128  tResult SetRunLevel(int8_t i8RunlevelToChangeTo, bool bWait=true) override;
129 
134  int8_t GetRunLevel() const override;
135 
136  // object registry
137  tResult RegisterObject(const iobject_ptr<IObject>& pObject,
138  const char* strNameOID,
139  int8_t nRunLevel,
140  uint32_t ui32Flags = 0) override;
141 
142  tResult UnregisterObject(const iobject_ptr<IObject>& pObject,
143  const tChar* strNameOID = "") override;
150  tResult GetObjects(iobject_enum<IObject>& lstOfObjects) const override;
151 
152  // plugin registry
153  tResult RegisterPlugin(const char* strUrl,
154  int8_t nRunLevel,
155  iobject_ptr<IPluginInfo>& pPluginInfo,
156  uint32_t ui32Flags=0) override;
157 
158  tResult UnregisterPlugin(const iobject_ptr<IPluginInfo>& pPluginInfo, uint32_t ui32Flags = 0) override;
159 
160  tResult UnregisterAllPlugins(int8_t nRunLevel, uint32_t ui32Flags = 0) override;
161 
162  tResult GetPlugins(iobject_enum<const IPluginInfo>& lstPluginInfos) const override;
163 
164  // class registry
165  tResult RegisterClassFactory(const iobject_ptr<const IClassFactory>& pClassFactory,
166  uint32_t ui32Flags=0) override;
167  tResult UnregisterClassFactory(const iobject_ptr<const IClassFactory>& pClassFactory) override;
168 
169  tResult GetClasses(iobject_enum<const IClassInfo>& lstOfClasses) const override;
170  tResult GetClassFactories(iobject_enum<const IClassFactory>& lstOfClasses) const override;
171 
174 
177 
178  // Get an object from the object registry
179  tResult GetObject(iobject_ptr<IObject>& pObject, const char* strNameOID) const override;
180  tResult GetObject(iobject_ptr<IObject>& pObject) const override;
181 
182  // Create an instance of a concrete type
183  tResult CreateInstance(const char* strCID,
184  iobject_ptr<IObject>& oObject,
185  const tChar* strNameOfObject = "") const override;
186 
187 
188 };//class cRuntime
189 
200 template<int8_t LAST_RUN_LEVEL>
201 class runtime : public cRuntime
202 {
203 public:
206  runtime() : cRuntime(LAST_RUN_LEVEL)
207  {
208  }
215  runtime(const adtf::util::cCommandLine& oCommandline) : cRuntime(LAST_RUN_LEVEL, oCommandline)
216  {
217  }
218 
224  const char* GetRunLevelString(int8_t /* i8Runlevel */) const override
225  {
226  return "";
227  }
228 };
229 
230 
231 
232 } // namespace detail
233 
234 using detail::runtime;
235 
236 } // namespace ant
237 
238 namespace spider
239 {
240 namespace detail
241 {
242 template<int8_t LAST_RUN_LEVEL>
243 class runtime : public catwo::object<ant::runtime<LAST_RUN_LEVEL>, spider::IRuntimeStartup>
244 {
245 public:
247  using base_type::base_type;
248 
249  bool StartupCompleted() const override
250  {
251  return this->StartedCompletedImplementation();
252  }
253 };
254 
255 }
256 
257 using detail::runtime;
258 
259 }
260 
261 using spider::runtime;
262 
263 
264 } // namespace ucom
265 } // namespace adtf
Copyright © Audi Electronics Venture GmbH.
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
const tChar * GetDescription() const
Get user provided error description.
tInt32 GetLine() const
Get line in source file where the error was reported.
tErrorCode GetErrorCode() const
Get error code.
const tChar * GetFunction() const
Get name of the function the error was reported in.
const tChar * GetFile() const
Get name of the file the error was reported in.
The IRuntimeHook interface provides a hook callback interface.
Definition: runtime_intf.h:76
The class cRuntime builds the standard implementation of the uCOM runtime environment.
Definition: runtime.h:73
int8_t GetRunLevel() const override
Get current run level.
virtual const char * GetRunLevelString(int8_t i8Runlevel) const =0
Logging Hook to retrieve logging message for the desired runtime changes.
tResult RegisterHook(IRuntimeHook &pHook) override
Register a Hook.
tResult UnregisterHook(IRuntimeHook &pHook) override
Unregister a Hook.
cRuntime(int8_t nLastRunlevel, const adtf::util::cCommandLine &oCommandline)
CTOR.
tResult GetObjects(iobject_enum< IObject > &lstOfObjects) const override
Implements the IRuntime::GetObjects.
Definition of a common level based runtime.
Definition: runtime.h:202
runtime(const adtf::util::cCommandLine &oCommandline)
CTOR.
Definition: runtime.h:215
const char * GetRunLevelString(int8_t) const override
Logging Hook to retrieve logging message for the desired runtime changes.
Definition: runtime.h:224
Special tResult implementation due to the allocation and reference counting of the tResult.
Definition: runtime.h:32
Interface definition for a container of objects.
Definition: object_list.h:22
Base object pointer to realize binary compatible reference counting in interface methods.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Definition: object.h:379
cADTFRuntime cRuntime
Type definition for the Default Runtime of ADTF.
Definition: adtf_runtime.h:151
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.