Qt IOC Container 3.5


qic::DefaultApplicationContext Class Reference

#include <DefaultApplicationContext.h>

Inheritance diagram for qic::DefaultApplicationContext:

Inheritance graph
[legend]
Collaboration diagram for qic::DefaultApplicationContext:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DefaultApplicationContext ()
virtual ~DefaultApplicationContext ()
virtual QObject * getObject (QString id)
virtual bool containsObject (QString id)
virtual QStringList getObjectDefinitionIds ()
virtual ObjectDefinitiongetObjectDefinition (QString id)
virtual QList< WireDefinition * > getWireDefinitions ()
virtual void registerObjectDefinition (QString id, ObjectDefinition *objectDefinition)
virtual void registerWireDefinition (WireDefinition *wireDefinition)
virtual QObject * resolveReferenceObject (ReferenceDefinition refDef)
virtual void registerReferenceInjector (QString type, QString path)

Protected Member Functions

virtual void unloadInjectorPlugins ()
virtual QVariant resolveReferenceInPropertyValue (QVariant val)
virtual void setProperty (QString id, QString name, QVariant val)
virtual void initObject (QString id)
virtual void destroyObject (QString id)
virtual void loadObject (QString id)
virtual void createObject (QString id)
virtual void injectDependencies (QString id)
virtual bool objectLoaded (QString id)
virtual bool objectStartLoading (QString id)
virtual void deleteFactoryCreatedObjects ()
virtual void unloadPlugins ()
virtual void deleteObjectDefinitions ()
virtual void deleteWireDefinitions ()
virtual void destroyObjects ()
virtual void wireObject (WireDefinition *def)
virtual void loadObjects ()
virtual void wireObjects ()

Protected Attributes

QStringList _object_id_list
QHash< QString, ObjectDefinition * > _object_definition_map
QList< WireDefinition * > _wire_definition_list
QHash< QString, QObject * > _object_map
QHash< QString, QPluginLoader * > _object_loader_map
QHash< QString, ObjectStatus_object_status_map
QHash< QString, QObject * > _injector_map
QHash< QString, QPluginLoader * > _injector_loader_map

Classes

struct  ObjectStatus

Detailed Description

DefaultApplicationContext loads objects from object definitions. It deletes factory-created objects in destructor. For plugin objects, the Qt system manages their release.

Author:
Zhihong "John" Wang

Definition at line 28 of file DefaultApplicationContext.h.


Constructor & Destructor Documentation

DefaultApplicationContext::DefaultApplicationContext  ) 
 

Definition at line 472 of file DefaultApplicationContext.cpp.

DefaultApplicationContext::~DefaultApplicationContext  )  [virtual]
 

Definition at line 475 of file DefaultApplicationContext.cpp.

References deleteFactoryCreatedObjects(), deleteObjectDefinitions(), deleteWireDefinitions(), destroyObjects(), unloadInjectorPlugins(), and unloadPlugins().


Member Function Documentation

bool DefaultApplicationContext::containsObject QString  id  )  [virtual]
 

Test if object id is in the container.

Implements qic::ApplicationContext.

Definition at line 507 of file DefaultApplicationContext.cpp.

References _object_map.

Referenced by qic::XmlApplicationContext::containsObject(), getObject(), and loadObject().

void DefaultApplicationContext::createObject QString  id  )  [protected, virtual]
 

Load object plugin or use factory to create object.

Definition at line 240 of file DefaultApplicationContext.cpp.

References _object_definition_map, qic::ObjectDefinition::getFactoryObjectId(), and qic::ObjectDefinition::getPluginPath().

Referenced by loadObject().

void DefaultApplicationContext::deleteFactoryCreatedObjects  )  [protected, virtual]
 

Definition at line 399 of file DefaultApplicationContext.cpp.

References _object_definition_map, and _object_map.

Referenced by ~DefaultApplicationContext().

void DefaultApplicationContext::deleteObjectDefinitions  )  [protected, virtual]
 

Definition at line 438 of file DefaultApplicationContext.cpp.

References _object_definition_map.

Referenced by ~DefaultApplicationContext().

void DefaultApplicationContext::deleteWireDefinitions  )  [protected, virtual]
 

Definition at line 452 of file DefaultApplicationContext.cpp.

References _wire_definition_list.

Referenced by ~DefaultApplicationContext().

void DefaultApplicationContext::destroyObject QString  id  )  [protected, virtual]
 

Call destroy method

Definition at line 113 of file DefaultApplicationContext.cpp.

References _object_definition_map, qic::ObjectDefinition::getDestroyMethodName(), and qic::ObjectDefinition::getInitMethodName().

Referenced by destroyObjects().

void DefaultApplicationContext::destroyObjects  )  [protected, virtual]
 

Call destroy method on all objects.

If init method was not successfully called, destroy method does not get called. If no init method was defined, destroy method is called.

Definition at line 464 of file DefaultApplicationContext.cpp.

References _object_id_list, and destroyObject().

Referenced by ~DefaultApplicationContext().

QObject * DefaultApplicationContext::getObject QString  id  )  [virtual]
 

Get object pointer indicated by the id of the object.

Parameters:
id id of the object.
Exceptions:
ObjectNotFoundException 

Implements qic::ApplicationContext.

Definition at line 513 of file DefaultApplicationContext.cpp.

References _object_map, and containsObject().

Referenced by qic::XmlApplicationContext::getObject(), and wireObject().

ObjectDefinition * DefaultApplicationContext::getObjectDefinition QString  id  )  [virtual]
 

Implements qic::ObjectDefinitionRegistry.

Definition at line 526 of file DefaultApplicationContext.cpp.

References _object_definition_map.

QStringList DefaultApplicationContext::getObjectDefinitionIds  )  [virtual]
 

Implements qic::ObjectDefinitionRegistry.

Definition at line 545 of file DefaultApplicationContext.cpp.

References _object_id_list.

QList< WireDefinition * > DefaultApplicationContext::getWireDefinitions  )  [virtual]
 

Get all the wire definitions.

Implements qic::ObjectDefinitionRegistry.

Definition at line 539 of file DefaultApplicationContext.cpp.

References _wire_definition_list.

void DefaultApplicationContext::initObject QString  id  )  [protected, virtual]
 

Call init method

Definition at line 78 of file DefaultApplicationContext.cpp.

References _object_definition_map, _object_map, _object_status_map, and qic::ObjectDefinition::getInitMethodName().

Referenced by loadObject().

void DefaultApplicationContext::injectDependencies QString  id  )  [protected, virtual]
 

Set properties and reference objects.

Definition at line 332 of file DefaultApplicationContext.cpp.

References _object_definition_map, qic::ObjectDefinition::getPropertyValues(), and setProperty().

Referenced by loadObject().

void DefaultApplicationContext::loadObject QString  id  )  [protected, virtual]
 

Load and prepare object.

Definition at line 368 of file DefaultApplicationContext.cpp.

References _object_status_map, containsObject(), createObject(), qic::DefaultApplicationContext::ObjectStatus::inConstruction, qic::DefaultApplicationContext::ObjectStatus::initMethodCalled, initObject(), injectDependencies(), objectLoaded(), and objectStartLoading().

Referenced by loadObjects().

void DefaultApplicationContext::loadObjects  )  [protected, virtual]
 

Make the objects ready in the registry.

This is called in derived classes when the object definitions are ready.

Definition at line 167 of file DefaultApplicationContext.cpp.

References _object_id_list, and loadObject().

Referenced by qic::XmlApplicationContextImpl::XmlApplicationContextImpl().

bool DefaultApplicationContext::objectLoaded QString  id  )  [protected, virtual]
 

Test if object is ready.

Definition at line 354 of file DefaultApplicationContext.cpp.

References _object_status_map.

Referenced by loadObject().

bool DefaultApplicationContext::objectStartLoading QString  id  )  [protected, virtual]
 

Test if object is loading.

Definition at line 348 of file DefaultApplicationContext.cpp.

References _object_status_map.

Referenced by loadObject().

void DefaultApplicationContext::registerObjectDefinition QString  id,
ObjectDefinition objectDefinition
[virtual]
 

Implements qic::ObjectDefinitionRegistry.

Definition at line 551 of file DefaultApplicationContext.cpp.

References _object_definition_map.

void DefaultApplicationContext::registerReferenceInjector QString  type,
QString  path
[virtual]
 

Implements qic::ObjectDefinitionRegistry.

Definition at line 301 of file DefaultApplicationContext.cpp.

References _injector_loader_map, _injector_map, and qic::Util::loadPlugin().

void DefaultApplicationContext::registerWireDefinition WireDefinition wireDefinition  )  [virtual]
 

Implements qic::ObjectDefinitionRegistry.

Definition at line 563 of file DefaultApplicationContext.cpp.

References _wire_definition_list, qic::WireDefinition::getReceiverMethod(), qic::WireDefinition::getReceiverObjectId(), qic::WireDefinition::getSenderObjectId(), and qic::WireDefinition::getSenderSignal().

QVariant DefaultApplicationContext::resolveReferenceInPropertyValue QVariant  val  )  [protected, virtual]
 

Definition at line 31 of file DefaultApplicationContext.cpp.

References _injector_map, and qic::ReferenceInjector::injectReference().

Referenced by setProperty().

QObject * DefaultApplicationContext::resolveReferenceObject ReferenceDefinition  refDef  )  [virtual]
 

Implements qic::ReferenceResolver.

Definition at line 309 of file DefaultApplicationContext.cpp.

References _object_definition_map, and qic::ReferenceDefinition::refId.

void DefaultApplicationContext::setProperty QString  id,
QString  name,
QVariant  val
[protected, virtual]
 

Set property of an object.

Parameters:
id object id
name property name
val property value

Definition at line 53 of file DefaultApplicationContext.cpp.

References _object_map, and resolveReferenceInPropertyValue().

Referenced by injectDependencies().

void DefaultApplicationContext::unloadInjectorPlugins  )  [protected, virtual]
 

Definition at line 487 of file DefaultApplicationContext.cpp.

References _injector_loader_map.

Referenced by ~DefaultApplicationContext().

void DefaultApplicationContext::unloadPlugins  )  [protected, virtual]
 

Definition at line 424 of file DefaultApplicationContext.cpp.

References _object_loader_map.

Referenced by ~DefaultApplicationContext().

void DefaultApplicationContext::wireObject WireDefinition def  )  [protected, virtual]
 

Connect signal and slot.

Definition at line 185 of file DefaultApplicationContext.cpp.

References getObject(), qic::WireDefinition::getReceiverMethod(), qic::WireDefinition::getReceiverObjectId(), qic::WireDefinition::getSenderObjectId(), qic::WireDefinition::getSenderSignal(), qic::WireDefinition::getWireType(), and qic::Util::translateConnectionType().

Referenced by wireObjects().

void DefaultApplicationContext::wireObjects  )  [protected, virtual]
 

Connect all the signals and slots.

This is called in derived classes after objects are loaded.

Definition at line 176 of file DefaultApplicationContext.cpp.

References _wire_definition_list, and wireObject().

Referenced by qic::XmlApplicationContextImpl::XmlApplicationContextImpl().


Member Data Documentation

QHash<QString, QPluginLoader *> qic::DefaultApplicationContext::_injector_loader_map [protected]
 

PluginLoaders for injectors indexed type name.

Definition at line 180 of file DefaultApplicationContext.h.

Referenced by registerReferenceInjector(), and unloadInjectorPlugins().

QHash<QString, QObject *> qic::DefaultApplicationContext::_injector_map [protected]
 

type name => injector object.

Definition at line 175 of file DefaultApplicationContext.h.

Referenced by registerReferenceInjector(), and resolveReferenceInPropertyValue().

QHash<QString, ObjectDefinition *> qic::DefaultApplicationContext::_object_definition_map [protected]
 

object id => object definition

Definition at line 146 of file DefaultApplicationContext.h.

Referenced by createObject(), deleteFactoryCreatedObjects(), deleteObjectDefinitions(), destroyObject(), getObjectDefinition(), initObject(), injectDependencies(), registerObjectDefinition(), and resolveReferenceObject().

QStringList qic::DefaultApplicationContext::_object_id_list [protected]
 

All the object ids.

Definition at line 141 of file DefaultApplicationContext.h.

Referenced by destroyObjects(), getObjectDefinitionIds(), and loadObjects().

QHash<QString, QPluginLoader *> qic::DefaultApplicationContext::_object_loader_map [protected]
 

object id => QPluginLoader *

Definition at line 159 of file DefaultApplicationContext.h.

Referenced by unloadPlugins().

QHash<QString, QObject *> qic::DefaultApplicationContext::_object_map [protected]
 

object id => QObject *

Definition at line 155 of file DefaultApplicationContext.h.

Referenced by containsObject(), deleteFactoryCreatedObjects(), getObject(), initObject(), and setProperty().

QHash<QString, ObjectStatus> qic::DefaultApplicationContext::_object_status_map [protected]
 

object id => ObjectStatus

Definition at line 170 of file DefaultApplicationContext.h.

Referenced by initObject(), loadObject(), objectLoaded(), and objectStartLoading().

QList<WireDefinition *> qic::DefaultApplicationContext::_wire_definition_list [protected]
 

All wire definitions.

Definition at line 150 of file DefaultApplicationContext.h.

Referenced by deleteWireDefinitions(), getWireDefinitions(), registerWireDefinition(), and wireObjects().


The documentation for this class was generated from the following files: