Qt IOC Container 3.5


DefaultApplicationContext.h

Go to the documentation of this file.
00001 
00002 #ifndef QIC_DEFAULT_APPLICATION_CONTEXT_H_
00003 #define QIC_DEFAULT_APPLICATION_CONTEXT_H_
00004 
00005 #include <QString>
00006 #include <QObject>
00007 #include <QHash>
00008 #include <QPluginLoader>
00009 #include <QList>
00010 #include <QVariant>
00011 
00012 #include "ApplicationContext.h"
00013 #include "ObjectDefinitionRegistry.h"
00014 #include "ReferenceDefinition.h"
00015 #include "ReferenceResolver.h"
00016 
00017 #include <log4cxx/logger.h>
00018 
00019 namespace qic
00020 {
00028   class DefaultApplicationContext : public ApplicationContext, public ObjectDefinitionRegistry, public ReferenceResolver
00029   {
00030 
00031     static log4cxx::LoggerPtr logger;
00032 
00033   public:
00034     DefaultApplicationContext ();
00035 
00036     virtual ~DefaultApplicationContext ();
00037 
00038     virtual QObject * getObject (QString id);
00039 
00040     virtual bool containsObject (QString id);
00041 
00042     virtual QStringList getObjectDefinitionIds ();
00043 
00044     virtual ObjectDefinition * getObjectDefinition(QString id);
00045 
00046     virtual QList<WireDefinition *> getWireDefinitions ();
00047 
00048     virtual void registerObjectDefinition (QString id, ObjectDefinition * objectDefinition);
00049 
00050     virtual void registerWireDefinition (WireDefinition * wireDefinition);
00051 
00052     virtual QObject * resolveReferenceObject (ReferenceDefinition refDef);
00053 
00054     virtual void registerReferenceInjector (QString type, QString path);
00055 
00056   protected:
00057 
00058     virtual void unloadInjectorPlugins ();
00059 
00060     virtual QVariant resolveReferenceInPropertyValue(QVariant val);
00061 
00069     virtual void setProperty(QString id, QString name, QVariant val);
00073     virtual void initObject(QString id);
00077     virtual void destroyObject (QString id);
00081     virtual void loadObject (QString id);
00085     virtual void createObject (QString id);
00089     virtual void injectDependencies (QString id);
00090 
00091 //    virtual void injectReferenceObject (QString id, QString name, ReferenceDefinition ref);
00092 //    virtual void injectReferenceObjects (QString id, QString name, QVariantMap ref);
00093 //    virtual void injectReferenceObjects (QString id, QString name, QVariantList ref);
00094 //    virtual void injectReferenceObjects (QString id, QString name, QVariant ref);
00095 
00096 //    virtual QObject * getReferenceObject (ReferenceDefinition refDef);
00097 
00101     virtual bool objectLoaded (QString id);
00105     virtual bool objectStartLoading (QString id);
00106 
00107     virtual void deleteFactoryCreatedObjects ();
00108     virtual void unloadPlugins ();
00109     virtual void deleteObjectDefinitions ();
00110     virtual void deleteWireDefinitions ();
00117     virtual void destroyObjects ();
00118 
00122     virtual void wireObject (WireDefinition * def);
00123 
00129     virtual void loadObjects ();
00130 
00136     virtual void wireObjects ();
00137 
00141     QStringList _object_id_list;
00142 
00146     QHash <QString, ObjectDefinition *> _object_definition_map;
00150     QList<WireDefinition *> _wire_definition_list;
00151 
00155     QHash <QString, QObject *> _object_map;
00159     QHash <QString, QPluginLoader *> _object_loader_map;
00160 
00161     struct ObjectStatus
00162     {
00163       bool initMethodCalled;
00164       bool inConstruction;
00165     };
00166 
00170     QHash<QString, ObjectStatus> _object_status_map;
00171 
00175     QHash <QString, QObject *> _injector_map;
00176 
00180     QHash <QString, QPluginLoader *> _injector_loader_map;
00181   }
00182   ; // class DefaultApplicationContext
00183 
00184 }
00185 ; // namespace qic
00186 
00187 #endif