FREEDM DGI
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
freedm::broker::IProtocol Class Referenceabstract

A connection protocol.

#include <IProtocol.hpp>

Inheritance diagram for freedm::broker::IProtocol:
freedm::broker::CProtocolSR

Public Member Functions

virtual ~IProtocol ()
 Destroy all humans. More...
 
virtual void ChangePhase (bool)
 Handles the change phase even. More...
 
int GetReliability () const
 Get the connection reliability for DCUSTOMNETWORK. More...
 
boost::asio::ip::udp::socket & GetSocket ()
 Get a socket connected to a single peer DGI. More...
 
bool GetStopped ()
 Handles checking to see if the connection is stopped. More...
 
std::string GetUUID () const
 Gets the uuid: More...
 
virtual void OnReceive ()=0
 Peforms an actions after finishing looking through a sliding window. More...
 
virtual bool Receive (const ProtocolMessage &msg)=0
 Function that determines if a message should dispatched. More...
 
virtual void ReceiveACK (const ProtocolMessage &msg)=0
 Public facing function that handles marking ACKS. More...
 
virtual void Send (const ModuleMessage &msg)=0
 Public write to channel function. More...
 
virtual void SendACK (const ProtocolMessage &msg)=0
 Handles Writing an ack for the input message to the channel. More...
 
void SetReliability (int r)
 Set the connection reliability for DCUSTOMNETWORK. More...
 
void SetStopped (bool v)
 Handles setting the stopped variable. More...
 
virtual void Stop ()=0
 Handles Stopping the timers etc. More...
 

Protected Member Functions

 IProtocol (std::string uuid, boost::asio::ip::udp::endpoint endpoint)
 Initializes the protocol with the underlying connection. More...
 
virtual void Write (ProtocolMessageWindow &msg)
 Handles writing the message to the underlying connection. More...
 
virtual void WriteCallback (const boost::system::error_code &)
 Callback for when a write completes. More...
 

Private Attributes

boost::asio::ip::udp::endpoint m_endpoint
 Datagram socket connected to a single peer DGI. More...
 
int m_reliability
 The reliability of the connection (FOR -DCUSTOMNETWORK) More...
 
bool m_stopped
 Tracker for the stoppedness of the connection. More...
 
std::string m_uuid
 The UUID of the remote endpoint for the connection. More...
 

Constructor & Destructor Documentation

virtual freedm::broker::IProtocol::~IProtocol ( )
inlinevirtual
freedm::broker::IProtocol::IProtocol ( std::string  uuid,
boost::asio::ip::udp::endpoint  endpoint 
)
protected

Member Function Documentation

virtual void freedm::broker::IProtocol::ChangePhase ( bool  )
inlinevirtual
int freedm::broker::IProtocol::GetReliability ( ) const

IProtocol::GetReliability

Description:
Get the connection reliability for DCUSTOMNETWORK
Precondition:
None
Postcondition:
None
Returns
percentage of packets that are allowed through
boost::asio::ip::udp::socket& freedm::broker::IProtocol::GetSocket ( )
bool freedm::broker::IProtocol::GetStopped ( )
inline
std::string freedm::broker::IProtocol::GetUUID ( ) const

IProtocol::GetUUID

Description:
Gets the UUID of the DGI on the other end of this connection.
Precondition:
None
Postcondition:
None
Returns
the peer's UUID
virtual void freedm::broker::IProtocol::OnReceive ( )
pure virtual

Implemented in freedm::broker::CProtocolSR.

virtual bool freedm::broker::IProtocol::Receive ( const ProtocolMessage &  msg)
pure virtual

Implemented in freedm::broker::CProtocolSR.

virtual void freedm::broker::IProtocol::ReceiveACK ( const ProtocolMessage &  msg)
pure virtual

Implemented in freedm::broker::CProtocolSR.

virtual void freedm::broker::IProtocol::Send ( const ModuleMessage &  msg)
pure virtual

Implemented in freedm::broker::CProtocolSR.

virtual void freedm::broker::IProtocol::SendACK ( const ProtocolMessage &  msg)
pure virtual

Implemented in freedm::broker::CProtocolSR.

void freedm::broker::IProtocol::SetReliability ( int  r)

IProtocol::SetReliability

Description:
Set the connection reliability for DCUSTOMNETWORK. 0 all packets areartifically dropped. 100 means no packets are artifically dropped.
Precondition:
None
Postcondition:
Sets the reliabilty of the protocol to r
Parameters
rbetween 0 and 100
void freedm::broker::IProtocol::SetStopped ( bool  v)
inline
virtual void freedm::broker::IProtocol::Stop ( )
pure virtual

Implemented in freedm::broker::CProtocolSR.

void freedm::broker::IProtocol::Write ( ProtocolMessageWindow &  msg)
protectedvirtual

IProtocol::Write

Description:
Sends a message over the connection associated with this IProtocol. This is a blocking send. An asynchronous send is not currently provided because: (a) this would require a second io_service, or a second thread in our io_service's thread pool, (b) because it would make the code more complicated: e.g. modules would be required to use an async callback (write handler) if they want custom error handling, and we would need to be more careful with our output buffer, and (c) because we don't know whether this actually slows down the DGI or not, or if so, how much. A TODO item would be to look into this. Synchronous writes usually slow things down dramatically, but that may not be the case with the DGI, given our custom scheduling.
Precondition:
None
Postcondition:
Writes the message using the listening socket to the Protocol's endpoint
Parameters
msgthe message to send to this p

Check to make sure it isn't going to overfill our message packet

Reimplemented in freedm::broker::CProtocolSR.

virtual void freedm::broker::IProtocol::WriteCallback ( const boost::system::error_code &  )
inlineprotectedvirtual

Member Data Documentation

boost::asio::ip::udp::endpoint freedm::broker::IProtocol::m_endpoint
private
int freedm::broker::IProtocol::m_reliability
private
bool freedm::broker::IProtocol::m_stopped
private
std::string freedm::broker::IProtocol::m_uuid
private

The documentation for this class was generated from the following files: