Yate
JBStreamSet Class Referenceabstract

A set of streams to be processed in an uniform way. More...

#include <yatejabber.h>

Inheritance diagram for JBStreamSet:
GenObject Mutex Lockable JBStreamSetProcessor JBStreamSetReceive

Public Member Functions

virtual ~JBStreamSet ()
 
ObjListclients ()
 
virtual bool add (JBStream *client)
 
virtual bool remove (JBStream *client, bool delObj=true)
 
unsigned int dropAll (const JabberID &local=JabberID::empty(), const JabberID &remote=JabberID::empty(), XMPPError::Type error=XMPPError::NoError, const char *reason=0)
 
void run ()
 
virtual bool start ()
 
virtual void stop ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtoString () const
 
virtual const StringtraceId () const
 
virtual void * getObject (const String &name) const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- Public Member Functions inherited from Mutex
 Mutex (bool recursive=false, const char *name=0)
 
 Mutex (const Mutex &original)
 
 ~Mutex ()
 
Mutexoperator= (const Mutex &original)
 
virtual bool lock (long maxwait=-1)
 
virtual bool unlock ()
 
virtual bool locked () const
 
const char * owner () const
 
bool recursive () const
 
- Public Member Functions inherited from Lockable
virtual ~Lockable ()
 
virtual bool check (long maxwait=-1)
 
virtual bool unlockAll ()
 

Protected Member Functions

 JBStreamSet (JBStreamSetList *owner)
 
virtual bool process (JBStream &stream)=0
 

Protected Attributes

bool m_changed
 
bool m_exiting
 
JBStreamSetListm_owner
 
ObjList m_clients
 

Friends

class JBStreamSetList
 

Additional Inherited Members

- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 
- Static Public Member Functions inherited from Mutex
static int count ()
 
static int locks ()
 
static bool efficientTimedLock ()
 
- Static Public Member Functions inherited from Lockable
static void wait (unsigned long maxwait)
 
static unsigned long wait ()
 
static void startUsingNow ()
 
static void enableSafety (bool safe=true)
 
static bool safety ()
 

Detailed Description

A set of streams to be processed in an uniform way.

This class holds a set of streams to be processed in an uniform way. This is a base class for specialized stream list processors. Its process() method should be called in its own thread

Constructor & Destructor Documentation

◆ ~JBStreamSet()

virtual ~JBStreamSet ( )
virtual

Destructor. Delete the owned streams. Remove from owner

◆ JBStreamSet()

JBStreamSet ( JBStreamSetList * owner)
protected

Constructor

Parameters
ownerThe list owning this set

References Mutex::owner().

Referenced by JBStreamSetProcessor::JBStreamSetProcessor(), and process().

Member Function Documentation

◆ add()

virtual bool add ( JBStream * client)
virtual

Add a stream to the set. The stream's reference counter will be increased. This method doesn't check if the stream is already added

Parameters
clientThe stream to append
Returns
True on success, false if there is no more room in this set

◆ clients()

ObjList & clients ( )
inline

Retrieve the list of clients. Make sure the set is locked before calling this method

Returns
The list of clients

◆ dropAll()

unsigned int dropAll ( const JabberID & local = JabberID::empty(),
const JabberID & remote = JabberID::empty(),
XMPPError::Type error = XMPPError::NoError,
const char * reason = 0 )

Terminate all streams matching local/remote jid

Parameters
localOptional local jid to match
remoteOptional remote jid to match
errorOptional error to be sent to the client
reasonOptional error text to be sent to the client
Returns
The number of streams terminated

References JabberID::empty().

◆ process()

virtual bool process ( JBStream & stream)
protectedpure virtual

This method is called from run() with the list unlocked and stream's reference counter increased. A specialized processor must implement this method

Parameters
streamThe stream to process
Returns
True if something was processed

Implemented in JBStreamSetProcessor, and JBStreamSetReceive.

References JBStreamSet().

◆ remove()

virtual bool remove ( JBStream * client,
bool delObj = true )
virtual

Remove a stream from set

Parameters
clientThe stream to remove
delObjTrue to release the stream, false to remove it from list without releasing it
Returns
True on success, false if not found

◆ run()

void run ( )

Process the list. Returns as soon as there are no more streams in the list

◆ start()

virtual bool start ( )
virtual

Start running

Returns
True on success

◆ stop()

virtual void stop ( )
virtual

Stop running


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