ADTF  3.14.2
kernel_intf.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include <adtfucom3/adtf_ucom3.h>
10 #include <adtfbase/string_intf.h>
11 
13 #define CID_ADTF_KERNEL "kernel.service.adtf.cid"
14 
15 namespace adtf
16 {
17 namespace services
18 {
19 namespace ant
20 {
21 
25 class IKernel: public ucom::IObject
26 {
27  public:
29  ADTF_IID(IKernel, "kernel.ant.services.adtf.iid");
30 
31  protected:
33  ~IKernel() = default;
34 
35  public:
39  enum class tSchedulingClass: uint32_t
40  {
41  Default = 0,
42  Normal = 1,
43  RealTime = 2,
44  };
45 
49  enum tThreadFlags // untyped for combinations
50  {
51  THF_None = 0,
52  THF_Detached = 1
54  };
55 
59  enum class tTimerClock: uint32_t
60  {
61  ADTF = 0,
62  Monotonic = 1,
63  RealTime = 2,
64  };
65 
69  enum tTimerFlags // untyped for combinations
70  {
71  TIF_None = 0
72  };
73 
78  {
88  float fPriority = -1.0,
89  const uint8_t* pProcessorAffinity = nullptr,
90  size_t nProcessorAffinityByteCount = 0):
93  {
94  if (pProcessorAffinity == nullptr)
95  {
96  adtf_util::cMemoryBlock::MemSet(aProcessorAffinity, 0xFF, sizeof(aProcessorAffinity));
97  }
98  else
99  {
100  adtf_util::cMemoryBlock::MemSet(aProcessorAffinity, 0x00, sizeof(aProcessorAffinity));
101  adtf_util::cMemoryBlock::MemCopy(aProcessorAffinity, pProcessorAffinity,
102  std::min<size_t>(nProcessorAffinityByteCount, sizeof(aProcessorAffinity)));
103  }
104  }
105 
107  float fPriority;
108  uint8_t aProcessorAffinity[128];
109  };
110 
115  {
116  public:
117  ADTF_IID(IScheduling, "scheduling.ant.kernel.services.adtf.iid");
118 
119  protected:
121  ~IScheduling() = default;
122 
123  public:
129  virtual tResult GetScheduling(tSchedulingInfo& sScheduling) const = 0;
130 
136  virtual tResult SetScheduling(const tSchedulingInfo& sScheduling) = 0;
137  };
138 
142  class IThread: public ucom::IObject
143  {
144  public:
145  ADTF_IID(IThread, "thread.ant.kernel.services.adtf.iid");
146 
147  protected:
149  ~IThread() = default;
150 
151  public:
156  virtual tResult Detach() = 0;
157 
162  virtual bool IsCurrent() const = 0;
163 
169  virtual tResult Join(tTimeStamp nTimeout = -1) = 0;
170  };
171 
175  class ITimer: public ucom::IObject
176  {
177  public:
178  ADTF_IID(ITimer, "timer.ant.kernel.services.adtf.iid");
179 
180  protected:
182  ~ITimer() = default;
183  public:
188  virtual tResult Stop() = 0;
189  };
190 
194  enum tSignalFlags // untyped for combinations
195  {
196  SIG_None = 0,
197  SIG_Async = 1
198  };
199 
204  class ISignal: public ucom::IObject
205  {
206  public:
207  ADTF_IID(ISignal, "signal.ant.kernel.services.adtf.iid");
208 
209  protected:
211  ~ISignal() = default;
212 
213  public:
217  virtual int32_t GetClass() const = 0;
218 
222  virtual int32_t GetCode() const = 0;
223  };
224 
229  {
230  protected:
232  ~ISignalHandler() = default;
233 
234  public:
241  virtual tResult HandleKernelSignal(const adtf::ucom::iobject_ptr<ISignal>& pSignal) = 0;
242  };
243 
249  {
250  public:
251  ADTF_IID(IKernelRunnable, "runnable.ant.kernel.services.adtf.iid");
252  protected:
254  ~IKernelRunnable() = default;
255  };
256 
257 
258  public:
277  virtual tResult ThreadCreate(adtf::ucom::iobject_ptr<IThread>& pThread, const char* strThreadName,
278  const adtf::ucom::iobject_ptr<IKernelRunnable>& pKernelRunnable,
279  const void* pUserData = nullptr,
280  size_t nUserDataSize = 0,
281  const tSchedulingInfo& sScheduling = tSchedulingInfo(),
282  uint32_t ui32Flags = tThreadFlags::THF_None) = 0;
283 
305  virtual tResult TimerCreate(adtf::ucom::iobject_ptr<ITimer>& pTimer, const char* strTimerName,
306  tTimeStamp nPeriod,
307  tTimeStamp nInitialDelay,
308  const adtf::ucom::iobject_ptr<IKernelRunnable>& pKernelRunnable,
309  const void* pUserData = nullptr,
310  size_t nUserDataSize = 0,
312  const tSchedulingInfo& sScheduling = tSchedulingInfo(),
313  uint32_t ui32Flags = tTimerFlags::TIF_None) = 0;
314 
321  virtual tResult SignalSend(const adtf::ucom::iobject_ptr<ISignal>& pSignal, uint32_t ui32Flags = tSignalFlags::SIG_None) = 0;
322 
329  virtual tResult SignalRegister(ISignalHandler& oHandler, uint32_t ui32Flags = tSignalFlags::SIG_None) = 0;
330 
336  virtual tResult SignalUnregister(ISignalHandler& oHandler) = 0;
337 
343  virtual tResult GetObjects(adtf::ucom::iobject_enum<IObject>& oObjects) = 0;
344 };
345 
346 }
347 
348 namespace devil
349 {
350 
351 class IKernel: public ant::IKernel
352 {
353  public:
355  ADTF_IID(IKernel, "kernel.devil.services.adtf.iid");
356 
357  public:
358 
363  {
364  public:
365  ADTF_IID(INamedKernelObject, "named_kernel_object.devil.kernel.services.adtf.iid");
366 
367  public:
368  virtual tResult GetName(base::ant::IString&& strName) const = 0;
369  };
370 };
371 
372 }
373 
374 using devil::IKernel;
375 
376 }
377 
378 }
Copyright © Audi Electronics Venture GmbH.
The Runnable interface defines common methods for a running component.
Definition: runnable_intf.h:26
The IString interface provides methods for getting and setting strings through abstract interfaces.
Definition: string_intf.h:24
IObject based version of IRunnable.
Definition: kernel_intf.h:249
~IKernelRunnable()=default
Protected destructor.
Interface for retrieving and setting of scheduling options.
Definition: kernel_intf.h:115
~IScheduling()=default
Protected destructor --> Use implemented Destroy() instead of delete!
virtual tResult GetScheduling(tSchedulingInfo &sScheduling) const =0
Get the current scheduling settings.
virtual tResult SetScheduling(const tSchedulingInfo &sScheduling)=0
Update the scheduling settings.
Interface for signal handlers.
Definition: kernel_intf.h:229
~ISignalHandler()=default
Protected destructor.
virtual tResult HandleKernelSignal(const adtf::ucom::iobject_ptr< ISignal > &pSignal)=0
Called when a signal is transmitted.
virtual int32_t GetCode() const =0
~ISignal()=default
Protected destructor --> Use implemented Destroy() instead of delete!
virtual int32_t GetClass() const =0
~IThread()=default
Protected destructor --> Use implemented Destroy() instead of delete!
virtual tResult Detach()=0
Detaches the thread, which can then no longer be modified via this interface.
virtual bool IsCurrent() const =0
Returns whether this thread is the current thread of execution.
virtual tResult Join(tTimeStamp nTimeout=-1)=0
Blocks the current thread until this thread has exited.
~ITimer()=default
Protected destructor --> Use implemented Destroy() instead of delete!
virtual tResult Stop()=0
Stops the timer.
Kernel interface for thread, timer and signal handling.
Definition: kernel_intf.h:26
virtual tResult GetObjects(adtf::ucom::iobject_enum< IObject > &oObjects)=0
Returns a list of all kernel primitives.
tSchedulingClass
Enum for different scheduling schemes.
Definition: kernel_intf.h:40
@ Default
The kernel may choose what it (or the user) likes.
@ Normal
Basic non-realtime scheduling.
tTimerFlags
Flags for time creation.
Definition: kernel_intf.h:70
@ TIF_None
No special behaviour.
Definition: kernel_intf.h:71
tSignalFlags
Enum for signal options.
Definition: kernel_intf.h:195
@ SIG_None
No special behaviour.
Definition: kernel_intf.h:196
@ SIG_Async
Transmit signal asynchronously.
Definition: kernel_intf.h:197
ADTF_IID(IKernel, "kernel.ant.services.adtf.iid")
Interface ID for the kernel interface.
virtual tResult SignalRegister(ISignalHandler &oHandler, uint32_t ui32Flags=tSignalFlags::SIG_None)=0
Registers a new signal handler.
tThreadFlags
Flags for thread creation.
Definition: kernel_intf.h:50
@ THF_Detached
Create a detached thread, the pThread handle is not set, so you cannot modify this thread after creat...
Definition: kernel_intf.h:52
@ THF_None
No special behaviour.
Definition: kernel_intf.h:51
virtual tResult SignalUnregister(ISignalHandler &oHandler)=0
Unregisters a signal handler.
tTimerClock
Enum for different time sources for timers.
Definition: kernel_intf.h:60
@ Monotonic
Realtime monotonic clock.
~IKernel()=default
Protected destructor --> Use implemented Destroy() instead of delete!
virtual tResult TimerCreate(adtf::ucom::iobject_ptr< ITimer > &pTimer, const char *strTimerName, tTimeStamp nPeriod, tTimeStamp nInitialDelay, const adtf::ucom::iobject_ptr< IKernelRunnable > &pKernelRunnable, const void *pUserData=nullptr, size_t nUserDataSize=0, tTimerClock eClock=tTimerClock::ADTF, const tSchedulingInfo &sScheduling=tSchedulingInfo(), uint32_t ui32Flags=tTimerFlags::TIF_None)=0
Creates a new timer, that periodically calls the Run method of the given runnable.
virtual tResult ThreadCreate(adtf::ucom::iobject_ptr< IThread > &pThread, const char *strThreadName, const adtf::ucom::iobject_ptr< IKernelRunnable > &pKernelRunnable, const void *pUserData=nullptr, size_t nUserDataSize=0, const tSchedulingInfo &sScheduling=tSchedulingInfo(), uint32_t ui32Flags=tThreadFlags::THF_None)=0
Creates a new thread of execution that executes the Run method of the given runnable.
virtual tResult SignalSend(const adtf::ucom::iobject_ptr< ISignal > &pSignal, uint32_t ui32Flags=tSignalFlags::SIG_None)=0
Transmits a signal to all registered signal handlers.
Interface for kernel objects that have names (threads/timer)
Definition: kernel_intf.h:363
ADTF_IID(IKernel, "kernel.devil.services.adtf.iid")
Interface ID for the kernel interface.
Base class for every interface type within the uCOM.
Definition: object_intf.h:31
Interface definition for a container of objects.
Definition: object_list.h:22
Base object pointer to realize binary compatible reference counting in interface methods.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Struct for defining scheduling settings of a thread or timer.
Definition: kernel_intf.h:78
tSchedulingClass eSchedulingClass
The scheduling class.
Definition: kernel_intf.h:106
uint8_t aProcessorAffinity[128]
The processor affinity (bitmask).
Definition: kernel_intf.h:108
float fPriority
The priority [0.0, 1.0].
Definition: kernel_intf.h:107
tSchedulingInfo(tSchedulingClass eSchedulingClass=tSchedulingClass::Default, float fPriority=-1.0, const uint8_t *pProcessorAffinity=nullptr, size_t nProcessorAffinityByteCount=0)
Constructor.
Definition: kernel_intf.h:87

Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Tue May 10 2022 by doxygen 1.9.1)