Salome HOME
First implementation of evalyfx.
[modules/yacs.git] / src / evalyfx / YACSEvalYFXPattern.hxx
1 // Copyright (C) 2012-2015  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 // Author : Anthony Geay (EDF R&D)
20
21 #ifndef __YACSEVALYFXPATTERN_HXX__
22 #define __YACSEVALYFXPATTERN_HXX__
23
24 #include "YACSEvalPort.hxx"
25
26 #include <list>
27 #include <vector>
28
29 namespace YACS
30 {
31   namespace ENGINE
32   {
33     class Proc;
34     class TypeCode;
35     class ComposedNode;
36     class InputPyPort;
37   }
38 }
39
40 class YACSEvalListOfResources;
41 class ResourcesManager_cpp;
42
43 class YACSEvalYFXPattern
44 {
45 public:
46   virtual ~YACSEvalYFXPattern();
47   std::list< YACSEvalInputPort *> getFreeInputPorts() const;
48   std::list< YACSEvalOutputPort *> getFreeOutputPorts() const;
49   static YACSEvalYFXPattern *FindPatternFrom(YACS::ENGINE::Proc *scheme, bool ownScheme);
50   bool isAlreadyComputedResources() const;
51   void checkNonAlreadyComputedResources() const;
52   void checkAlreadyComputedResources() const;
53   void checkLocked() const;
54   void checkNonLocked() const;
55   static void CheckNodeIsOK(YACS::ENGINE::ComposedNode *node);
56   virtual void setOutPortsOfInterestForEvaluation(std::size_t commonSize, const std::list<YACSEvalOutputPort *>& outputs) = 0;
57   virtual void resetOutputsOfInterest() = 0;
58   virtual void generateGraph() = 0;
59   virtual void resetGeneratedGraph() = 0;
60   virtual int assignNbOfBranches() = 0;
61   virtual bool isLocked() const = 0;
62   virtual YACSEvalListOfResources *giveResources() = 0;
63   virtual YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const = 0;
64   virtual std::vector<YACSEvalSeqAny *> getResults() const = 0;
65 public:
66   static const char DFT_PROC_NAME[];
67 protected:
68   YACSEvalYFXPattern(YACS::ENGINE::Proc *scheme, bool ownScheme);
69   YACS::ENGINE::TypeCode *createSeqTypeCodeFrom(YACS::ENGINE::Proc *scheme, const std::string& zeType);
70   void setResources(YACSEvalListOfResources *res);
71   void resetResources();
72   YACSEvalListOfResources *getResourcesInternal() const { return _res; }
73   ResourcesManager_cpp *getCatalogInAppli() const { return _rm; }
74   static YACSEvalSeqAny *BuildValueInPort(YACS::ENGINE::InputPyPort *port);
75 private:
76   void cleanScheme();
77 private:
78   bool _ownScheme;
79   YACS::ENGINE::Proc *_scheme;
80   ResourcesManager_cpp *_rm;
81   YACSEvalListOfResources *_res;
82 protected:
83   std::list< YACSEvalInputPort > _inputs;
84   std::list< YACSEvalOutputPort > _outputs;
85 };
86
87 class YACSEvalYFXRunOnlyPattern : public YACSEvalYFXPattern
88 {
89 public:
90   YACSEvalYFXRunOnlyPattern(YACS::ENGINE::Proc *scheme, bool ownScheme, YACS::ENGINE::ComposedNode *runNode);
91   void setOutPortsOfInterestForEvaluation(std::size_t commonSize, const std::list<YACSEvalOutputPort *>& outputsOfInterest);
92   void resetOutputsOfInterest();
93   void generateGraph();
94   void resetGeneratedGraph();
95   int assignNbOfBranches();
96   bool isLocked() const;
97   YACSEvalListOfResources *giveResources();
98   YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const;
99   std::vector<YACSEvalSeqAny *> getResults() const;
100   static bool IsMatching(YACS::ENGINE::Proc *scheme, YACS::ENGINE::ComposedNode *& runNode);
101 public:
102   static const char GATHER_NODE_NAME[];
103 private:
104   void buildInputPorts();
105   void buildOutputPorts();
106 private:
107   YACS::ENGINE::ComposedNode *_runNode;
108   std::size_t _commonSz;
109   std::list<YACSEvalOutputPort *> _outputsOfInterest;
110   YACS::ENGINE::Proc *_generatedGraph;
111 };
112
113 #endif