Salome HOME
updated copyright message
[modules/yacs.git] / src / hmi / guiContext.hxx
1 // Copyright (C) 2006-2023  CEA/DEN, EDF R&D
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 _GUICONTEXT_HXX_
21 #define _GUICONTEXT_HXX_
22
23 #include "HMIExport.hxx"
24 #include "Proc.hxx"
25 #include "Catalog.hxx"
26 #include "commandsProc.hxx"
27 #include "guiObservers.hxx"
28
29 #include <map>
30 #include <string>
31
32 namespace YACS
33 {
34   namespace HMI
35   {
36
37     class HMI_EXPORT GuiContext: public Subject
38     {
39     public:
40       GuiContext();
41       virtual ~GuiContext();
42       virtual void setProc(YACS::ENGINE::Proc* proc);
43       long getNewId(YACS::HMI::TypeOfElem type);
44
45       inline YACS::ENGINE::Catalog* getBuiltinCatalog()        {return _builtinCatalog; };
46       inline YACS::ENGINE::Catalog* getSessionCatalog()        {return _sessionCatalog; };
47       inline YACS::ENGINE::Catalog* getProcCatalog()           {return _procCatalog; };
48       inline YACS::ENGINE::Catalog* getCurrentCatalog()        {return _currentCatalog; };
49
50       inline YACS::ENGINE::Proc* getProc()                     {return _proc; };
51       inline YACS::HMI::ProcInvoc* getInvoc()                  {return _invoc; };
52       inline YACS::HMI::SubjectProc* getSubjectProc()          {return _subjectProc; };
53       inline long getNewId()                                   {return _numItem++; };
54       inline std::string getXMLSchema()                        {return _xmlSchema; };
55       inline std::pair<std::string, std::string> getYACSCont() {return _YACSEngineContainer; }
56       inline bool isNotSaved()                                 {return _isNotSaved; };
57       inline bool isLoading()                                  {return _isLoading; };
58
59       inline void setSessionCatalog(YACS::ENGINE::Catalog* cata)           {_sessionCatalog = cata; };
60       inline void setProcCatalog(YACS::ENGINE::Catalog* cata)              {_procCatalog = cata; };
61       inline void setCurrentCatalog(YACS::ENGINE::Catalog* cata)           {_currentCatalog = cata; };
62       inline void setXMLSchema(std::string xmlSchema)                      {_xmlSchema = xmlSchema; };
63       inline void setYACSContainer(std::pair<std::string, std::string> yc) {_YACSEngineContainer = yc; };
64       inline void setNotSaved(bool isNotSaved)                             {_isNotSaved = isNotSaved; };
65       inline void setLoading(bool isLoading)                               {_isLoading = isLoading; };
66
67       inline static GuiContext* getCurrent()             {return _current; };
68       inline static void setCurrent(GuiContext* context) { _current=context; };
69
70       std::map<YACS::ENGINE::Node*,YACS::HMI::SubjectNode*>                                        _mapOfSubjectNode;
71       std::map<YACS::ENGINE::DataPort*,YACS::HMI::SubjectDataPort*>                                _mapOfSubjectDataPort;
72       std::map<std::pair<YACS::ENGINE::OutPort*, YACS::ENGINE::InPort*>,YACS::HMI::SubjectLink*>   _mapOfSubjectLink;
73       std::map<std::pair<YACS::ENGINE::Node*, YACS::ENGINE::Node*>,YACS::HMI::SubjectControlLink*> _mapOfSubjectControlLink;
74       std::map<YACS::ENGINE::ComponentInstance*, YACS::HMI::SubjectComponent*>                     _mapOfSubjectComponent;
75       std::map<YACS::ENGINE::Container*, YACS::HMI::SubjectContainerBase*>                         _mapOfSubjectContainer;
76       std::map<std::string, YACS::HMI::SubjectDataType*>                                           _mapOfSubjectDataType;
77       std::map<int,YACS::HMI::SubjectNode*>                                                        _mapOfExecSubjectNode;
78       std::map<std::string, YACS::ENGINE::ComponentInstance*>                                      _mapOfLastComponentInstance;
79       std::string _lastErrorMessage;
80
81     protected:
82       YACS::ENGINE::Catalog* _builtinCatalog;
83       YACS::ENGINE::Catalog* _sessionCatalog;
84       YACS::ENGINE::Catalog* _procCatalog;
85       YACS::ENGINE::Catalog* _currentCatalog;
86       YACS::ENGINE::Proc* _proc;
87       YACS::HMI::ProcInvoc* _invoc;
88       YACS::HMI::SubjectProc *_subjectProc;
89       long _numItem;
90       bool _isNotSaved;
91       bool _isLoading;
92       static GuiContext* _current;
93       std::string _xmlSchema;
94       std::pair<std::string, std::string> _YACSEngineContainer; // --- <ContainerName, HostName>
95
96     };
97   }
98 }
99 #endif