1 // Copyright (C) 2012-2015 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #ifndef __YACSEVALYFXPATTERN_HXX__
22 #define __YACSEVALYFXPATTERN_HXX__
24 #include "YACSEvalPort.hxx"
45 class YACSEvalObserver;
46 class YACSEvalListOfResources;
47 class ResourcesManager_cpp;
48 class YACSEvalYFXRunOnlyPatternInternalObserver;
50 class YACSEvalYFXPattern
53 virtual ~YACSEvalYFXPattern();
54 std::vector< YACSEvalInputPort *> getFreeInputPorts() const;
55 std::vector< YACSEvalOutputPort *> getFreeOutputPorts() const;
56 static YACSEvalYFXPattern *FindPatternFrom(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme);
57 bool isAlreadyComputedResources() const;
58 void checkNonAlreadyComputedResources() const;
59 void checkAlreadyComputedResources() const;
60 void checkLocked() const;
61 void checkNonLocked() const;
62 static void CheckNodeIsOK(YACS::ENGINE::ComposedNode *node);
63 void registerObserver(YACSEvalObserver *observer);
64 YACSEvalObserver *getObserver() const { return _observer; }
65 YACSEvalYFX *getBoss() const { return _boss; }
66 virtual void setOutPortsOfInterestForEvaluation(const std::vector<YACSEvalOutputPort *>& outputs) = 0;
67 virtual void resetOutputsOfInterest() = 0;
68 virtual void generateGraph() = 0;
69 virtual void resetGeneratedGraph() = 0;
70 virtual void assignRandomVarsInputs() = 0;
71 virtual int assignNbOfBranches() = 0;
72 virtual bool isLocked() const = 0;
73 virtual YACSEvalListOfResources *giveResources() = 0;
74 virtual YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const = 0;
75 virtual std::vector<YACSEvalSeqAny *> getResults() const = 0;
76 virtual void emitStart() const = 0;
78 static const char DFT_PROC_NAME[];
80 YACSEvalYFXPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme);
81 YACS::ENGINE::TypeCode *createSeqTypeCodeFrom(YACS::ENGINE::Proc *scheme, const std::string& zeType);
82 void setResources(YACSEvalListOfResources *res);
83 void resetResources();
84 YACSEvalListOfResources *getResourcesInternal() const { return _res; }
85 ResourcesManager_cpp *getCatalogInAppli() const { return _rm; }
86 static YACSEvalSeqAny *BuildValueInPort(YACS::ENGINE::InputPyPort *port);
92 YACS::ENGINE::Proc *_scheme;
93 ResourcesManager_cpp *_rm;
94 YACSEvalListOfResources *_res;
95 mutable YACSEvalObserver *_observer;
97 std::vector< YACSEvalInputPort > _inputs;
98 std::vector< YACSEvalOutputPort > _outputs;
101 class YACSEvalYFXRunOnlyPattern : public YACSEvalYFXPattern
104 YACSEvalYFXRunOnlyPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme, YACS::ENGINE::ComposedNode *runNode);
105 ~YACSEvalYFXRunOnlyPattern();
106 void setOutPortsOfInterestForEvaluation(const std::vector<YACSEvalOutputPort *>& outputsOfInterest);
107 void resetOutputsOfInterest();
108 void generateGraph();
109 void resetGeneratedGraph();
110 int assignNbOfBranches();
111 void assignRandomVarsInputs();
112 bool isLocked() const;
113 YACSEvalListOfResources *giveResources();
114 YACS::ENGINE::Proc *getUndergroundGeneratedGraph() const;
115 std::vector<YACSEvalSeqAny *> getResults() const;
116 void emitStart() const;
118 YACS::ENGINE::ForEachLoop *getUndergroundForEach() const { return _FEInGeneratedGraph; }
119 static bool IsMatching(YACS::ENGINE::Proc *scheme, YACS::ENGINE::ComposedNode *& runNode);
121 static const char GATHER_NODE_NAME[];
123 void buildInputPorts();
124 void buildOutputPorts();
126 YACS::ENGINE::ComposedNode *_runNode;
127 std::vector<YACSEvalOutputPort *> _outputsOfInterest;
128 YACS::ENGINE::Proc *_generatedGraph;
129 YACS::ENGINE::ForEachLoop *_FEInGeneratedGraph;
130 YACSEvalYFXRunOnlyPatternInternalObserver *_obs;