Public Member Functions | Private Attributes

ana_component Class Reference

A representative of a network component to the application. More...

#include <network_manager_ana.hpp>

Collaboration diagram for ana_component:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ana_component ()
 Constructs a server component.
 ~ana_component ()
 ana_component (const std::string &host, const std::string &port)
 Constructs a client component.
network::statistics get_send_stats () const
 Get network upload statistics for this component.
network::statistics get_receive_stats () const
 Get network download statistics for this component.
ana::serverserver () const
 Get the pointer to an ana::server object for this component.
ana::clientclient () const
 Get the pointer to an ana::client object for this component.
ana::detail::listenerlistener () const
 Get the pointer to an ana::listener object for this component.
bool is_server () const
 Returns true iff this component is a server.
bool is_client () const
 Returns true iff this component is a client.
ana::net_id get_id () const
 Returns this component's id.
network::connection get_wesnoth_id () const
void set_wesnoth_id (network::connection)
const ana::statsget_stats (ana::stat_type type=ana::ACCUMULATED) const
 Returns a pointer to the ana::stats object for accumulated network stats.
void add_buffer (ana::read_buffer buffer, ana::net_id id)
 Push a buffer to the queue of incoming messages.
ana::read_buffer wait_for_element ()
 Blocking operation to wait for a message in a component.
network::connection oldest_sender_id_still_pending ()
 Returns the network id of the oldest sender of a pending buffer.
bool new_buffer_ready ()
 Returns true iff.

Private Attributes

boost::variant< ana::server
*, ana::client * > 
base_
bool is_server_
ana::net_id id_
network::connection wesnoth_id_
boost::mutex mutex_
boost::condition_variable condition_
std::queue< ana::read_bufferbuffers_
std::queue< network::connectionsender_ids_

Detailed Description

A representative of a network component to the application.

Definition at line 36 of file network_manager_ana.hpp.


Constructor & Destructor Documentation

ana_component::ana_component (  ) 

Constructs a server component.

Definition at line 361 of file network_manager_ana.cpp.

ana_component::~ana_component (  ) 

Definition at line 385 of file network_manager_ana.cpp.

References client(), is_server(), and server().

Here is the call graph for this function:

ana_component::ana_component ( const std::string &  host,
const std::string &  port 
)

Constructs a client component.

Parameters:
host : The hostname to which it is supposed to connect to.
port : The port it is supposed to connect to.

Definition at line 373 of file network_manager_ana.cpp.


Member Function Documentation

void ana_component::add_buffer ( ana::read_buffer  buffer,
ana::net_id  id 
)

Push a buffer to the queue of incoming messages.

Definition at line 473 of file network_manager_ana.cpp.

References buffers_, condition_, is_server_, mutex_, and sender_ids_.

ana::client * ana_component::client (  )  const

Get the pointer to an ana::client object for this component.

Precondition:
: This component is a client.

Definition at line 427 of file network_manager_ana.cpp.

References base_, and is_server_.

Referenced by ana_network_manager::create_client_and_connect(), listener(), and ~ana_component().

Here is the caller graph for this function:

ana::net_id ana_component::get_id (  )  const
network::statistics ana_component::get_receive_stats (  )  const

Get network download statistics for this component.

Definition at line 406 of file network_manager_ana.cpp.

References ana::ACCUMULATED, network::statistics::current, network::statistics::current_max, listener(), ana::detail::ana_component::stats_collector(), and network::statistics::total.

Here is the call graph for this function:

network::statistics ana_component::get_send_stats (  )  const

Get network upload statistics for this component.

Definition at line 393 of file network_manager_ana.cpp.

References ana::ACCUMULATED, network::statistics::current, network::statistics::current_max, listener(), ana::detail::ana_component::stats_collector(), and network::statistics::total.

Here is the call graph for this function:

const ana::stats * ana_component::get_stats ( ana::stat_type  type = ana::ACCUMULATED  )  const

Returns a pointer to the ana::stats object for accumulated network stats.

Definition at line 468 of file network_manager_ana.cpp.

References ana::network_stats_logger::get_stats(), and listener().

Here is the call graph for this function:

network::connection ana_component::get_wesnoth_id (  )  const
bool ana_component::is_client (  )  const

Returns true iff this component is a client.

Definition at line 448 of file network_manager_ana.cpp.

References is_server_.

bool ana_component::is_server (  )  const

Returns true iff this component is a server.

Definition at line 443 of file network_manager_ana.cpp.

References is_server_.

Referenced by ~ana_component().

Here is the caller graph for this function:

ana::detail::listener * ana_component::listener (  )  const

Get the pointer to an ana::listener object for this component.

Both an ana::client an the ana::server are listeners.

Definition at line 435 of file network_manager_ana.cpp.

References client(), is_server_, and server().

Referenced by get_receive_stats(), get_send_stats(), and get_stats().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ana_component::new_buffer_ready (  ) 

Returns true iff.

the component has a read buffer ready that hasn't been returned.

Definition at line 1343 of file network_manager_ana.cpp.

References buffers_, and mutex_.

network::connection ana_component::oldest_sender_id_still_pending (  ) 

Returns the network id of the oldest sender of a pending buffer.

Definition at line 499 of file network_manager_ana.cpp.

References mutex_, and sender_ids_.

ana::server * ana_component::server (  )  const

Get the pointer to an ana::server object for this component.

Precondition:
: This component is a server.

Definition at line 419 of file network_manager_ana.cpp.

References base_, and is_server_.

Referenced by ana_network_manager::create_server(), listener(), and ~ana_component().

Here is the caller graph for this function:

void ana_component::set_wesnoth_id ( network::connection  id  ) 

Definition at line 463 of file network_manager_ana.cpp.

References wesnoth_id_.

Referenced by ana_network_manager::create_client_and_connect().

Here is the caller graph for this function:

ana::read_buffer ana_component::wait_for_element (  ) 

Blocking operation to wait for a message in a component.

Returns:
The buffer that was received first from all pending buffers.

Definition at line 485 of file network_manager_ana.cpp.

References buffers_, condition_, and mutex_.


Member Data Documentation

boost::variant<ana::server*, ana::client*> ana_component::base_ [private]

Definition at line 111 of file network_manager_ana.hpp.

Referenced by client(), and server().

std::queue< ana::read_buffer > ana_component::buffers_ [private]

Definition at line 122 of file network_manager_ana.hpp.

Referenced by add_buffer(), new_buffer_ready(), and wait_for_element().

boost::condition_variable ana_component::condition_ [private]

Definition at line 120 of file network_manager_ana.hpp.

Referenced by add_buffer(), and wait_for_element().

Definition at line 115 of file network_manager_ana.hpp.

Referenced by get_id().

bool ana_component::is_server_ [private]

Definition at line 113 of file network_manager_ana.hpp.

Referenced by add_buffer(), client(), is_client(), is_server(), listener(), and server().

boost::mutex ana_component::mutex_ [private]

Definition at line 123 of file network_manager_ana.hpp.

Referenced by add_buffer(), and oldest_sender_id_still_pending().

Definition at line 116 of file network_manager_ana.hpp.

Referenced by get_wesnoth_id(), and set_wesnoth_id().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:12:41 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs