2 #ifndef SYDEVS_SYSTEMS_PORT_H_ 
    3 #define SYDEVS_SYSTEMS_PORT_H_ 
   17 template<data_mode dmode, data_goal dgoal, 
typename T>
 
   38     const std::string port_name_;
 
   39     const int64 port_index_;
 
   52 template<data_mode dmode, data_goal dgoal, 
typename T>
 
   90     const T& value() 
const;  
 
   92     void print_on_use(
bool flag = 
true) 
const;  
 
  128     bool received() 
const;   
 
  129     const T& value() 
const;  
 
  131     void print_on_use(
bool flag = 
true) 
const;  
 
  167     void send(
const T& val);  
 
  169     void print_on_use(
bool flag = 
true) 
const;  
 
  205     void assign(
const T& val);  
 
  207     void print_on_use(
bool flag = 
true) 
const;  
 
  211 template<data_mode dmode, data_goal dgoal, 
typename T>
 
  218 template<data_mode dmode, data_goal dgoal, 
typename T>
 
  225 template<data_mode dmode, data_goal dgoal, 
typename T>
 
  228     return external_interface_.node_index();
 
  232 template<data_mode dmode, data_goal dgoal, 
typename T>
 
  235     return external_interface_;
 
  239 template<data_mode dmode, data_goal dgoal, 
typename T>
 
  241     : port_name_(port_name)
 
  242     , port_index_(port_index)
 
  243     , external_interface_(external_interface)
 
  247         throw std::logic_error(
"Invalid data type for port (" + this->
port_name() + 
") " +
 
  248                                "of node (" + full_node_name + 
")");
 
  257         const_cast<
node_interface&>(external_interface).add_flow_input_port(port_name), 
 
  268         throw std::logic_error(
"Attempt to get value on flow input port (" + this->
port_name() + 
") " +
 
  269                                "of inactive node (" + full_node_name + 
")");
 
  272     return const_cast<const T&
>(val.template dereference<T>());
 
  279     auto tostring_func = flag ? tostring_converter<T>() : 
nullptr;
 
  288         const_cast<
node_interface&>(external_interface).add_message_input_port(port_name),
 
  299         throw std::logic_error(
"Attempt to check message input port (" + this->
port_name() + 
") " +
 
  300                                "of inactive node (" + full_node_name + 
")");
 
  304         throw std::logic_error(
"Attempt to check message input port (" + this->
port_name() + 
") " +
 
  305                                "of node (" + full_node_name + 
") outside of unplanned event");
 
  316         throw std::logic_error(
"Attempt to get value on message input port (" + this->
port_name() + 
") " +
 
  317                                "of inactive node (" + full_node_name + 
")");
 
  321         throw std::logic_error(
"Attempt to get value on message input port (" + this->
port_name() + 
") " +
 
  322                                "of node (" + full_node_name + 
") outside of unplanned event");
 
  326         throw std::logic_error(
"Attempt to get value on message input port (" + this->
port_name() + 
") " +
 
  327                                "of node (" + full_node_name + 
"), which was not the port that received the message.");
 
  330     return const_cast<const T&
>(val.template dereference<T>());
 
  337     auto tostring_func = flag ? tostring_converter<T>() : 
nullptr;
 
  346         const_cast<
node_interface&>(external_interface).add_message_output_port(port_name),
 
  357         throw std::logic_error(
"Attempt to send value on message output port (" + this->
port_name() + 
") " +
 
  358                                "of inactive node (" + full_node_name + 
")");
 
  362         throw std::logic_error(
"Attempt to send value on message output port (" + this->
port_name() + 
") " +
 
  363                                "of node (" + full_node_name + 
") outside of planned event");
 
  372     auto tostring_func = flag ? tostring_converter<T>() : 
nullptr;
 
  381         const_cast<
node_interface&>(external_interface).add_flow_output_port(port_name),
 
  392         throw std::logic_error(
"Attempt to assign value on flow output port (" + this->
port_name() + 
") " +
 
  393                                "of inactive node (" + full_node_name + 
")");
 
  397         throw std::logic_error(
"Attempt to assign value on flow output port (" + this->
port_name() + 
") " +
 
  398                                "of node (" + full_node_name + 
") outside of initialization or finalization event");
 
  407     auto tostring_func = flag ? tostring_converter<T>() : 
nullptr;
 
Definition: node_interface.h:17
~port()=default
Destructor.
port & operator=(port &&)=default
Move assignment.
port(port &&)=default
Move constructor.
~port()=default
Destructor.
port & operator=(port &&)=default
Move assignment.
port(port &&)=default
Move constructor.
A base class template for all port classes.
Definition: port.h:19
port_base(port_base &&)=default
Move constructor.
port_base & operator=(const port_base &)=delete
No copy assignment.
const node_interface & external_interface() const
Returns the encomassing node_interface object.
Definition: port.h:233
port_base & operator=(port_base &&)=default
Move assignment.
const std::string & port_name() const
Returns the name of the port.
Definition: port.h:212
int64 node_index() const
Returns the index of the node within the encompassing node_structure object.
Definition: port.h:226
int64 port_index() const
Returns the index of the port within the encompassing node_interface object.
Definition: port.h:219
port_base(const std::string &port_name, int64 port_index, node_interface &external_interface)
Definition: port.h:240
port_base(const port_base &)=delete
No copy constructor.
virtual ~port_base()=default
Destructor.
A generic port class template declaration.
Definition: port.h:54
const auto message
Equivalent to data_mode::message.
Definition: data_mode.h:23
const auto output
Equivalent to data_goal::output.
Definition: data_goal.h:22
const auto input
Equivalent to data_goal::input.
Definition: data_goal.h:21
const auto flow
Equivalent to data_mode::flow.
Definition: data_mode.h:22
int64_t int64
Definition: number_types.h:15
Definition: qualified_type.h:24
static pointer copy(const T &X)
If T is a qualified type, returns a deep copy of X.
Definition: qualified_type.h:174