|
Embedded Artistry Framework
Embedded Systems C++ Framework
|
Interfaces and components for building a virtual platform. More...
|
Classes | |
| class | embvm::EventBase |
| Base class for events. More... | |
| class | embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::EventHandle |
| Handle for an event subscription. More... | |
| class | embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc > |
| Global Event Manager class. More... | |
| class | embvm::EventQueue< TEvent, TQueueSize > |
| Keep a queue of events. More... | |
| class | embvm::VirtualPlatformBase< TPlatform, TDriverRegistry > |
| Base class for Platform definitions. More... | |
| class | embvm::PlatformDispatcher< TDispatchQueue > |
| Add a dispatch queue to the VirtualPlatform through inheritance. More... | |
| class | embvm::PlatformEventManagement< TEventCenter > |
| Add an event manager to the VirtualPlatform through inheritance. More... | |
Typedefs | |
| using | embvm::Signal_t = uint32_t |
| Signal type which is used for function inputs. More... | |
| template<const size_t TSize, const size_t TThreadCnt = 1, typename TFunc = stdext::inplace_function<void(), EVENT_CENTER_REQD_STATIC_FUNCTION_SIZE>> | |
| using | embvm::StaticEventQueue = embutil::StaticDispatchQueue< TSize, TThreadCnt, TFunc > |
| This alias represents a static dispatch queue which can be used with the event manager Primarily this alias is used to prevent users from needing to declare a long type declaration just because of the need to increase inplace_function<>'s size. More... | |
| using | embvm::DynamicEventCenter = EventCenter< 0, 0 > |
| Declare an EventCenter that uses dynamic memory allocation. More... | |
| template<const size_t TMaxEvents = 16, const size_t TMaxSubscribersPerEvent = 4> | |
| using | embvm::StaticEventCenter = EventCenter< TMaxEvents, TMaxSubscribersPerEvent > |
| Declare a DriverRegistry that uses static memory allocation. More... | |
Enumerations | |
| enum | embvm::Signal { embvm::Event_Invalid = 0, embvm::Event_ProcessorInitd, embvm::Event_HwPlatformInitd, embvm::Event_PlatformInitd, embvm::Event_EXTENSION_START } |
| Default framework event signal definitions. More... | |
Variables | |
| static constexpr size_t | embvm::EVENT_CENTER_REQD_STATIC_FUNCTION_SIZE = (sizeof(void*) * 8) |
| Maximum size of the Event center callback functor object. More... | |
Interfaces and components for building a virtual platform.
| class embvm::EventBase |
Base class for events.
The EventBase class represents a signal with no associated data Templated to allow use of any signal definition type within the framework
You can define custom events with data by inheriting from this class:
You can then transform event base objects to your class (as long as the types match!)
Public Member Functions | |
| EventBase (Signal_t s=Event_Invalid) noexcept | |
| Default constructor. More... | |
| type_safe::boolean | safeToFree () const noexcept |
| Check whether this event is safe to free. More... | |
Public Attributes | |
| Signal_t | sig = Event_Invalid |
| Signal ID for this event. More... | |
Private Member Functions | |
| EventBase (Signal_t s, bool d) noexcept | |
Private Attributes | |
| type_safe::boolean | dynamic_ = false |
| nullptr indicates this is statically allocated and should not be freed More... | |
|
inlineexplicitnoexcept |
Default constructor.
Creates a static event base (e.g. on the stack)
| s | The signal which corresponds to this event |
|
inlinenoexcept |
Check whether this event is safe to free.
References dynamic_.
|
private |
nullptr indicates this is statically allocated and should not be freed
Referenced by safeToFree().
| Signal_t embvm::EventBase::sig = Event_Invalid |
Signal ID for this event.
| class embvm::EventCenter::EventHandle |
Handle for an event subscription.
EventHandle represents a handle to an event registration. EventHandles are created during the subscribe() process. The lifetime of the EventHandle controls the lifetime of the subscription: if the handle leaves scope, the subscription will be automatically revoked.
Template parameters simply match those in the original EventCenter declaration, since EventHandle is a class member.
Public Member Functions | |
| EventHandle & | operator= (EventHandle &&rhs) noexcept |
| Move assignment operator. More... | |
| EventHandle (const EventHandle &)=delete | |
| Delete the copy constructor. More... | |
| const EventHandle & | operator= (const EventHandle &)=delete |
| Delete the copy assignment operator. More... | |
| ~EventHandle () noexcept | |
| EventHandle destructor. More... | |
| operator bool () const noexcept | |
| Boolean operator returns true if the handle is valid, false otherwise. More... | |
| const Signal_t & | sig () const noexcept |
| Check the signal this subscription corresponds to. More... | |
| void | reset () noexcept |
| Unregister the callback and invalidate the handle. More... | |
Private Types | |
| using | TEventHandle = typename decltype(events_)::mapped_type::iterator |
| Convenience declaration: our handle is an iterator to the mapped type. More... | |
Private Member Functions | |
| EventHandle (EventCenter *owner, Signal_t sig, TEventHandle iter) noexcept | |
| EventHandle constructor. More... | |
| EventHandle (EventHandle &&rhs) noexcept | |
| Move constructor. More... | |
| TEventHandle | get () const noexcept |
| Get the underlying handle. More... | |
Private Attributes | |
| Signal_t | sig_ |
| TEventHandle | handle_ |
| bool | is_valid_ |
| EventCenter * | mgr_ |
Friends | |
| class | EventCenter |
| Event Center is able to invoke private EventHandle functions. More... | |
|
private |
Convenience declaration: our handle is an iterator to the mapped type.
|
delete |
Delete the copy constructor.
|
inlinenoexcept |
EventHandle destructor.
On destruction, the handle will automatically unsubscribe itself from the event.
|
inlineexplicitprivatenoexcept |
EventHandle constructor.
| owner | The EventCenter which owns this EventHandle |
| sig | The signal which the subscriber is interested in |
| iter | The handle object |
|
inlineprivatenoexcept |
Move constructor.
|
inlineprivatenoexcept |
Get the underlying handle.
|
inlinenoexcept |
Boolean operator returns true if the handle is valid, false otherwise.
|
inlinenoexcept |
Move assignment operator.
References embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::EventHandle::handle_.
|
delete |
Delete the copy assignment operator.
|
inlinenoexcept |
Unregister the callback and invalidate the handle.
|
inlinenoexcept |
Check the signal this subscription corresponds to.
|
friend |
Event Center is able to invoke private EventHandle functions.
|
private |
|
private |
|
private |
|
private |
| class embvm::EventCenter |
Global Event Manager class.
Allows you to subscribe and unsubscribe to/from events. Allows you to post signals and events. Calls are dispatched. You must keep your handle alive when you register for a callback. Handles will be automatically cleaned up when they go out of scope!
Allowed: publishing and signaling from an interrupt. Not allowed: subscribing or unsubscribing from an interrupt.
This class provides support for both dynamic memory allocation and static memory allocation. The default TMaxEvents and TMaxSubscribersPerEvent settings (0) indicate dynamic memory.
(TMaxEvents * TMaxSubscribersPerEvent * sizeof(event))| TMaxEvents | The maximum number of events to store in the queue. 0 indicates dynamic memory allocation will be used; all other numbers use static memory. |
| TMaxSubscribersPerEvent | The maximum number of subscribers that can register for each event. 0 indicates dynamic memory allocation will be used; all other numbers use static memory. |
| TFunc | The function object type for the DispatcherFunc. |
Public Types | |
| using | sig_t = Signal_t |
| Underlying signal type. More... | |
| using | cb_t = stdext::inplace_function< void(embvm::EventBase)> |
| Callback type. More... | |
Public Member Functions | |
| EventCenter () noexcept | |
| Default EventCenter constructor. More... | |
| EventCenter (const DispatcherFunc &dispatcher) noexcept | |
| Construct EventCenter with a dispatcher. More... | |
| ~EventCenter ()=default | |
| Default destructor. More... | |
| EventCenter (const EventCenter &)=delete | |
| Deleted copy constructor. More... | |
| const EventCenter & | operator= (const EventCenter &)=delete |
| Deleted copy assignment operator. More... | |
| EventCenter (EventCenter &&)=delete | |
| Deleted move constructor. More... | |
| EventCenter & | operator= (EventCenter &&)=delete |
| Deleted move assignment operator. More... | |
| embvm::EventBase | createSignal (Signal_t sig=Signal::Event_Invalid) noexcept |
| Create an event on the stack. More... | |
| size_t | numSubscribedEvents () noexcept |
| Check how many event types are registered. More... | |
| size_t | numSubscribers (Signal_t sig) noexcept |
| Check how many subscribers are listening to a specific event. More... | |
| EventCenter::EventHandle | subscribe (Signal_t sig, const cb_t &cb) noexcept |
| Subscribe to an event. More... | |
| EventCenter::EventHandle | subscribe (Signal_t sig, cb_t &&cb) noexcept |
| Subscribe to an event. More... | |
| void | unsubscribe (EventCenter::EventHandle &handle) noexcept |
| Unsubscribe from listening for an event. More... | |
| void | signal (Signal_t sig) noexcept |
| Signal an event. More... | |
| void | publish (embvm::EventBase event) noexcept |
| Publish an event. More... | |
Private Types | |
| using | DispatcherFunc = stdext::inplace_function< void(const TFunc &)> |
| The function prototype for the Dispatcher. More... | |
| typedef std::conditional<(TMaxSubscribersPerEvent==0), std::list< cb_t >, etl::list< cb_t, TMaxSubscribersPerEvent > >::type | TListType |
| Type for storing lists of event subscribers. More... | |
| typedef std::conditional<(TMaxEvents==0), std::map< Signal_t, TListType >, etl::map< Signal_t, TListType, TMaxEvents > >::type | TMapType |
| Type for storing event subscription lists. More... | |
Private Member Functions | |
| void | EventCenterDispatch (const TFunc &op) noexcept |
| EventCenter Default Dispatch Function. More... | |
Private Attributes | |
| TMapType | events_ |
| The map which stores event subscriptions. More... | |
| std::mutex | mutex_ |
| Mutex which protects. More... | |
| const DispatcherFunc | dispatcher_ |
| Dispatcher function which will handle callbacks. More... | |
| using embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::cb_t = stdext::inplace_function<void(embvm::EventBase)> |
Callback type.
|
private |
The function prototype for the Dispatcher.
The dispacher uses inplace_function regardless of static or dynamic memory allocation.
| using embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::sig_t = Signal_t |
Underlying signal type.
|
private |
Type for storing lists of event subscribers.
TListType is either std::list or etl::list depending on static or dynamic memory allocations. For static allocations, TListType is capped at TMaxSubscribersPerEvent.
|
private |
Type for storing event subscription lists.
TMapType is either std::map or etl::map depending on static or dynamic memory allocations. For static allocations, TMapType is capped at TMaxEvents. The map key is the signal ID.
|
inlinenoexcept |
Default EventCenter constructor.
Creating an EventCenter without a dispatcher will result in the manager invoking the functions.
|
inlineexplicitnoexcept |
Construct EventCenter with a dispatcher.
Specify a function to dispatch all of the event callbacks to. Used with a dispatch queue, or other type of system event queue.
|
default |
Default destructor.
|
delete |
Deleted copy constructor.
|
delete |
Deleted move constructor.
|
inlinenoexcept |
Create an event on the stack.
|
inlineprivatenoexcept |
EventCenter Default Dispatch Function.
If no external dispatcher is provided, event center has one which just executes the operation by default.
|
inlinenoexcept |
Check how many event types are registered.
References embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::events_.
|
inlinenoexcept |
Check how many subscribers are listening to a specific event.
| sig | The type of event to check. |
References embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::events_.
|
delete |
Deleted copy assignment operator.
|
delete |
Deleted move assignment operator.
|
inlinenoexcept |
Publish an event.
Signals to the system that an event has occurred. All subscribers will have their callback function invoked and will be passed the input event.
| event | The event object that will be shared with the subscribers |
References embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::dispatcher_, and embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::events_.
|
inlinenoexcept |
Signal an event.
Signals to the system that an event has occurred. All subscribers will have their callback function invoked.
| sig | The event type to signal |
References embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::dispatcher_, and embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::events_.
|
inlinenoexcept |
Subscribe to an event.
Subscribes to an event with a callback function. The callback will be invoked whenever an event of the specified type is signalled.
| sig | The type of event to listen for. |
| cb | The function which will be called when the event occurs. |
References assert, embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::events_, and embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::mutex_.
|
inlinenoexcept |
Subscribe to an event.
Subscribes to an event with a callback function. The callback will be invoked whenever an event of the specified type is signalled.
| sig | The type of event to listen for. |
| cb | The function which will be called when the event occurs. |
References assert, embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::events_, and embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::mutex_.
|
inlinenoexcept |
Unsubscribe from listening for an event.
Removes the subscription to the event. An unsubscribe request uses the EventHandle which was returned by subscribe(). Unsubscribe also happens automatically when the EventHandle goes out of scope.
| handle | The handle to the subscription, which was returned by subscribe() |
References embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::events_, and embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::mutex_.
|
private |
Dispatcher function which will handle callbacks.
Referenced by embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::publish(), and embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::signal().
|
private |
The map which stores event subscriptions.
Referenced by embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::numSubscribedEvents(), embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::numSubscribers(), embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::publish(), embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::signal(), embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::subscribe(), and embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::unsubscribe().
|
private |
Mutex which protects.
Referenced by embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::subscribe(), and embvm::EventCenter< TMaxEvents, TMaxSubscribersPerEvent, TFunc >::unsubscribe().
| class embvm::EventQueue |
Keep a queue of events.
Manage a queue of events of a specified type. The EventQueue can utilize both static and dynamic memory allocation strategies.
| TEvent | The event type which this queue manages. Can be embvm::EventBase, or a derived event with data. |
| TQueueSize | The maximum size of the event queue. Size 0 indicates dynamic memory will be used. All other sizes will enable static memory allocation. |
Public Member Functions | |
| EventQueue ()=default | |
| Default constructor. More... | |
| ~EventQueue ()=default | |
| Default destructor. More... | |
| EventQueue (const EventQueue &)=delete | |
| Deleted copy constructor. More... | |
| const EventQueue & | operator= (const EventQueue &)=delete |
| Deleted copy assignment operator. More... | |
| EventQueue (EventQueue &&)=default | |
| Default move constructor. More... | |
| EventQueue & | operator= (EventQueue &&)=default |
| Default move assignment operator. More... | |
| bool | empty () const noexcept |
| Check if the queue is empty. More... | |
| size_t | size () const noexcept |
| Check the size of the queue. More... | |
| void | push (TEvent e) noexcept |
| Add an event to the queue. More... | |
| TEvent & | front () const noexcept |
| Get the front element of the queue, without popping. More... | |
| TEvent | pop () noexcept |
| Pop the front element from the queue. More... | |
Private Types | |
| using | TQueueType = typename std::conditional<(TQueueSize==0), std::queue< TEvent >, etl::queue< TEvent, TQueueSize > >::type |
| The type of the underlying queue. More... | |
Private Attributes | |
| TQueueType | q_ |
| The underlying event queue storage. More... | |
|
private |
The type of the underlying queue.
Size 0 indicates dynamic memory usage (std::queue), other sizes indicate static memory.
|
default |
Default constructor.
|
default |
Default destructor.
|
delete |
Deleted copy constructor.
|
default |
Default move constructor.
|
inlinenoexcept |
Check if the queue is empty.
References embvm::EventQueue< TEvent, TQueueSize >::q_.
|
inlinenoexcept |
Get the front element of the queue, without popping.
References embvm::EventQueue< TEvent, TQueueSize >::q_.
|
delete |
Deleted copy assignment operator.
|
default |
Default move assignment operator.
|
inlinenoexcept |
Pop the front element from the queue.
References embvm::EventQueue< TEvent, TQueueSize >::q_.
|
inlinenoexcept |
Add an event to the queue.
| e | The event to add to the queue for processing. |
References embvm::EventQueue< TEvent, TQueueSize >::q_.
|
inlinenoexcept |
Check the size of the queue.
References embvm::EventQueue< TEvent, TQueueSize >::q_.
|
private |
The underlying event queue storage.
Referenced by embvm::EventQueue< TEvent, TQueueSize >::empty(), embvm::EventQueue< TEvent, TQueueSize >::front(), embvm::EventQueue< TEvent, TQueueSize >::pop(), embvm::EventQueue< TEvent, TQueueSize >::push(), and embvm::EventQueue< TEvent, TQueueSize >::size().
| class embvm::VirtualPlatformBase |
Base class for Platform definitions.
Platforms should derive from this base class, and optionally from other platform base classes which provide optional functionality (see embvm::PlatformEventManagement<>, embvm::PlatformDispatcher<>).
The platform base is templated off of the driver registry type, in order to Allow users to utilize their custom driver types with the platform.
| TPlatform | The derived CRTP class which defines the consumer's platform. |
| TDriverRegistry | The type of the platform's DriverRegistry. DriverRegistry type is specified to enable consumers to use custom driver types. |

Public Member Functions | |
| VirtualPlatformBase (const VirtualPlatformBase &)=delete | |
| Deleted copy constructor. More... | |
| const VirtualPlatformBase & | operator= (const VirtualPlatformBase &)=delete |
| Deleted copy assignment operator. More... | |
| VirtualPlatformBase (VirtualPlatformBase &&)=delete | |
| Deleted move constructor. More... | |
| VirtualPlatformBase & | operator= (VirtualPlatformBase &&)=delete |
| Deleted move assignment operator. More... | |
| void | init () noexcept |
| Initialize the platform. More... | |
| void | initProcessor () noexcept |
| Initialize the processor. More... | |
| void | initHWPlatform () noexcept |
| Initialize the hardware platform. More... | |
| constexpr const std::string_view & | name () const noexcept |
| Access the platform's name. More... | |
| constexpr const char * | name_cstr () const noexcept |
| Access the platform name as a cstring for C API compatibility. More... | |
| auto | findDriver (const std::string_view &name) noexcept |
| Access a device driver in the registry by name. More... | |
| auto | findDriver (embvm::DriverType_t type) noexcept |
| Access a device driver in the registry by type. More... | |
| template<class TDriverClass > | |
| auto | findDriver () noexcept |
| Access a device driver in the registry by type, cast as the appropriate base class. More... | |
| template<class TDriverClass > | |
| auto | findDriver (const std::string_view &name) noexcept |
| Access a device driver in the registry by name, cast as the appropriate base class. More... | |
| auto | findAllDrivers (embvm::DriverType_t type) noexcept |
| Get a list of all device drivers in the registry by type. More... | |
| template<class TDriverClass > | |
| auto | findAllDrivers () noexcept |
| Get a list of all device drivers in the registry by type, cast as the appropriate base class. More... | |
| size_t | driverCount () const noexcept |
| Get the count of drivers registered with the platform. More... | |
Static Public Member Functions | |
| static TPlatform & | inst () noexcept |
| Get the global platform instance. More... | |
| static void | earlyInitHook () noexcept |
| Call early-initialization code. More... | |
| static void | initOS () noexcept |
| Initialize the OS. More... | |
| static void | initOS (void(*main_thread)()) noexcept |
| Initialize the with a function to use as the main thread. More... | |
| static void | registerDriver (const std::string_view &name, embvm::DriverBase *driver) noexcept |
| Platform-level API for registering a new device driver. More... | |
| static void | unregisterDriver (const std::string_view &name, embvm::DriverBase *driver) noexcept |
| Platform-level API for unregistering a new device driver. More... | |
Protected Member Functions | |
| VirtualPlatformBase (const char *name) noexcept | |
| Create a virtual platform base using a C-string. More... | |
| VirtualPlatformBase (const std::string &name) noexcept | |
| Create a virtual platform base using a std::string name. More... | |
| VirtualPlatformBase (const std::string_view &name) noexcept | |
| Create a virtual platform base using a std::string_view name. More... | |
| ~VirtualPlatformBase ()=default | |
| Default destructor. More... | |
Protected Attributes | |
| const std::string_view | name_ |
Static Private Member Functions | |
| static TDriverRegistry & | driverRegistry () noexcept |
| Access the platform DriverRegistry instance. More... | |
|
delete |
Deleted copy constructor.
|
delete |
Deleted move constructor.
|
inlineexplicitprotectednoexcept |
Create a virtual platform base using a C-string.
| name | The name of the platform. |
|
inlineexplicitprotectednoexcept |
Create a virtual platform base using a std::string name.
| name | The name of the platform. Note: VirtualPlatformBase() uses a std::string_view, so the std::string must remain valid |
|
inlineexplicitprotectednoexcept |
Create a virtual platform base using a std::string_view name.
| name | The name of the platform. |
|
protecteddefault |
Default destructor.
|
inlinenoexcept |
Get the count of drivers registered with the platform.
returns Number of drivers currently registered with the platform DriverRegistry.
|
inlinestaticprivatenoexcept |
Access the platform DriverRegistry instance.
Static declaration of the DriverRegistry for the platform. We use this function to avoid the static initializatio order 'fiasco'. See more: https://isocpp.org/wiki/faq/ctors#static-init-order
Referenced by embvm::VirtualPlatformBase< FrameworkDemoSimPlatform, PlatformDriverRegistry >::driverCount(), embvm::VirtualPlatformBase< FrameworkDemoSimPlatform, PlatformDriverRegistry >::findAllDrivers(), embvm::VirtualPlatformBase< FrameworkDemoSimPlatform, PlatformDriverRegistry >::findDriver(), embvm::VirtualPlatformBase< FrameworkDemoSimPlatform, PlatformDriverRegistry >::registerDriver(), and embvm::VirtualPlatformBase< FrameworkDemoSimPlatform, PlatformDriverRegistry >::unregisterDriver().
|
inlinestaticnoexcept |
Call early-initialization code.
Call early initialization code, which is to be run before C runtime initialization, memory relocations, OS initialization, etc. This call is used to handle early setup code that the rest of the initialization process might depend on, such as DRAM initialization.
This function forwards the call to the derived class for the actual implementation.
|
inlinenoexcept |
Get a list of all device drivers in the registry by type.
The type will be returned as the appropriate base class (instead of embvm::DriverBase).
This call forwards the information to the DriverRegistry instance.
| type | The type of driver being requested (embvm::i2c::master, SystemClock). |
|
inlinenoexcept |
Get a list of all device drivers in the registry by type, cast as the appropriate base class.
The type will be returned as the appropriate base class (instead of embvm::DriverBase).
This call forwards the information to the DriverRegistry instance.
| TDriverClass | The class of driver being requested (embvm::i2c::master, SystemClock). |
|
inlinenoexcept |
Access a device driver in the registry by name.
Find a driver by name.
This call forwards the information to the DriverRegistry instance.
|
inlinenoexcept |
Access a device driver in the registry by type.
Find a driver by type. If multiple drivers are found for a type, the first one found will be returned.
This call forwards the information to the DriverRegistry instance.
|
inlinenoexcept |
Access a device driver in the registry by type, cast as the appropriate base class.
If multiple drivers are found for a type, the first one found will be returned. The type will be returned as the appropriate base class (instead of embvm::DriverBase).
This call forwards the information to the DriverRegistry instance.
| TDriverClass | The class of driver being requested (embvm::i2c::master, SystemClock). |
|
inlinenoexcept |
Access a device driver in the registry by name, cast as the appropriate base class.
The type will be returned as the appropriate base class (instead of embvm::DriverBase).
This call forwards the information to the DriverRegistry instance.
| TDriverClass | The class of driver being requested (embvm::i2c::master, SystemClock). |
|
inlinenoexcept |
Initialize the platform.
This function is responsible for initializing the platform.
This function forwards the call to the derived class for the actual implementation.
|
inlinenoexcept |
Initialize the hardware platform.
Performs steps necessary to initialize the hardware platform for use by the platform. In many cases, this call should just invoke the hardware platform's init() function. Control of this function is placed in the platform layer to allow for platform-specific customization & initialization of the hardware platform in situations where non-default values are used.
This function forwards the call to the derived class for the actual implementation.
|
inlinestaticnoexcept |
Initialize the OS.
Performs steps necessary to initialize the OS for use by the platform. Control of this function is placed in the platform layer to allow for platform-specific customization & initialization of the OS, since each OS has different startup requirements
This function forwards the call to the derived class for the actual implementation.
|
inlinestaticnoexcept |
Initialize the with a function to use as the main thread.
Performs steps necessary to initialize the OS for use by the platform. Control of this function is placed in the platform layer to allow for platform-specific customization & initialization of the OS, since each OS has different startup requirements
This function forwards the call to the derived class for the actual implementation.
| main_thread | a function pointer to use as the main thread routine. This version of initOS should be used for OSes such as FreeRTOS which kill execution of the current thread when the scheduler is started. |
|
inlinenoexcept |
Initialize the processor.
Performs steps necessary to initialize the processor for use by the platform. In many cases, this call should just invoke the processor's init() function. Control of this function is placed in the platform layer to allow for platform-specific customization & initialization of the processor in situations where non-default values are used.
This function forwards the call to the derived class for the actual implementation.
|
inlinestaticnoexcept |
Get the global platform instance.
Static declaration of the VirtualPlatformBase instance. We use this function to avoid the static initializatio order 'fiasco'. See more: https://isocpp.org/wiki/faq/ctors#static-init-order
|
inlinenoexcept |
Access the platform's name.
Referenced by embvm::VirtualPlatformBase< FrameworkDemoSimPlatform, PlatformDriverRegistry >::findDriver(), embvm::VirtualPlatformBase< FrameworkDemoSimPlatform, PlatformDriverRegistry >::registerDriver(), and embvm::VirtualPlatformBase< FrameworkDemoSimPlatform, PlatformDriverRegistry >::unregisterDriver().
|
inlinenoexcept |
Access the platform name as a cstring for C API compatibility.
|
delete |
Deleted copy assignment operator.
|
delete |
Deleted move assignment operator.
|
inlinestaticnoexcept |
Platform-level API for registering a new device driver.
Register a device driver with the platform's driver registry.
This call forwards the information to the DriverRegistry instance.
| name | The name (used as a key) the driver will be registered under. |
| driver | Pointer to the embvm::DriverBase object. A pointer is used because there are any number of potential derived classes which will be tracked. To prevent slicing, a pointer to the base class is stored. |
|
inlinestaticnoexcept |
Platform-level API for unregistering a new device driver.
Unregister a device driver with the platform's driver registry.
This call forwards the information to the DriverRegistry instance.
| name | The name of the driver to remove. |
| driver | Pointer to the embvm::DriverBase object being removed. |
|
protected |
| class embvm::PlatformDispatcher |
Add a dispatch queue to the VirtualPlatform through inheritance.
Your platform can inherit from this class to add dispatching APIs a the platform level. This template is specialized based on the class of Dispatch Queue you want to create.
Example declaration:
| TDispatchQueue | The type declaration for the underlying dispatch queue. This is user specified because each platform will have its own specific dispatch queue configuration. |

Public Member Functions | |
| PlatformDispatcher (size_t threads=1) noexcept | |
| Construct a platform dispatcher. More... | |
| PlatformDispatcher (const char *name, size_t threads=1) noexcept | |
| Construct a platform dispatcher with a C-string name. More... | |
| PlatformDispatcher (const std::string &name, size_t threads=1) noexcept | |
| Construct a platform dispatcher with a C-string name. More... | |
| PlatformDispatcher (const std::string_view &name, size_t threads=1) noexcept | |
| Construct a platform dispatcher with a std::string_views name. More... | |
| auto | getBoundDispatch () noexcept |
| Get std::bind object corresponding dispatch(const&) function. More... | |
| auto | getBoundMoveDispatch () noexcept |
| Get std::bind object corresponding dispatch(&&) function. More... | |
| void | dispatch (const TFunc &op) noexcept |
| Dispatch an operation. More... | |
| void | dispatch (TFunc &&op) noexcept |
| Dispatch an operation. More... | |
Protected Attributes | |
| TDispatchQueue | dispatch_queue_ |
Private Types | |
| using | TFunc = typename TDispatchQueue::DispatchFunc_t |
|
private |
|
inlineexplicitnoexcept |
Construct a platform dispatcher.
| threads | The number of threads the dispatch queue will use. |
|
inlineexplicitnoexcept |
Construct a platform dispatcher with a C-string name.
| name | The name for the dispatch queue. |
| threads | The number of threads the dispatch queue will use. |
|
inlineexplicitnoexcept |
Construct a platform dispatcher with a C-string name.
| name | The name for the dispatch queue. |
| threads | The number of threads the dispatch queue will use |
|
inlineexplicitnoexcept |
Construct a platform dispatcher with a std::string_views name.
| name | The name for the dispatch queue. |
| threads | The number of threads the dispatch queue will use |
|
inlinenoexcept |
Dispatch an operation.
Dispatch an operation to the queue. Forwards the function object to the underlying dispatch queue.
| op | The function object containing the operation that will be dispatched to the queue. |
|
inlinenoexcept |
Dispatch an operation.
Dispatch an operation to the queue. Forwards the function object to the underlying dispatch queue.
| op | The function object containing the operation that will be dispatched to the queue. |
|
inlinenoexcept |
Get std::bind object corresponding dispatch(const&) function.
If you need to get the function dispatch(const&) variant for use with another class, (e.g., passing dispatch() as a callback), use this function.
std::bind object corresponding to the dispatch(const&) function.
|
inlinenoexcept |
Get std::bind object corresponding dispatch(&&) function.
If you need to get the function dispatch(&&) variant for use with another class, (e.g., passing dispatch() as a callback), use this function.
std::bind object corresponding to the dispatch(&&) function.
|
protected |
| class embvm::PlatformEventManagement |
Add an event manager to the VirtualPlatform through inheritance.
Your platform can inherit from this class to add event APIs a the platform level This template is specialized based on the class of EventCenter you want to create
Example declaration:
| TEventCenter | The class of EventCenter you want to use with the Platform Event Manager. |

Public Member Functions | |
| auto | subscribeToEvent (event_sig_t sig, const event_cb_t &cb) noexcept |
| Subscribe to an event. More... | |
| auto | subscribeToEvent (event_sig_t sig, event_cb_t &&cb) noexcept |
| void | unsubscribeFromEvent (typename TEventCenter::EventHandle &handle) noexcept |
| Unsubscribe from an event. More... | |
| void | signal (event_sig_t sig) noexcept |
| Forwards a signal to the event manager. More... | |
| void | publishEvent (EventBase event) noexcept |
| Forwards an event to the event manager. More... | |
Protected Attributes | |
| TEventCenter | event_manager_ |
| The instance of the event manager that belongs to the platform. More... | |
Private Types | |
| using | event_sig_t = typename TEventCenter::sig_t |
| Convenience alias for the signal type. More... | |
| using | event_cb_t = typename TEventCenter::cb_t |
| Convenience alias for the callback type. More... | |
|
private |
Convenience alias for the callback type.
|
private |
Convenience alias for the signal type.
|
inlinenoexcept |
Forwards an event to the event manager.
| event | The event to publish to the platform event manager. |
|
inlinenoexcept |
Forwards a signal to the event manager.
| sig | The signal to raise to the platform event manager. |
|
inlinenoexcept |
Subscribe to an event.
| sig | The signal to subscribe to. |
| cb | The callback function to invoke when the signal is raised. |
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexcept |
Unsubscribe from an event.
| handle | The event handle to unsubscribe. |
|
protected |
The instance of the event manager that belongs to the platform.
Referenced by embvm::PlatformEventManagement< PlatformEventCenter >::publishEvent(), embvm::PlatformEventManagement< PlatformEventCenter >::signal(), embvm::PlatformEventManagement< PlatformEventCenter >::subscribeToEvent(), and embvm::PlatformEventManagement< PlatformEventCenter >::unsubscribeFromEvent().
| using embvm::DynamicEventCenter = typedef EventCenter<0, 0> |
Declare an EventCenter that uses dynamic memory allocation.
A EventCenter utilizes dynamic memory allocation and can grow to the limit that memory allows. This type is useful for host-based simulation platforms, as well as embedded platforms which allow dynamic memory allocation.
| using embvm::Signal_t = typedef uint32_t |
Signal type which is used for function inputs.
This type is preferred because users are able to define their own signal types.
| using embvm::StaticEventCenter = typedef EventCenter<TMaxEvents, TMaxSubscribersPerEvent> |
Declare a DriverRegistry that uses static memory allocation.
The size and memory allocation of the StaticDriverRegistry is known at compile-time. No dynamic memory allocations are used.
| TMaxEvents | The maximum number of events to store in the queue. 0 indicates dynamic memory allocation will be used; all other numbers use static memory. |
| TMaxSubscribersPerEvent | The maximum number of subscribers that can register for each event. 0 indicates dynamic memory allocation will be used; all other numbers use static memory. |
| using embvm::StaticEventQueue = typedef embutil::StaticDispatchQueue<TSize, TThreadCnt, TFunc> |
This alias represents a static dispatch queue which can be used with the event manager Primarily this alias is used to prevent users from needing to declare a long type declaration just because of the need to increase inplace_function<>'s size.
| TSize | the maximum number of entries in the dispatch queue |
| TThreadCnt | the number of threads to use in the dispatch queue |
| TFunc | the function object that will be stored in the queue |
| enum embvm::Signal |
Default framework event signal definitions.
These default signals carry no data.
To add your own event types, create an enum in your project code and use Event_EXTENSION_START as the first value.
| Enumerator | |
|---|---|
| Event_Invalid | |
| Event_ProcessorInitd | |
| Event_HwPlatformInitd | |
| Event_PlatformInitd | |
| Event_EXTENSION_START | |
|
static |
Maximum size of the Event center callback functor object.
1.8.15