MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Showcase::ComponentInstance Class Referenceabstract

Proxy object for instanced object (f.ex. Widget or service). More...

#include <Component.hpp>

Inheritance diagram for Showcase::ComponentInstance:
Showcase::ServiceInstance Showcase::UIComponentInstance Showcase::OperatorInstance Showcase::RootInstance Showcase::ScheduleInstance Showcase::WidgetInstance

Public Member Functions

 ComponentInstance (std::shared_ptr< Component > component)
 Create a new instance from the given component. More...
 
virtual ~ComponentInstance ()
 Each subclass needs to do needed clean up in their own destructors (should be enough to call removeInstance) More...
 
virtual MultiWidgets::WidgetPtr widgetInstance ()
 After first call of this, user of the component is required to keep track of the widget. More...
 
virtual MultiWidgets::OperatorPtr operatorInstance (MultiWidgets::Widget &host, bool immediate=false)
 Assigns the operator to the given widget. More...
 
std::shared_ptr< Componentcreator () const
 An instance is always tied to a component and can't exist without the component that created it. More...
 
virtual void propertyReceived (const PropertyKey &key, const PropertyValue &value)
 Called for each property found for the creator component This function may be called same time from multiple threads. More...
 
virtual void propertyLost (const PropertyKey &key, const PropertyValue &value)
 Called when a property is unset for the component This function may be called same time from multiple threads. More...
 

Protected Member Functions

virtual void removeInstance ()=0
 Allows removing component instance when the component is removed. More...
 
void onDelete ()
 This needs to be set up so that when the actual instance (not this proxy object) is removed this is called (f.ex. More...
 

Detailed Description

Proxy object for instanced object (f.ex. Widget or service).

Constructor & Destructor Documentation

Showcase::ComponentInstance::ComponentInstance ( std::shared_ptr< Component component)

Create a new instance from the given component.

Parameters
componentthe creator component
Showcase::ComponentInstance::~ComponentInstance ( )
virtual

Each subclass needs to do needed clean up in their own destructors (should be enough to call removeInstance)

Basically this is only possible to be destroyed from the creator so no need to notify this being destroyed with onDelete();

Member Function Documentation

std::shared_ptr< Component > Showcase::ComponentInstance::creator ( ) const

An instance is always tied to a component and can't exist without the component that created it.

The component is guaranteed to stay alive as long as any instance of it exists

Returns
the component that created this instance
void Showcase::ComponentInstance::onDelete ( )
protected

This needs to be set up so that when the actual instance (not this proxy object) is removed this is called (f.ex.

represented Widget is deleted). Not to be confused with destructor that is triggered when this proxy is destroyed.

Notifies creator of this instance

MultiWidgets::OperatorPtr Showcase::ComponentInstance::operatorInstance ( MultiWidgets::Widget &  host,
bool  immediate = false 
)
virtual

Assigns the operator to the given widget.

ComponentInstance erases the last strong pointer to the operator after this If immediate is set to true, operator is added to the widget during this call, otherwise it's added to the widget in main thread after next update.

Reimplemented in Showcase::OperatorInstance.

void Showcase::ComponentInstance::propertyLost ( const PropertyKey key,
const PropertyValue &  value 
)
virtual

Called when a property is unset for the component This function may be called same time from multiple threads.

Parameters
keyidentifies the target property
valuevalue for the property

Reimplemented in Showcase::WidgetInstance, Showcase::OperatorInstance, and Showcase::ScheduleInstance.

void Showcase::ComponentInstance::propertyReceived ( const PropertyKey key,
const PropertyValue &  value 
)
virtual

Called for each property found for the creator component This function may be called same time from multiple threads.

Parameters
keyidentifies the target property
valuenew value set for the property

Reimplemented in Showcase::WidgetInstance, Showcase::OperatorInstance, Showcase::ServiceInstance, and Showcase::ScheduleInstance.

virtual void Showcase::ComponentInstance::removeInstance ( )
protectedpure virtual

Allows removing component instance when the component is removed.

Implementations must not call instanceDestroyed of the associated component

Implemented in Showcase::UIComponentInstance, Showcase::WidgetInstance, Showcase::RootInstance, Showcase::ServiceInstance, Showcase::OperatorInstance, and Showcase::ScheduleInstance.

MultiWidgets::WidgetPtr Showcase::ComponentInstance::widgetInstance ( )
virtual

After first call of this, user of the component is required to keep track of the widget.

componentInstance erases the last strong pointer to widget after this

Reimplemented in Showcase::WidgetInstance.