20 #ifndef __TPIE_PIPELINING_FILE_STREAM_H__
21 #define __TPIE_PIPELINING_FILE_STREAM_H__
25 #include <tpie/pipelining/node.h>
26 #include <tpie/pipelining/factory_helpers.h>
30 namespace pipelining {
39 template <
typename dest_t>
42 typedef typename dest_t::item_type item_type;
46 set_name(
"Read", PRIORITY_INSIGNIFICANT);
59 virtual void go()
override {
84 set_name(
"Read", PRIORITY_INSIGNIFICANT);
98 inline bool can_pull() {
110 template <
typename T>
116 set_name(
"Write", PRIORITY_INSIGNIFICANT);
120 inline void push(
const T & item) {
132 template <
typename source_t>
135 typedef typename source_t::item_type item_type;
139 set_name(
"Write", PRIORITY_INSIGNIFICANT);
143 virtual void go()
override {
145 while (source.can_pull()) {
146 fs.
write(source.pull());
155 template <
typename T>
158 template <
typename dest_t>
167 void push(
const item_type & i) {
186 return termfactory_1<bits::pull_input_t<T>,
file_stream<T> &>(fs);
189 template <
typename T>
190 inline pipe_end<termfactory_1<bits::output_t<T>, file_stream<T> &> > output(file_stream<T> & fs) {
191 return termfactory_1<bits::output_t<T>, file_stream<T> &>(fs);
195 inline pullpipe_end<factory_1<bits::pull_output_t, file_stream<T> &> > pull_output(file_stream<T> & fs) {
196 return factory_1<bits::pull_output_t, file_stream<T> &>(fs);
199 template <
typename T>
200 inline pipe_middle<factory_1<bits::tee_t<typename T::item_type>::template type, T &> >
201 tee(T & fs) {
return factory_1<bits::tee_t<typename T::item_type>::template type, T &>(fs);}
void add_pull_source(const node_token &dest)
Called by implementers to declare a pull source.
const item_type & read()
Read an item from the stream.
void write(const item_type &item)
Write an item to the stream.
void add_push_destination(const node_token &dest)
Called by implementers to declare a push destination.
void set_name(const std::string &name, priority_type priority=PRIORITY_USER)
Set this node's name.
void set_minimum_memory(memory_size_type minimumMemory)
Called by implementers to declare minimum memory requirements.
Node factory for 1-argument generator.
void step(stream_size_type steps=1)
Step the progress indicator.
static memory_size_type memory_usage(float blockFactor=1.0, bool includeDefaultFileAccessor=true)
Calculate the amount of memory used by a single file_stream.
file_stream output terminator.
bool is_open() const
Check if file is open.
bool can_read() const
Check if we can read an item with read().
file_stream output pull data source.
void set_steps(stream_size_type steps)
Called by implementers that intend to call step().
void forward(std::string key, T value, bool explicitForward=true)
Called by implementers to forward auxiliary data to successors.
virtual void go() override
For initiator nodes, execute this phase by pushing all items to be pushed.
stream_size_type size() const
Get the size of the file measured in items.
Simple class acting both as a tpie::file and a tpie::file::stream.