the multi property on the service is used.
interface Superv_Component : Engines::DSC {
//! Operation to create the service ports before it is executed
- /*!
- The SUPERV module call this method before starting the service. Thus the service
+ /*!
+ YACS module call this method before starting the service. Thus the service
can add its dynamics ports before it is started.
\param service_name service's name.
\return true if the service is correctly initialised.
*/
boolean init_service(in string service_name);
+
+ struct multiple_param {
+ string name;
+ long number;
+ };
+
+ typedef sequence<multiple_param> seq_multiple_param;
+
+ /*!
+ YACS module call this method before starting the service. Thus the service
+ can add its dynamics ports before it is started.
+ This method is also used by YACS to specify for each datastream port (name in multiple_param)
+ how many the service should create a datastream port.
+
+ For a defined port named: in_data_port, the service should create ports with the names:
+ in_data_port_0, in_data_port_1, ...
+ */
+ boolean init_service_with_multiple(in string service_name, in seq_multiple_param params);
};
};
#include <sstream>
#include <string>
#include <exception>
+#include <cstring>
PySupervCompo::PySupervCompo( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
}
}
+ char** create_multiple_calcium_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend, int number)
+ {
+ if (number <= 0)
+ {
+ std::cerr << "Cannot create a multiple calcium port with number <= 0, value is " << number << std::endl;
+ return NULL;
+ }
+ char** names = new char*[number];
+ for (int i = 0; i < number; i++)
+ {
+ std::ostringstream new_name;
+ new_name << name << "_" << i;
+ std::string cpp_name = new_name.str();
+ char * c_name = new char [cpp_name.size()+1];
+ strcpy(c_name, cpp_name.c_str());
+ names[i] = c_name;
+ }
+
+ // Create ports
+ for (int i = 0; i < number; i++)
+ {
+ create_calcium_port(compo, (char*)std::string(names[i]).c_str(), type, mode, depend);
+ }
+
+ return names;
+ }
+
}
bool notif = false);
virtual ~PySupervCompo();
CORBA::Boolean init_service(const char * service_name){return true;};
+ CORBA::Boolean init_service_with_multiple(const char* service_name,
+ const Engines::Superv_Component::seq_multiple_param & params)
+ {
+ return true;
+ }
};
extern "C" void create_calcium_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend);
+
+// This method permits to help a service developer to create multiple calcium ports
+extern "C" char** create_multiple_calcium_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend, int number);
static void setTimeOut();
void beginService(const char *serviceName);
-private:
+
+ // This method is implemented by default since it is a very specific usage.
+ // It also permits to not break compatibility with older components.
+ virtual CORBA::Boolean init_service_with_multiple(const char* service_name,
+ const Engines::Superv_Component::seq_multiple_param & params)
+ {
+ return true;
+ }
+
+private:
// Factory map
typedef std::map<std::string, port_factory*> factory_map_t;
static factory_map_t _factory_map;