1 #ifndef __COMPONENTINSTANCE_HXX__
2 #define __COMPONENTINSTANCE_HXX__
4 #include "RefCounter.hxx"
16 /*! \brief Base class for all component instances.
20 * This is an abstract class that must be specialized in runtime.
21 * Specialized classes must provide implementation for loading of
22 * a component (load method) unloading (unload method) and an
23 * information method (isLoaded) about the state of the component
25 * A component instance is used by one or more ServiceNode to execute
26 * services of this component instance
30 class ComponentInstance : public RefCounter
33 virtual ~ComponentInstance();
35 ComponentInstance(const std::string& name);
36 ComponentInstance(const ComponentInstance& other);
37 const std::string& getName() const { return _name; }
38 void setContainer(Container *cont);
39 Container *getContainer() const { return _container; }
40 //! Load the component instance
41 virtual void load() = 0;
42 //! Unload the component instance
43 virtual void unload() = 0;
44 //! Indicate if the component instance is loaded (true) or not
45 virtual bool isLoaded() = 0;
46 virtual void attachOnCloning() const;
47 virtual void dettachOnCloning() const;
48 bool isAttachedOnCloning() const;
50 virtual std::string getFileRepr() const;
51 virtual ServiceNode* createNode(const std::string& name)=0;
52 virtual ComponentInstance *clone() const = 0;
53 //! Return the component kind
55 * A runtime can provide several implementations of a component instance.
56 * Each implementation has a different kind. A ComponentInstance can be
57 * associated to a ServiceNode is they have the same kind.
59 virtual std::string getKind() const;
60 static const char KIND[];
62 //! \b WARNING : _name has a strong semantic. It discriminates ComponentInstance instances each other.
64 Container *_container;
65 mutable bool _isAttachedOnCloning;
67 static const char NULL_FILE_REPR[];