1 #include "CalStreamPort.hxx"
2 #include "SalomeComponent.hxx"
3 #include "CORBANode.hxx"
7 #include "YacsTrace.hxx"
9 using namespace YACS::ENGINE;
12 const char InputCalStreamPort::NAME[]="InputCalStreamPort";
14 InputCalStreamPort::InputCalStreamPort(const std::string& name, Node *node, TypeCode* type):
15 InputDataStreamPort(name, node, type),
16 DataPort(name, node, type),
17 Port(node),_depend("T"),_schema("TI"),_delta(0.),_level(-1)
20 InputCalStreamPort::InputCalStreamPort(const InputCalStreamPort& other, Node *newHelder):
21 InputDataStreamPort(other,newHelder),
22 DataPort(other,newHelder),
23 Port(other,newHelder),_depend(other._depend),_schema(other._schema),_delta(other._delta),_level(other._level)
27 InputCalStreamPort::~InputCalStreamPort()
31 void InputCalStreamPort::setDepend(const std::string& depend)
33 DEBTRACE("InputCalStreamPort::setDepend: " << edGetNumberOfLinks());
34 if(edGetNumberOfLinks() > 0)
36 throw Exception("Can not modify depend parameter on a connected port");
38 if(depend != "T" && depend != "I")
40 throw Exception("depend parameter must be T or I");
45 void InputCalStreamPort::setSchema(const std::string& schema)
47 if(schema != "TI" && schema != "TF" && schema != "DELTA")
49 throw Exception("schema parameter must be TI, TF or DELTA");
53 void InputCalStreamPort::setLevel(const std::string& level)
55 _level =atoi(level.c_str());
58 void InputCalStreamPort::setProperty(const std::string& name, const std::string& value)
62 else if(name == "schema")
64 else if(name == "level")
66 InputDataStreamPort::setProperty(name,value);
70 void InputCalStreamPort::initPortProperties()
76 CORBA::Object_var objComponent=((SalomeComponent*)((SalomeNode*)_node)->getComponent())->getCompoPtr();
77 Engines::Superv_Component_var compo=Engines::Superv_Component::_narrow(objComponent);
78 Ports::PortProperties_var port_properties=compo->get_port_properties(getName().c_str());
80 a <<= (CORBA::Long)_level;
83 port_properties->set_property("StorageLevel",a);
85 catch(Ports::NotDefined& ex)
87 throw Exception("Property StorageLevel not defined on that port: "+getName());
93 std::string InputCalStreamPort::getNameOfTypeOfCurrentInstance() const
98 InputCalStreamPort *InputCalStreamPort::clone(Node *newHelder) const
100 return new InputCalStreamPort(*this,newHelder);
103 const char OutputCalStreamPort::NAME[]="OutputCalStreamPort";
105 OutputCalStreamPort::OutputCalStreamPort(const std::string& name, Node *node, TypeCode* type):
106 OutputDataStreamPort(name, node, type),
107 DataPort(name, node, type),
108 Port(node),_depend("T")
112 OutputCalStreamPort::OutputCalStreamPort(const OutputCalStreamPort& other, Node *newHelder):
113 OutputDataStreamPort(other,newHelder),
114 DataPort(other,newHelder),
115 Port(other,newHelder),
116 _depend(other._depend)
120 OutputCalStreamPort::~OutputCalStreamPort()
124 void OutputCalStreamPort::setDepend(const std::string& depend)
126 DEBTRACE("OutputCalStreamPort::setDepend: " << edGetNumberOfOutLinks());
127 if(edGetNumberOfOutLinks() > 0)
129 throw Exception("Can not modify depend parameter on a connected port");
131 if(depend != "T" && depend != "I" )
133 throw Exception("depend parameter must be T or I");
138 void OutputCalStreamPort::setSchema(const std::string& schema)
140 if(schema != "TI" && schema != "TF" && schema != "DELTA")
142 throw Exception("schema parameter must be TI, TF or DELTA");
146 void OutputCalStreamPort::setLevel(const std::string& level)
148 _level =atoi(level.c_str());
151 void OutputCalStreamPort::setProperty(const std::string& name, const std::string& value)
155 else if(name == "schema")
157 else if(name == "level")
159 OutputDataStreamPort::setProperty(name,value);
162 std::string OutputCalStreamPort::getNameOfTypeOfCurrentInstance() const
167 OutputCalStreamPort *OutputCalStreamPort::clone(Node *newHelder) const
169 return new OutputCalStreamPort(*this,newHelder);
172 bool OutputCalStreamPort::addInPort(InPort *inPort) throw(Exception)
174 DEBTRACE("OutputCalStreamPort::addInPort " << InputCalStreamPort::NAME );
175 if(inPort->getNameOfTypeOfCurrentInstance()!=InputCalStreamPort::NAME)
177 string what="not compatible type of port requested during building of link FROM ";
178 what+=NAME; what+=" TO "; what+=inPort->getNameOfTypeOfCurrentInstance();
179 throw Exception(what);
182 InputCalStreamPort* port=static_cast<InputCalStreamPort*>(inPort);
183 if(port->getDepend() != _depend)
185 std::string what= "incompatible depend parameters: "+_depend+" != "+ port->getDepend();
186 throw Exception(what);
189 ret= edAddInputDataStreamPort(port);
194 int OutputCalStreamPort::removeInPort(InPort *inPort, bool forward) throw(Exception)
196 DEBTRACE("OutputCalStreamPort::removeInPort");
197 if(inPort->getNameOfTypeOfCurrentInstance()!=InputCalStreamPort::NAME && !forward)
199 string what="not compatible type of port requested during destruction of for link FROM ";
200 what+=NAME; what+=" TO "; what+=inPort->getNameOfTypeOfCurrentInstance();
201 throw Exception(what);
203 return edRemoveInputDataStreamPort(static_cast<InputDataStreamPort *>(inPort),forward);