SEAL Component Model ROOT/CORE Meeting 8 April 2005 P. Mato / CERN
Component Model Overview � A way of resolving software complexity � A generic set of software building blocks – components , services � Exposing well defined interface(s) – contract , protocol � Easily configurable – properties � Assembled via generic infrastructure – contexts , scopes � Compile-time and/or run-time – static and/or dynamic binding � Easy deployment based on plug-n-play architecture – plug-ins 8 April 2005 SEAL Component Model P. Mato/CERN 2
3. Component Model � Hierarchy of bases classes to Component support the component model Factory � Provide standard functionality – Loading, instantiation, configuration, Component lifetime management,… RefCounted Loader � Each Component is in a Context � Tree of Contexts � Support for locating components * Component – If not in local context, look in parent � A Service provides its own local 1 Context 1 Service Context – Components of a Service are scoped in its own Context * � User classes inherit from Component or Service – Plug-in functionality for free MyComponent MyService 8 April 2005 SEAL Component Model P. Mato/CERN 3
Context Hierarchy Context Application C1 C1 C2 C1 C5 C1 Svc1 Svc2 C3 C1 C4 C1 C6 C1 C7 C1 Svc1 Component C7 C1 Service � Any Component may attempt to locate another Component in the running application (collaboration network) – By “type” or by “key” – If the not found in the current context, the parent context is searched is recursively 8 April 2005 SEAL Component Model P. Mato/CERN 4
Component Model: How-To (1) #ifndef MYCOMPONENT_H MyComponent.h #define MYCOMPONENT_H 1 #include "SealKernel/Component.h“ class MyComponent : public seal::Component{ DECLARE_SEAL_COMPONENT; public: MyComponent (seal::Context* context, const std::string & label); // implicit copy constructor // implicit assignment operator // implicit destructor //.....component member functions.. void doSomething(); }; #endif // MYCOMPONENT_H 8 April 2005 SEAL Component Model P. Mato/CERN 5
Component Model: How-To (2) MyComponent.cpp #include "MyComponent.h“ #include <iostream> DEFINE_SEAL_COMPONENT (MyComponent, “example/MyComponent"); MyComponent::MyComponent (seal::Context* context, const std::string & label) : Component (context, label){} // member function implementations void MyComponent::doSomething() { std::cout << "MyComponent: Hello World ! " << std::endl; } #include "MyComponent.h“ Module.cpp #include "SealKernel/ComponentFactory.h“ #include "PluginManager/ModuleDef.h“ DEFINE_SEAL_MODULE (); DEFINE_SEAL_PLUGIN (seal::ComponentFactory, MyComponent, MyComponent::classContextLabel ()); 8 April 2005 SEAL Component Model P. Mato/CERN 6
Component Look-up OtherComponent.cpp #include “SealKernel/ComponentLoader.h” #include “MyComponent.h” Handle<MyComponent> handle = component<MyComponent>(); Application AppContext handle->doSomething(); 2 1 2 3 4 5 Component1 “example/MyComponent” Component1 “example/MyComponent2” #include “SealKernel/ComponentLoader.h” #include “MyComponent.h” Svc2Context Svc2 1 1 … … 42 43 Handle<MyComponent> handle = component<MyComponent>(“example/MyComponent”); Component7 handle->doSomething(); 8 April 2005 SEAL Component Model P. Mato/CERN 7
Existing Services � Application – Defines the top level Context – Possibility to set the initial set of Components to be loaded in the application � Message Service – Message composition, filtering and reporting – Closely related to MessageStream � Configuration Service – Management of Component properties and loading configurations – Multiple backends foreseen: » Gaudi style options(current),.INI style, CMS style, XML,… � Dictionary Service – Enables automatic loading of SEAL C++ reflection dictionaries simply by specifying a C++ type name 8 April 2005 SEAL Component Model P. Mato/CERN 8
Equivalence in ROOT � Similar functionality exists in ROOT with the use of global variables – Scoped lookups missing #include “TROOT.h” #include “TGlobal.h” #include “MyComponent.” MyComponent* handle = (MyComponent*)(gROOT->GetGlobal(“gMyComponent”).GetAddress()); handle->doSomething(); 8 April 2005 SEAL Component Model P. Mato/CERN 9
Recommend
More recommend