#ifndef _BIP_Engine_Port_HPP_
#define _BIP_Engine_Port_HPP_

// inherited classes
#include <PortItf.hpp>

class PortValue;
class BipError;
class Connector;

class Port : public virtual PortItf {
 public:
  // constructors
  Port(const string &name, const PortType &type);

  // destructor
  virtual ~Port();


  /**
   * \brief Performs the update of the port when it is involved in the executed
   * interaction.
   */
  virtual BipError &execute(PortValue& portValue) = 0;

  void addConnectedConnector(Connector &connector) { mConnectedConnectors.push_back(&connector); }
  void addConnectedPort(Port &port) { mConnectedPorts.push_back(&port); }
  void reset();
  void resetConnectedConnectors();
  void resetConnectedPorts();

  bool isReset() const { return mIsReset; }
  void setIsReset(bool b) { mIsReset = b; }

 protected:
  const vector<Connector *> &connectedConnectors() const { return mConnectedConnectors; }
  const vector<Port *> &connectedPorts() const { return mConnectedPorts; }

  vector<Connector *> mConnectedConnectors;
  vector<Port *> mConnectedPorts;

  bool mIsReset;
};

#endif // _BIP_Engine_Port_HPP_
