Salome HOME
015f39920f73715b4f189a90d437c84139433380
[modules/yacs.git] / src / engine / ComponentInstance.hxx
1 // Copyright (C) 2006-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __COMPONENTINSTANCE_HXX__
21 #define __COMPONENTINSTANCE_HXX__
22
23 #include "YACSlibEngineExport.hxx"
24 #include "RefCounter.hxx"
25 #include "PropertyInterface.hxx"
26
27 #include <list>
28 #include <string>
29
30 namespace YACS
31 {
32   namespace ENGINE
33   {
34     class Task;
35     class ServiceNode;
36     class Container;
37
38     class YACSLIBENGINE_EXPORT ComponentInstance : public PropertyInterface, public RefCounter
39     {
40     protected:
41       virtual ~ComponentInstance();
42     public:
43       ComponentInstance(const std::string& name);
44       ComponentInstance(const ComponentInstance& other);
45       const std::string& getCompoName() const { return _compoName; }
46       const std::string& getInstanceName() const { return _instanceName; }
47       void setName(const std::string& name) { _instanceName = name; };
48       virtual void setAnonymous(bool anon) { _anonymous = anon; };
49       virtual bool isAnonymous() { return _anonymous; };
50       int getNumId() const { return _numId; }
51       virtual bool setContainer(Container *cont);
52       Container *getContainer() const { return _container; }
53 //! Load the component instance
54       virtual void load(Task *askingNode) = 0;
55 //! Unload the component instance
56       virtual void unload(Task *askingNode) = 0;
57 //! Indicate if the component instance is loaded (true) or not
58       virtual bool isLoaded(Task *askingNode) const = 0;
59       virtual void attachOnCloning() const;
60       virtual void dettachOnCloning() const;
61       bool isAttachedOnCloning() const;
62       virtual std::string getFileRepr() const;
63       virtual ServiceNode* createNode(const std::string& name)=0;
64       virtual ComponentInstance *clone() const = 0;
65       virtual ComponentInstance *cloneAlways() const = 0;
66       virtual std::string getKind() const;
67       virtual std::string getKindForNode() const;
68       static const char KIND[];
69       virtual void shutdown(int level);
70     protected:
71       //! \b WARNING : _compoName identify only the component type.
72       std::string _compoName;
73       //! \b WARNING : _InstanceName has a strong semantic. It discriminates ComponentInstance instances each other.
74       std::string _instanceName;
75       int _numId;
76       Container *_container;
77       mutable bool _isAttachedOnCloning;
78     protected:
79       static const char NULL_FILE_REPR[];
80       static int _total;
81       bool _anonymous;
82     };
83   }
84 }
85
86 #endif