Salome HOME
4ffc1227353708c8540ca20e9161a14f919cf8ab
[modules/yacs.git] / src / engine / ComponentInstance.hxx
1 #ifndef __COMPONENTINSTANCE_HXX__
2 #define __COMPONENTINSTANCE_HXX__
3
4 #include "RefCounter.hxx"
5
6 #include <list>
7 #include <string>
8
9 namespace YACS
10 {
11   namespace ENGINE
12   {
13     class Container;
14     class ServiceNode;
15
16 /*! \brief Base class for all component instances.
17  *
18  * \ingroup Nodes
19  *
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
24  *
25  * A component instance is used by one or more ServiceNode to execute
26  * services of this component instance
27  *
28  * \see ServiceNode
29  */
30     class ComponentInstance : public RefCounter
31     {
32     protected:
33       virtual ~ComponentInstance();
34     public:
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;
49 //! For dump in file
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
54 /*!
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.
58  */
59       virtual std::string getKind() const;
60       static const char KIND[];
61     protected:
62       //! \b WARNING : _name has a strong semantic. It discriminates ComponentInstance instances each other.
63       std::string _name;
64       Container *_container;
65       mutable bool _isAttachedOnCloning;
66     protected:
67       static const char NULL_FILE_REPR[];
68     };
69   }
70 }
71
72 #endif