27 #ifndef _CALCIUM_CXXINTERFACE_HXX_
28 #define _CALCIUM_CXXINTERFACE_HXX_
30 #if defined(__CONST_H) || defined(__CALCIUM_H)
31 #error "The header CalciumCxxInterface.hxx must be included before calcium.h"
49 template <
typename T1,
typename T2>
51 static const bool value =
false;
53 template <
typename T1>
62 #include <boost/type_traits/remove_all_extents.hpp>
64 namespace CalciumInterface {
72 CORBA::String_var componentName=component.
instanceName();
74 if (instanceName.empty()) instanceName=componentName;
81 CORBA::String_var componentName=component.
instanceName();
85 std::vector<std::string> usesPortNames;
86 std::vector<std::string>::const_iterator it;
95 for (it=usesPortNames.begin(); it != usesPortNames.end(); ++it)
99 myCalciumUsesPort= component.Superv_Component_i::get_port<
calcium_uses_port >((*it).c_str());
106 std::cerr <<
"-------- CalciumInterface(ecp_fin) MARK 1 -|"<< *it <<
"|----"<<
108 typeid(myCalciumUsesPort).name() <<
"-------------" << std::endl;
115 myCalciumUsesPort->
disconnect(provideLastGivenValue);
147 template <
typename T1,
typename T2>
static void
151 typedef typename PortType::DataManipulator DataManipulator;
152 typedef typename DataManipulator::Type
DataType;
153 typedef typename DataManipulator::InnerType InnerType;
158 template <
typename T1>
static void
161 ecp_free<T1,T1> ( dataPtr );
173 template <
typename T1,
typename T2 >
static void
179 const std::string & nomVar,
186 CORBA::String_var componentName=component.
instanceName();
190 typedef typename PortType::DataManipulator DataManipulator;
191 typedef typename DataManipulator::Type CorbaDataType;
192 typedef typename DataManipulator::InnerType InnerType;
196 CorbaDataType corbaData;
199 std::cerr <<
"-------- CalciumInterface(ecp_lecture) MARK 1 ------------------" << std::endl;
209 std::cout <<
"-------- CalciumInterface(lecture) MARK 2 --"<<
typeid(port).name()<<
"----------------" << std::endl;
212 std::cout <<
"-------- CalciumInterface(lecture) MARK 2b1 -----" <<
typeid(t1).name() <<
"-------------" << std::endl;
213 std::cout <<
"-------- CalciumInterface(lecture) MARK 2b2 -----" <<
typeid(t2).name() <<
"-------------" << std::endl;
218 port = component.Superv_Component_i::get_port< PortType > (nomVar.c_str());
220 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 3 ------------------" << std::endl;
252 "Dependency mode is not the same as the required one");
254 << portDependencyType <<
" is not the same as the required one."));
258 std::stringstream msgout,msg;
264 msg <<
"ti=" << ti <<
", tf=" << tf ;
266 corbaData = port->get(tt,tf, 0);
267 msgout <<
"read t=" << tt ;
269 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 5 ------------------" << std::endl;
284 corbaData = port->get(0, i);
285 msgout <<
"read i=" << i ;
287 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 6 ------------------" << std::endl;
302 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 7 ------------------" << std::endl;
305 corbaData = port->next(ti,i);
307 if(i==0)msgout<<
"t=" <<ti;
308 else msgout<<
"i=" <<i;
318 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 8 ------------------" << std::endl;
320 size_t corbaDataSize = DataManipulator::size(corbaData);
322 std::cout <<
"-------- CalciumInterface(ecp_lecture) corbaDataSize : " << corbaDataSize << std::endl;
328 if ( bufferLength != 0 )
330 MESSAGE(
"bufferLength devrait valoir 0 pour l'utilisation du mode sans copie (data==NULL)");
332 nRead = corbaDataSize;
336 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 9 ------------------" << std::endl;
348 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 10 ------------------" << std::endl;
363 nRead = std::min < size_t > (corbaDataSize,bufferLength);
365 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 11 ------------------" << std::endl;
371 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 12 ------------------" << std::endl;
375 std::cout <<
"-------- CalciumInterface(ecp_lecture), Valeur de data : " << std::endl;
376 std::copy(data,data+nRead,std::ostream_iterator<T1>(std::cout,
" "));
377 std::cout <<
"Ptr :" << data << std::endl;
378 std::cout <<
"-------- CalciumInterface(ecp_lecture) MARK 13 ------------------" << std::endl;
385 template <
typename T1 >
static void
391 const std::string & nomVar,
397 i,nomVar,bufferLength,nRead,data);
405 template <
typename T1,
typename T2>
static void
410 const std::string & nomVar,
416 CORBA::String_var componentName=component.
instanceName();
420 typedef typename boost::remove_all_extents< T1 >::type T1_without_extent;
421 typedef typename boost::remove_all_extents< T2 >::type T2_without_extent;
424 typedef typename ProvidesPortType::DataManipulator DataManipulator;
427 typedef typename DataManipulator::Type CorbaDataType;
428 typedef typename DataManipulator::InnerType InnerType;
430 T1_without_extent
const & _data = data;
436 std::cerr <<
"-------- CalciumInterface(ecriture) MARK 1 ------------------" << std::endl;
438 if ( nomVar.empty() )
445 std::cout <<
"-------- CalciumInterface(ecriture) MARK 2 ---"<<
typeid(port).name()<<
"---------------" << std::endl;
448 std::cout <<
"-------- CalciumInterface(ecriture) MARK 2b1 -----" <<
typeid(t1).name() <<
"-------------" << std::endl;
449 std::cout <<
"-------- CalciumInterface(ecriture) MARK 2b2 -----" <<
typeid(t2).name() <<
"-------------" << std::endl;
454 port = component.Superv_Component_i::get_port< UsesPortType > (nomVar.c_str());
456 std::cout <<
"-------- CalciumInterface(ecriture) MARK 3 ------------------" << std::endl;
498 "SEQUENCE_DEPENDENCY mode is not possible when writing");
500 <<
" is not possible when writing."));
514 if ( bufferLength < 1 )
520 CorbaDataType corbaData;
522 std::cout <<
"-------- CalciumInterface(ecriture) MARK 4 ------------------" << std::endl;
546 T1_without_extent t1b;
548 std::cout <<
"-------- CalciumInterface(ecriture) MARK 4b1 -----" <<
typeid(t1b).name() <<
"-------------" << std::endl;
549 std::cout <<
"-------- CalciumInterface(ecriture) MARK 4b2 -----" <<
typeid(t2b).name() <<
"-------------" << std::endl;
559 port->put(*corbaData,t, -1);
560 std::stringstream msg;
572 std::cout <<
"-------- CalciumInterface(ecriture) MARK 5 ------------------" << std::endl;
579 port->put(*corbaData,-1, i);
580 std::stringstream msg;
590 std::cout <<
"-------- CalciumInterface(ecriture) MARK 6 ------------------" << std::endl;
595 std::cout <<
"-------- CalciumInterface(ecriture), Valeur de corbaData : " << std::endl;
596 for (
int i = 0; i < corbaData->length(); ++i)
597 std::cout <<
"-------- CalciumInterface(ecriture), corbaData[" << i <<
"] = " << (*corbaData)[i] << std::endl;
605 std::cout <<
"-------- CalciumInterface(ecriture) MARK 7 ------------------" << std::endl;
611 template <
typename T1>
static void
616 const std::string & nomVar,
620 ecp_ecriture<T1,T1> (component,
dependencyType,t,i,nomVar,bufferLength,data);
626 CORBA::String_var componentName=component.
instanceName();
669 "Dependency mode must be iteration mode");
671 << portDependencyType <<
" must be iteration mode."));
676 std::stringstream msg;
685 CORBA::String_var componentName=component.
instanceName();
728 "Dependency mode must be time mode");
730 << portDependencyType <<
" must be time mode."));
735 std::stringstream msg;
744 CORBA::String_var componentName=component.
instanceName();
787 "Dependency mode must be iteration mode");
789 << portDependencyType <<
" must be iteration mode."));
794 std::stringstream msg;
803 CORBA::String_var componentName=component.
instanceName();
846 "Dependency mode must be time mode");
848 << portDependencyType <<
" must be time mode."));
853 std::stringstream msg;