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

A stream that can be written to. More...

#include <outputStream.h>

Inheritance diagram for MaxOS::common::GenericOutputStream< Type >:
MaxOS::common::InputStreamProcessor< Type, Type > MaxOS::common::InputStreamEventHandler< Type > MaxOS::common::GenericInputStream< Type >

Public Member Functions

 GenericOutputStream ()
 __________________________________________Templates__________________________________________________///
 
 ~GenericOutputStream ()
 Destructor of the GenericOutputStream class.
 
void on_stream_read (Type) override
 Writes the date that was read from the input stream to the output stream.
 
void on_end_of_stream (GenericInputStream< Type > *) override
 Close the stream and remove it from the list of streams when the end of the stream is reached.
 
virtual void write (Type)
 write an element to the stream.
 
virtual void close ()
 Close the stream.
 
virtual GenericOutputStream< Type > & operator<< (Type)
 Overload the << operator to write an element to the stream.
 
- Public Member Functions inherited from MaxOS::common::InputStreamProcessor< Type, Type >
 InputStreamProcessor ()
 Creates a new InputStreamProcessor.
 
 InputStreamProcessor (InputStreamEventHandler< Type > *generic_stream_event_handler)
 Creates a new InputStreamProcessor.
 
 ~InputStreamProcessor ()
 Destroys the InputStreamProcessor.
 
void on_end_of_stream (GenericInputStream< Type > *stream) override
 Called when a stream has finished. Passes the event on to the handlers and then removes the stream from the array of streams.
 
- Public Member Functions inherited from MaxOS::common::InputStreamEventHandler< Type >
 InputStreamEventHandler ()
 _______________________________________________TEMPLATES_________________________________________________________________///
 
 ~InputStreamEventHandler ()
 Destroys the InputStreamProcessor and disconnects it from all streams.
 
- Public Member Functions inherited from MaxOS::common::GenericInputStream< Type >
 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.
 

Additional Inherited Members

- Protected Attributes inherited from MaxOS::common::InputStreamEventHandler< Type >
common::Vector< GenericInputStream< Type > * > m_generic_input_streams
 List of streams being observed by this handler.
 
- Protected Attributes inherited from MaxOS::common::GenericInputStream< Type >
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::GenericOutputStream< Type >

A stream that can be written to.

Template Parameters
TypeThe type of the elements that will be written to the stream.

Definition at line 25 of file outputStream.h.

Constructor & Destructor Documentation

◆ GenericOutputStream()

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

__________________________________________Templates__________________________________________________///

Constructor of the GenericOutputStream class.

Template Parameters
TypeThe type of the elements that will be written to the stream.

◆ ~GenericOutputStream()

Destructor of the GenericOutputStream class.

Template Parameters
TypeThe type of the elements that will be written to the stream.

Member Function Documentation

◆ close()

template<class Type >
void MaxOS::common::GenericOutputStream< Type >::close ( )
virtual

Close the stream.

Template Parameters
TypeThe type of the elements that will be written to the stream.

Definition at line 136 of file outputStream.h.

136 {
137
138 }

◆ on_end_of_stream()

template<class Type >
void MaxOS::common::GenericOutputStream< Type >::on_end_of_stream ( GenericInputStream< Type > *  stream)
overridevirtual

Close the stream and remove it from the list of streams when the end of the stream is reached.

Template Parameters
TypeThe type of the elements that will be written to the stream.
Parameters
streamThe stream that reached the end.

Reimplemented from MaxOS::common::InputStreamEventHandler< Type >.

Definition at line 108 of file outputStream.h.

108 {
109
110 // Close the stream.
111 close();
112
113 // Pass the event to any handlers
114 for(auto& input_stream_event_handler : this->m_input_stream_event_handlers)
115 input_stream_event_handler->on_end_of_stream(stream);
116
117 // Remove the stream from the list of streams.
119
120 }
common::Vector< InputStreamEventHandler< Type > * > m_input_stream_event_handlers
List of streams being observed by this handler.
void on_end_of_stream(GenericInputStream< Type > *) override
Close the stream and remove it from the list of streams when the end of the stream is reached.
virtual void close()
Close the stream.
void on_end_of_stream(GenericInputStream< Type > *stream) override
Called when a stream has finished. Passes the event on to the handlers and then removes the stream fr...

References MaxOS::common::InputStreamProcessor< Type, ProcessorType >::on_end_of_stream().

◆ on_stream_read()

template<class Type >
void MaxOS::common::GenericOutputStream< Type >::on_stream_read ( Type  read_element)
overridevirtual

Writes the date that was read from the input stream to the output stream.

Template Parameters
TypeThe type of the elements that will be written to the stream.
Parameters
read_elementThe element that was read from the stream.

Reimplemented from MaxOS::common::InputStreamEventHandler< Type >.

Definition at line 90 of file outputStream.h.

90 {
91
92 // When something is read from the input stream, it is written to the output stream.
93 write(read_element);
94
95 // Pass the element to any handlers
96 for(auto& input_stream_event_handler : this->m_input_stream_event_handlers)
97 input_stream_event_handler->on_stream_read(read_element);
98
99
100 }
void on_stream_read(Type) override
Writes the date that was read from the input stream to the output stream.
virtual void write(Type)
write an element to the stream.

◆ operator<<()

template<class Type >
GenericOutputStream< Type > & MaxOS::common::GenericOutputStream< Type >::operator<< ( Type  write_element)
virtual

Overload the << operator to write an element to the stream.

Template Parameters
TypeThe type of the elements that will be written to the stream.
Parameters
write_elementThe element that will be written to the stream.
Returns
The stream

Definition at line 136 of file outputStream.h.

147 {
148
149 // write the element to the stream.
150 write(write_element);
151
152 // Return the stream.
153 return *this;
154 }

◆ write()

template<class Type >
void MaxOS::common::GenericOutputStream< Type >::write ( Type  )
virtual

write an element to the stream.

Template Parameters
TypeThe type of the elements that will be written to the stream.

Definition at line 127 of file outputStream.h.

127 {
128
129 }

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