AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxNet::SocketSet Class Reference

#include <Socket.h>

+ Inheritance diagram for agxNet::SocketSet:

Public Member Functions

 SocketSet ()
 Creates a socket set of the specified size. More...
 
bool addSocket (Socket *sock)
 Add a socket to socket set. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
bool checkSockets (agx::UInt32 timeoutMillis)
 Check sockets from socket set for activity. More...
 
size_t getMaxSockets () const
 Returns maximal number of sockets the system allows. More...
 
size_t getNumSockets () const
 Returns number of sockets the socket set currently holds. More...
 
int getReferenceCount () const
 
const SocketRefVector & getSockets () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
bool removeSocket (Socket *sock)
 Remove socket from socket set. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~SocketSet ()
 Destroys the socket set. More...
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Definition at line 518 of file Socket.h.

Constructor & Destructor Documentation

agxNet::SocketSet::SocketSet ( )

Creates a socket set of the specified size.

Creates a socket set which can hold the specified number of sockets at maximum.

virtual agxNet::SocketSet::~SocketSet ( )
inlineprotectedvirtual

Destroys the socket set.

Note, that it does not destroy the sockets this set holds references to.

Definition at line 580 of file Socket.h.

Member Function Documentation

bool agxNet::SocketSet::addSocket ( Socket *  sock)

Add a socket to socket set.

Parameters
sock- pointer to the socket object to add.
Returns
false if socket is already added
void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
bool agxNet::SocketSet::checkSockets ( agx::UInt32  timeoutMillis)

Check sockets from socket set for activity.

This method checks sockets for activities of incoming data ready or remote socket has disconnected. This method sets ready flag for all sockets with activity which can later be checked by Socket::IsReady() method. The ready flag will be cleared by subsequent TCPSocket::Recv() function call.

Parameters
timeoutMillis- maximum number of milliseconds to wait for socket activity to appear. if 0 is specified the function will not wait and will return immediately.
Returns
true if there is at least one socket with activity.
false if there are no any sockets with activities.
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
size_t agxNet::SocketSet::getMaxSockets ( ) const

Returns maximal number of sockets the system allows.

Returns
maximal number of sockets available in the system.
size_t agxNet::SocketSet::getNumSockets ( ) const
inline

Returns number of sockets the socket set currently holds.

Returns
number of sockets the socket set currently holds.

Definition at line 532 of file Socket.h.

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
const SocketRefVector& agxNet::SocketSet::getSockets ( ) const
inline

Definition at line 572 of file Socket.h.

template<typename T >
bool agx::Referenced::is ( ) const
inherited
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

bool agxNet::SocketSet::removeSocket ( Socket *  sock)

Remove socket from socket set.

Parameters
sock- pointer to socket object which we want to remove from the set.
Returns
false if socket is not previously added
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.


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