STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Public Member Functions | Public Types | Protected Member Functions
stapl::stream_impl::stream_wrapper_impl< Stream > Struct Template Reference

A wrapper around a stream that is a p_object. A pointer to an instance is stored in stapl::stream instances provided to work functions to allow access to the stream on the location. More...

Public Member Functions

 stream_wrapper_impl (char const *const name)
 
 stream_wrapper_impl (char const *const name, std::ios_base::openmode mode)
 
void open (char const *const name)
 
void open (char const *const name, std::ios_base::openmode mode)
 
void close (void)
 
bool is_open (void) const
 Checks if the stream has an associated file.
 
template<typename T >
void read (T &val)
 Read a value from the stream. More...
 
template<typename T , typename Accessor >
void read (proxy< T, Accessor > &val)
 Read a value from the stream. More...
 
void read (typename Stream::char_type *s, std::streamsize count)
 Read blocks of characters from the stream. More...
 
void getline (typename Stream::char_type *s, std::streamsize count, typename Stream::char_type delim)
 Read values from the stream without formatting. More...
 
template<typename T >
void write (T const &val)
 Write the specified value val to the stream.
 
void write (typename Stream::char_type *s, std::streamsize count)
 Write the specified count of characters from buffer s to the stream.
 
void endl (void)
 Method invoked when std::endl is passed to the stream. The std::endl is inserted in the stream on location 0.
 
runtime::location_md const & get_location_md (void) const noexcept
 Returns the location metadata of the location this object registered in.
 
runtime::location_mdget_location_md (void) noexcept
 Returns the location metadata of the location this object registered in. noexcept More...
 
Distributed Object Management
rmi_handle::const_reference const & get_rmi_handle (void) const noexcept
 Returns the associated rmi_handle.
 
rmi_handle::reference const & get_rmi_handle (void) noexcept
 Returns the associated rmi_handle.
 
size_type get_location_id (void) const noexcept
 Returns the location id of the local sub-object.
 
size_type get_num_locations (void) const noexcept
 Returns the number of locations of the gang of this p_object.
 
void advance_epoch (void)
 Advances the epoch of the object. More...
 
void unlock (void)
 Used by lock_guard functionality in method of derived classes to request atomicity with respect to incoming RMIs. More...
 
void lock (void)
 Used by lock_guard functionality in method of derived classes to request atomicity with respect to incoming RMIs. More...
 
bool try_lock (void)
 Attempt to maintain atomicity with respect to incoming RMIs. More...
 

Public Types

using size_type = rmi_handle::size_type
 

Protected Member Functions

template<typename T >
get_value ()
 
std::basic_string< typename Stream::char_type > fetch (std::streamsize count)
 Call read on the local stream and return shared_ptr to the populated buffer. More...
 
void write_impl (std::basic_string< typename Stream::char_type > const &data, std::streamsize count)
 Call write on the local stream to write the unformatted data provided to the stream. More...
 
boost::shared_ptr< typename Stream::char_type > fetchline (std::streamsize count, typename Stream::char_type delim)
 Call getline on the local stream and return shared_ptr to the populated buffer. More...
 

Detailed Description

template<typename Stream>
struct stapl::stream_impl::stream_wrapper_impl< Stream >

A wrapper around a stream that is a p_object. A pointer to an instance is stored in stapl::stream instances provided to work functions to allow access to the stream on the location.

Currently only location 0 opens the stream and all other locations will forward read/writes to location 0.

Member Function Documentation

◆ fetch()

template<typename Stream >
std::basic_string<typename Stream::char_type> stapl::stream_impl::stream_wrapper_impl< Stream >::fetch ( std::streamsize  count)
protected

Call read on the local stream and return shared_ptr to the populated buffer.

This method is invoked by read(typename Stream::char_type*, std::streamsize).

Parameters
countNumber of characters to be read from the stream
Returns
string containing the characters from the stream

◆ write_impl()

template<typename Stream >
void stapl::stream_impl::stream_wrapper_impl< Stream >::write_impl ( std::basic_string< typename Stream::char_type > const &  data,
std::streamsize  count 
)
protected

Call write on the local stream to write the unformatted data provided to the stream.

This method is invoked by write(typename Stream::char_type* s, std::streamsize count)

Parameters
datastring that contains an unformatted byte sequence to be written to the stream
countNumber of characters to be written to the stream

◆ fetchline()

template<typename Stream >
boost::shared_ptr<typename Stream::char_type> stapl::stream_impl::stream_wrapper_impl< Stream >::fetchline ( std::streamsize  count,
typename Stream::char_type  delim 
)
protected

Call getline on the local stream and return shared_ptr to the populated buffer.

This method is invoked by getline.

Parameters
countMaximum number of charaters to extract
delimDeliminter used to separate lines.
Returns
shared_ptr to a populated char array.

◆ read() [1/3]

template<typename Stream >
template<typename T >
void stapl::stream_impl::stream_wrapper_impl< Stream >::read ( T &  val)

Read a value from the stream.

Parameters
valvariable where the value read from stream is assigned.

◆ read() [2/3]

template<typename Stream >
template<typename T , typename Accessor >
void stapl::stream_impl::stream_wrapper_impl< Stream >::read ( proxy< T, Accessor > &  val)

Read a value from the stream.

Parameters
valA proxy over the variable that will have the value read from the stream assigned to it.
Note
This specialization is provided in order to pass the correct type of the value to be read from the stream to get_value. This is needed because a proxy cannot be default constructed.

◆ read() [3/3]

template<typename Stream >
void stapl::stream_impl::stream_wrapper_impl< Stream >::read ( typename Stream::char_type *  s,
std::streamsize  count 
)

Read blocks of characters from the stream.

Parameters
sBuffer to be populated with characters extracted from stream
countNumber of characters to be extracted from the stream

◆ getline()

template<typename Stream >
void stapl::stream_impl::stream_wrapper_impl< Stream >::getline ( typename Stream::char_type *  s,
std::streamsize  count,
typename Stream::char_type  delim 
)

Read values from the stream without formatting.

Parameters
sBuffer to be populated with characters extracted from stream
countMaximum number of elements to extract from stream
delimCharacter delimiting a new line in the file.

◆ get_location_md()

runtime::location_md& stapl::p_object::get_location_md ( void  )
noexceptinherited

Returns the location metadata of the location this object registered in. noexcept

noexcept

◆ advance_epoch()

void stapl::p_object::advance_epoch ( void  )
inherited

Advances the epoch of the object.

Advancing the epoch will flush any pending RMIs. It will also increase the epoch of the current gang if the object is not a named object.

◆ unlock()

void stapl::p_object::unlock ( void  )
inherited

Used by lock_guard functionality in method of derived classes to request atomicity with respect to incoming RMIs.

Mutates counter in the associated runqueue.

◆ lock()

void stapl::p_object::lock ( void  )
inherited

Used by lock_guard functionality in method of derived classes to request atomicity with respect to incoming RMIs.

Mutates counter in the associated runqueue.

◆ try_lock()

bool stapl::p_object::try_lock ( void  )
inherited

Attempt to maintain atomicity with respect to incoming RMIs.

Mutates counter in the associated runqueue.

Returns
true if the lock was able to be acquired. false if it is already locked.

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