Go to the documentation of this file.
28 #ifndef _CALCIUM_GENERIC_PROVIDES_PORT_HXX_
29 #define _CALCIUM_GENERIC_PROVIDES_PORT_HXX_
31 #include <omnithread.h>
57 #define CALCIUM_GENERIC_PROVIDES_PORT_HXX(specificPortName,CorbaInterface,...) \
58 class specificPortName : public virtual CorbaInterface , \
59 public virtual POA_Ports::PortProperties, \
60 public GenericProvidesPort< __VA_ARGS__ , CalciumCouplingPolicy, calcium_provides_port > { \
62 omni_mutex _disconnect_mutex; \
63 int _mustnotdisconnect; \
65 typedef __VA_ARGS__ DataManipulator; \
66 typedef DataManipulator::Type CorbaDataType; \
67 typedef GenericPort< DataManipulator , \
68 CalciumCouplingPolicy > Port; \
69 specificPortName () : _mustnotdisconnect(0) {}; \
71 virtual ~ specificPortName (); \
73 inline void disconnect(bool provideLastGivenValue) { \
74 _disconnect_mutex.lock(); \
75 if(_mustnotdisconnect > 1) \
77 _mustnotdisconnect--; \
79 else if(_mustnotdisconnect == 1) \
81 _mustnotdisconnect--; \
82 Port::disconnect(provideLastGivenValue); \
84 _disconnect_mutex.unlock(); \
86 inline void setDependencyType(CalciumTypes::DependencyType dependencyType) { \
87 Port::setDependencyType(dependencyType); \
89 inline CalciumTypes::DependencyType getDependencyType () const { \
90 return Port::getDependencyType(); \
92 inline void setStorageLevel (size_t storageLevel) { \
93 Port::setStorageLevel(storageLevel); \
95 inline size_t getStorageLevel () const { \
96 return Port::getStorageLevel(); \
98 inline void setDateCalSchem (CalciumTypes::DateCalSchem dateCalSchem) { \
99 Port::setDateCalSchem (dateCalSchem); \
101 inline CalciumTypes::DateCalSchem getDateCalSchem () const { \
102 return Port::getDateCalSchem (); \
104 inline void setAlpha(double alpha) { \
105 Port::setAlpha(alpha); \
107 inline double getAlpha() const { \
108 return Port::getAlpha(); \
110 inline void setDeltaT(double deltaT ) { \
111 Port::setDeltaT(deltaT); \
113 inline double getDeltaT() const { \
114 return Port::getDeltaT(); \
116 inline void setInterpolationSchem (CalciumTypes::InterpolationSchem interpolationSchem) { \
117 Port::setInterpolationSchem(interpolationSchem); \
119 inline void setExtrapolationSchem (CalciumTypes::ExtrapolationSchem extrapolationSchem) { \
120 Port::setExtrapolationSchem(extrapolationSchem); \
122 inline CalciumTypes::InterpolationSchem getInterpolationSchem() const { \
123 return Port::getInterpolationSchem(); \
125 inline CalciumTypes::ExtrapolationSchem getExtrapolationSchem() const { \
126 return Port::getExtrapolationSchem(); \
129 inline void put( DataManipulator::CorbaInType data, \
130 CORBA::Double time, CORBA::Long tag) { \
131 Port::put(data, time, tag); \
134 inline Ports::Port_ptr get_port_ref() { \
138 Ports::PortProperties_ptr get_port_properties() { \
139 return POA_Ports::PortProperties::_this(); \
142 virtual void set_property(const char * name, const CORBA::Any& value) \
143 throw (Ports::NotDefined, Ports::BadType, Ports::BadValue); \
145 virtual CORBA::Any* get_property(const char* name) \
146 throw (Ports::NotDefined); \
148 virtual void provides_port_changed(int connection_nbr, \
149 const Engines::DSC::Message message) { \
150 if ( message == Engines::DSC::AddingConnection) \
152 _disconnect_mutex.lock(); \
153 _mustnotdisconnect++; \
154 _disconnect_mutex.unlock(); \
156 else if ( message == Engines::DSC::RemovingConnection ) \
162 inline void calcium_erase(float t,long i, bool before) \
170 #define CALCIUM_GENERIC_PROVIDES_PORT_CXX(specificPortName) \
172 specificPortName::~specificPortName(void) {}; \
174 void specificPortName::set_property(const char * name, const CORBA::Any& value) \
175 throw (Ports::NotDefined, Ports::BadType, Ports::BadValue) { \
177 const std::string key(name); \
179 CORBA::Double alpha,delta; \
180 Ports::Calcium_Ports::DependencyType dt; \
181 Ports::Calcium_Ports::DateCalSchem dcs; \
182 Ports::Calcium_Ports::InterpolationSchem is; \
183 Ports::Calcium_Ports::ExtrapolationSchem es; \
188 if (key == "StorageLevel" ) \
189 {if ( ( ok=(value >>= sl) ) ) Port::setStorageLevel(sl);} \
190 else if (key == "Alpha" ) \
191 {if ( ( ok=(value >>= alpha) ) ) Port::setAlpha(alpha);} \
192 else if (key == "DeltaT" ) \
193 {if ( ( ok=(value >>= delta) ) ) Port::setDeltaT(delta);} \
194 else if (key == "DependencyType" ) \
195 {if ( ( ok=( value >>= dt) ) ) Port::setDependencyType(dependencyType[dt]);} \
196 else if (key == "DateCalSchem" ) \
197 {if ( ( ok=(value >>= dcs) ) ) \
198 Port::setDateCalSchem(dateCalSchem[dcs]);} \
199 else if (key == "InterpolationSchem") \
200 {if ( ( ok=(value >>= is) ) ) \
201 Port::setInterpolationSchem(interpolationSchem[is]);} \
202 else if (key == "ExtrapolationSchem") \
203 {if ( ( ok=(value >>= es) ) ) \
204 Port::setExtrapolationSchem(extrapolationSchem[es]);} \
206 throw Ports::NotDefined(); \
207 if (!ok) throw Ports::BadType(); \
209 } catch ( const DSC_Exception & ex ) { \
211 std::cerr << ex.what() << std::endl; \
212 throw Ports::BadValue(); \
217 CORBA::Any* specificPortName::get_property(const char* name) \
218 throw (Ports::NotDefined) { \
219 const std::string key(name); \
220 CORBA::Any* value=new CORBA::Any; \
221 if (key == "StorageLevel" ) \
222 { (*value) <<= static_cast<CORBA::Long>(Port::getStorageLevel()); } \
223 else if (key == "Alpha" ) \
224 { *value <<= (CORBA::Double) Port::getAlpha();} \
225 else if (key == "DeltaT" ) \
226 { *value <<= (CORBA::Double) Port::getDeltaT();} \
227 else if (key == "DependencyType" ) \
228 { *value <<= corbaDependencyType[Port::getDependencyType()];} \
229 else if (key == "DateCalSchem" ) \
230 { *value <<= corbaDateCalSchem[Port::getDateCalSchem()];} \
231 else if (key == "InterpolationSchem") \
232 { *value <<= corbaInterpolationSchem[Port::getInterpolationSchem()];} \
233 else if (key == "ExtrapolationSchem") \
234 { *value <<= corbaExtrapolationSchem[Port::getExtrapolationSchem()];} \
237 throw Ports::NotDefined(); \