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