Carousel
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Pages
Public Member Functions | Protected Member Functions | List of all members
BaseComponent Class Reference

It is a base unit of the carousel, that can contain UI and/or logic features, provides or exposes some services for the other components. More...

#include <BaseComponent.h>

Inherits IComponent.

Inherited by ComponentSystemUIComponent, InteractionServiceComponent, JsScriptingComponent, ProxyComponent, and UndoComponent.

Public Member Functions

Availability availability () const
 
const ComponentDefinitiondefinition () const
 
void * getExtension (const QString &byTypeId) const
 
bool isCompatible (const IComponent *withOther) const
 
const QStringname () const
 
void setAvailability (Availability newMode)
 
void shutdown (IServiceLocator *serviceLocator)
 
bool started () const
 
bool startup (IServiceLocator *serviceLocator)
 
- Public Member Functions inherited from IComponent
template<typename TExtension >
TExtension * extension ()
 
template<typename TExtension >
const TExtension * extension () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
bool blockSignals (bool block)
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThreadthread () const
 

Protected Member Functions

 BaseComponent (const QString &name, QObject *parent=nullptr)
 
 BaseComponent (ComponentDefinition *definition, QObject *parent=nullptr)
 
void addParent (const QString &parentName, int major_version, int minor_version, int build_version=0, int revision_version=0)
 
void loadAvailability ()
 
virtual void onAvailabilityChanged (Availability newMode)
 
virtual void onShutdown (IServiceLocator *serviceLocator)
 
virtual bool onStartup (IServiceLocator *serviceLocator)
 
template<typename TExtension >
void registerExtension (TExtension *instance)
 
void saveAvailability ()
 
void setDescription (const QString &description)
 
void setProductName (const QString &productName)
 
void setProvider (const QString &provider)
 
void setShortName (const QString &name)
 
void setVersion (int major_version, int minor_version, int build_version=0, int revision_version=0)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObjectsender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from IComponent
enum  Availability { Enabled, Disabled, Unavailable }
 
- Signals inherited from IComponent
void availabilityChanged (IComponent::Availability)
 
- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from IComponent
Availability availability
 
const ComponentDefinition definition
 
QString name
 
bool started
 
- Properties inherited from QObject
 objectName
 

Detailed Description

It is a base unit of the carousel, that can contain UI and/or logic features, provides or exposes some services for the other components.

See ComponentDefinition interface, if your component will be have a dependencies from the other application components.

The BaseComponent also serves as a base class for the custom Components. It sets objectName to the QObject, provides defensive invokes of startup() and shutdown(), and exposes the registerExtension() template method to register component extensions while deriving.

If availability was changed during last application's start, it will be loaded and ovewrite default value.

Constructor & Destructor Documentation

BaseComponent::BaseComponent ( const QString name,
QObject parent = nullptr 
)
explicitprotected

Initializes a new instance of the BaseComponent class using specified component name and IComponent::Enabled availability.

Parameters
namethe name of your component class. In derived classes you should pass the unique name for the your component (not per instance, but per class!).
BaseComponent::BaseComponent ( ComponentDefinition definition,
QObject parent = nullptr 
)
explicitprotected

Initializes a new instance of the BaseComponent class using specified component definition and IComponent::Enabled availability..

Parameters
definitionThis paramter cannot be null.

Member Function Documentation

Availability BaseComponent::availability ( ) const
virtual

Gets the value specified whether this component is enabled, disabled, or unavailable. When the availability is enabled, the component is checked in the Components dialog.

See Also
setAvailability

Implements IComponent.

const ComponentDefinition* BaseComponent::definition ( ) const
virtual

Gets the component definition that can specify component dependencies and also describes the component.

Note, that component takes ownership for its defition.

Implements IComponent.

void* BaseComponent::getExtension ( const QString byTypeId) const
virtual

Finds extension's pointer associated with it type id in inner objects dictionary.

Returns
The raw pointer corresponded with specified type id if such found. Null pointer otherwise.

Implements IComponent.

Reimplemented in ProxyComponent.

bool BaseComponent::isCompatible ( const IComponent withOther) const
virtual

Returns true if component version is compatible with all parent component versions, e.g. if they are equal. Otherwise, returns false.

See Also
ComponentDefinition::isCompatible()

Implements IComponent.

const QString& BaseComponent::name ( ) const
virtual

The name of the component. This name should be unique and used for the resolving component dependencies.

It is a shortcut for the definition()->name().

Implements IComponent.

void BaseComponent::setAvailability ( Availability  newMode)
virtual

Sets the value specified whether this component is enabled or disabled. The checked state of the component is saved in the user settings.

See Also
availability

Implements IComponent.

void BaseComponent::shutdown ( IServiceLocator serviceLocator)
virtual

Shuts down the component. Implement this method to perform some action when the component gets unloaded.

Note
You should not use this method directly, use IComponentManager::shutdownComponent() instead.

Implements IComponent.

bool BaseComponent::started ( ) const
virtual

Gets the value determined whether component is already started or not.

Implements IComponent.

bool BaseComponent::startup ( IServiceLocator serviceLocator)
virtual

When all components are registered, each component started up with given initialization data.

Parameters
serviceLocatoris a reference to the services pool. It is needed to register/locate to common services and other components' services.
Returns
true, if component started up successful. Otherwise - return false. E.g. if component started twice - it is return false on the second time, because it is already started.
Note
You should not use this method directly, use IComponentManager::startupComponent() instead.

Implements IComponent.

template<typename TExtension >
void BaseComponent::registerExtension ( TExtension *  instance)
protected

Registers an extension instance. It might be necessary to specify typename TExtension explicitly due to the static binding:

* MyExtension extension;
* this->registerExtension(&extension); // will be registered "class MyExtension" - seems not what you expected
* IMyExtension *locatedExtension = this->extension<IMyExtension>() // returns null, because asked "class IMyExtension" does not found
*

To avoid this you should explicitly specify registered typename:

* MyExtension extension;
* this->registerInstance<IMyExtension>(&extension); // will be registered "class IMyExtension" - good
* IMyExtension *locatedExtension = this->extension<IMyExtension>() // returns extension pointer
*

or register pointer to the extension interface:

* IMyExtension *extensionInterface = new MyExtension();
* this->registerInstance(extensionInterface); // will be registered "class IMyExtension" - good
* IMyExtension *locatedExtension = this->extension<IMyExtension>() // returns extension pointer
*
Template Parameters
TExtensionThe type of extension, which instance name should be associated while registered.
Note
it does not take ownership for registered extension.
virtual void BaseComponent::onShutdown ( IServiceLocator serviceLocator)
protectedvirtual

It is a defensive declaration of the public shutdown() method, that invokes only after startup(). When override in derived classes shuts down the component. Nothing to do by default.

Reimplemented in JsScriptingComponent, ProxyComponent, InteractionServiceComponent, UndoComponent, and ComponentSystemUIComponent.

virtual bool BaseComponent::onStartup ( IServiceLocator serviceLocator)
protectedvirtual

It is a defensive declaration of the public startup() method, that invokes only if component is not started. When override in derived classes starts up the component. Nothing to do by default.

Parameters
serviceLocatoris a reference to the services pool. It is needed to register/locate to common services and other components' services.

Reimplemented in JsScriptingComponent, ProxyComponent, InteractionServiceComponent, UndoComponent, and ComponentSystemUIComponent.

void BaseComponent::addParent ( const QString parentName,
int  major_version,
int  minor_version,
int  build_version = 0,
int  revision_version = 0 
)
protected

Adds a parent component name and version as a dependency for defined component.

void BaseComponent::loadAvailability ( )
protected

Loads component availability using QSettings and component name.

void BaseComponent::saveAvailability ( )
protected

Saves component availability using QSettings and component name.

void BaseComponent::setDescription ( const QString description)
protected

Sets the component description.

void BaseComponent::setShortName ( const QString name)
protected

Sets the short component name.

void BaseComponent::setProductName ( const QString productName)
protected

Sets the product name.

void BaseComponent::setProvider ( const QString provider)
protected

Sets the provider name.

void BaseComponent::setVersion ( int  major_version,
int  minor_version,
int  build_version = 0,
int  revision_version = 0 
)
protected

Sets the version of a component.

virtual void BaseComponent::onAvailabilityChanged ( Availability  newMode)
protectedvirtual

This method emits availabilityChanged() signal when extension's availability changed.

See Also
setAvailability, availabilityChanged