Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::common::GenericInputStream< Type > Class Template Reference

Manages the connection of a stream to handlers. More...

#include <inputStream.h>

Inheritance diagram for MaxOS::common::GenericInputStream< Type >:
MaxOS::common::InputStreamProcessor< Type, Type > MaxOS::common::InputStreamProcessor< Type, Type * > MaxOS::common::InputStreamProcessor< string, string > MaxOS::common::GenericOutputStream< Type > MaxOS::common::InputStreamSocket< Type > MaxOS::common::InputStreamBuffer< Type >

Public Member Functions

 GenericInputStream ()
 Creates a new GenericInputStream.
 
 GenericInputStream (InputStreamEventHandler< Type > *)
 Creates a new GenericInputStream and connects it to the handler.
 
 ~GenericInputStream ()
 Destroys the GenericInputStream and disconnects all handlers.
 
void connect_input_stream_event_handler (InputStreamEventHandler< Type > *)
 Adds a inputStreamEventHandler to the list of internetProtocolHandlers.
 
void disconnect_input_stream_event_handler (InputStreamEventHandler< Type > *)
 Removes a handler from the list of handlers.
 

Protected Attributes

common::Vector< InputStreamEventHandler< Type > * > m_input_stream_event_handlers
 List of streams being observed by this handler.
 

Detailed Description

template<class Type>
class MaxOS::common::GenericInputStream< Type >

Manages the connection of a stream to handlers.

Template Parameters
TypeThe type of data the stream is handling

Definition at line 102 of file inputStream.h.

Constructor & Destructor Documentation

◆ GenericInputStream() [1/2]

template<class Type >
MaxOS::common::GenericInputStream< Type >::GenericInputStream ( )
default

Creates a new GenericInputStream.

Template Parameters
TypeThe type of data the stream is handling

◆ GenericInputStream() [2/2]

template<class Type >
MaxOS::common::GenericInputStream< Type >::GenericInputStream ( InputStreamEventHandler< Type > *  input_stream_event_handler)
explicit

Creates a new GenericInputStream and connects it to the handler.

Template Parameters
TypeThe type of data the stream is handling
Parameters
input_stream_event_handlerThe handler to handle the data

Definition at line 376 of file inputStream.h.

376 {
377
378 // Connect the handler
379 connect_input_stream_event_handler(input_stream_event_handler);
380 }
void connect_input_stream_event_handler(InputStreamEventHandler< Type > *)
Adds a inputStreamEventHandler to the list of internetProtocolHandlers.

◆ ~GenericInputStream()

Destroys the GenericInputStream and disconnects all handlers.

Template Parameters
TypeThe type of data the stream is handling

Definition at line 387 of file inputStream.h.

387 {
388
389 // Disconnect all handlers
390 while(!m_input_stream_event_handlers.empty())
392 }
common::Vector< InputStreamEventHandler< Type > * > m_input_stream_event_handlers
List of streams being observed by this handler.
void disconnect_input_stream_event_handler(InputStreamEventHandler< Type > *)
Removes a handler from the list of handlers.

Member Function Documentation

◆ connect_input_stream_event_handler()

template<class Type >
void MaxOS::common::GenericInputStream< Type >::connect_input_stream_event_handler ( InputStreamEventHandler< Type > *  input_stream_event_handler)

Adds a inputStreamEventHandler to the list of internetProtocolHandlers.

Template Parameters
TypeThe type of data the stream is handling
Parameters
input_stream_event_handlerThe inputStreamEventHandler to add

Definition at line 399 of file inputStream.h.

399 {
400
401 // Don't add the handler if it is already connected
402 if(m_input_stream_event_handlers.find(input_stream_event_handler) != m_input_stream_event_handlers.end())
403 return;
404
405 // Add the handler
406 m_input_stream_event_handlers.push_back(input_stream_event_handler);
407
408 }

◆ disconnect_input_stream_event_handler()

template<class Type >
void MaxOS::common::GenericInputStream< Type >::disconnect_input_stream_event_handler ( InputStreamEventHandler< Type > *  input_stream_event_handler)

Removes a handler from the list of handlers.

Template Parameters
TypeThe type of data the stream is handling
Parameters
input_stream_event_handlerThe handler to remove

Definition at line 416 of file inputStream.h.

416 {
417
418 // Don't remove the handler if it is not connected
419 if(m_input_stream_event_handlers.find(input_stream_event_handler) == m_input_stream_event_handlers.end())
420 return;
421
422 // Remove the handler
423 m_input_stream_event_handlers.erase(input_stream_event_handler);
424
425 // Fire the end of stream event
426 input_stream_event_handler->on_end_of_stream(this);
427
428 }

References MaxOS::common::InputStreamEventHandler< Type >::on_end_of_stream().

Member Data Documentation

◆ m_input_stream_event_handlers

template<class Type >
common::Vector<InputStreamEventHandler<Type>*> MaxOS::common::GenericInputStream< Type >::m_input_stream_event_handlers
protected

List of streams being observed by this handler.

Definition at line 105 of file inputStream.h.


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