Socket System

The socket system supports input and output data ports, called sink and source sockets, respectively. ViennaX automatically handles the dependencies and ensures that the available source sockets are linked to the corresponding sink sockets. In general, the data associated to the sockets can either be already available, thus no copying is required, or it can be generated automatically during the course of the socket creation. The following user-level code snippet depicts the basic utilization of source sockets. Note that the sink sockets are handled similarily.


Utilization of source sockets
  1. void configure(std::size_t pid, std::string const& configstr)
  2. {
  3. // A data object is automatically created
  4. // Requires the type to be default-constructible
  5. create_source<double>("x");
  6. // Already instantiated objects can also be used
  7. double y;
  8. link_source(y, "y");
  9. }
  11. bool execute(std::size_t pid, std::size_t call)
  12. {
  13. // Accessing the socket-associated data objects
  14. double& x = access_source<double>("x");
  15. double& y = access_source<double>("y");
  16. return true;
  17. }