TPIE

2362a60
tpie::pipelining::factory_base Class Reference

Base class of all pipelining factories. More...

#include <tpie/pipelining/factory_base.h>

Inherited by tpie::pipelining::serialization_bits::sort_factory_base< default_pred_sort_factory >, tpie::pipelining::bits::sort_factory_base< default_pred_sort_factory< store_t >, store_t >, tpie::pipelining::serialization_bits::sort_factory_base< sort_factory< pred_t > >, tpie::pipelining::bits::sort_factory_base< sort_factory< pred_t, store_t >, store_t >, tpie::pipelining::bits::passive_sorter_factory_input< T, pred_t, store_t >, tpie::pipelining::bits::passive_sorter_factory_output< T, pred_t, store_t >, tpie::pipelining::bits::sort_factory_base< child_t, store_t >, tpie::pipelining::factory< R, T >, tpie::pipelining::parallel_bits::factory< fact_t >, tpie::pipelining::serialization_bits::passive_sorter_factory_input< Traits >, tpie::pipelining::serialization_bits::passive_sorter_factory_output< Traits >, tpie::pipelining::serialization_bits::sort_factory_base< child_t >, tpie::pipelining::split_factory< I, OB, O >, tpie::pipelining::tempfactory< Holder, T >, tpie::pipelining::termfactory< R, T >, and tpie::pipelining::tfactory< R, Args< TT...>, T...>.

Public Member Functions

 factory_base (const factory_base &other)=delete
 
 factory_base (factory_base &&)=default
 
factory_baseoperator= (const factory_base &other)=delete
 
factory_baseoperator= (factory_base &&)=default
 
void memory (double amount)
 Set memory fraction for this node in the pipeline phase. More...
 
double memory () const
 Set memory fraction for this node in the pipeline phase. More...
 
void hook_initialization (factory_init_hook *hook)
 Add a node initialization hook. More...
 
void copy_hooks_to (factory_base &other) const
 Copy the hooks that have been added to this factory to another. More...
 
void init_node (node &r)
 Initialize node constructed in a subclass. More...
 
void init_sub_node (node &r)
 Initialize node constructed in a subclass. More...
 
void add_default_edge (node &r, const node &dest) const
 Used by pipe_base classes to set a default actor edge for ordinary push/pull nodes. More...
 
void add_default_edge (node &r, const node_token &dest) const
 Used by pipe_base classes to set a default actor edge for ordinary push/pull nodes. More...
 
void add_node_set_edges (node &r) const
 
void name (const std::string &n, priority_type p)
 Set name for this node. More...
 
void phase_name (const std::string &n, priority_type p)
 Set name for this phase. More...
 
void push_breadcrumb (const std::string &n)
 Set a prefix for the name of this node. More...
 
void set_destination_kind_push ()
 Used by pipe_base classes to indicate that the default actor edge is a push edge. More...
 
void set_destination_kind_pull ()
 Used by pipe_base classes to indicate that the default actor edge is a pull edge. More...
 
void add_to_set (node_set s)
 
void add_dependencies (node_set s)
 
void add_forwarding_dependencies (node_set s)
 
void forward (const std::string &key, any_noncopyable value)
 

Detailed Description

Base class of all pipelining factories.

The subclass must define an inner template struct named constructed, that takes one template parameter dest_t and defines an inner typedef named type that is the actual type of node constructed.

If the factory foo_factory constructs foo objects, then the type expression foo_factory::constructed<bar<baz> >::type should be equal to foo<bar<baz> >.

The subclass must also define a template const method named construct, that takes one template parameter dest_t, has the return type constructed<dest_t>::type and takes just one parameter dest of type dest_t.

If the factory constructs just one node descendent, then the factory should call the factory_base::init_node method with this node as parameter. For example see tpie/pipelining/factory_helpers.h.

If the factory constructs multiple node descendents, then the factory should call the factory_base::init_sub_node method for each of the nodes. For example see sort_factory_base in tpie/pipelining/sort.h.

Definition at line 73 of file factory_base.h.

Member Function Documentation

void tpie::pipelining::factory_base::add_default_edge ( node r,
const node dest 
) const
inline

Used by pipe_base classes to set a default actor edge for ordinary push/pull nodes.

Definition at line 178 of file factory_base.h.

References tpie::pipelining::node::get_token().

178  {
179  add_default_edge(r, dest.get_token());
180  }
void add_default_edge(node &r, const node &dest) const
Used by pipe_base classes to set a default actor edge for ordinary push/pull nodes.
Definition: factory_base.h:178
void tpie::pipelining::factory_base::add_default_edge ( node r,
const node_token dest 
) const
inline

Used by pipe_base classes to set a default actor edge for ordinary push/pull nodes.

Definition at line 186 of file factory_base.h.

References tpie::pipelining::node::add_pull_source(), tpie::pipelining::node::add_push_destination(), tpie::pipelining::node::get_id(), and tpie::pipelining::node::get_node_map().

186  {
187  if (r.get_node_map()->find_authority()->out_degree(r.get_id()) > 0) return;
188  switch (m_destinationKind) {
189  case destination_kind::none:
190  break;
191  case destination_kind::push:
192  r.add_push_destination(dest);
193  break;
194  case destination_kind::pull:
195  r.add_pull_source(dest);
196  break;
197  }
198  }
void tpie::pipelining::factory_base::copy_hooks_to ( factory_base other) const
inline

Copy the hooks that have been added to this factory to another.

Definition at line 118 of file factory_base.h.

118  {
119  for (size_t i = 0; i < m_hooks.size(); ++i) {
120  other.m_hooks.push_back(m_hooks[i]);
121  }
122  }
void tpie::pipelining::factory_base::hook_initialization ( factory_init_hook hook)
inline

Add a node initialization hook.

When a node is instantiated in construct(), the given hook will get a chance to do some additional initialization.

Definition at line 111 of file factory_base.h.

111  {
112  m_hooks.push_back(hook);
113  }
void tpie::pipelining::factory_base::init_node ( node r)
inline

Initialize node constructed in a subclass.

This lets the user define a name or memory fraction for this certain node in the pipeline phase, and it lets initialization hooks do their thing.

If more than one node is constructed in the subclass in construct(), the implementation should use init_sub_node instead.

Definition at line 134 of file factory_base.h.

References tpie::pipelining::node::set_breadcrumb(), tpie::pipelining::node::set_name(), and tpie::pipelining::node::set_phase_name().

134  {
135  if (!m_name.empty()) {
136  r.set_name(m_name, m_namePriority);
137  }
138  if (!m_phaseName.empty()) {
139  r.set_phase_name(m_phaseName, m_phaseNamePriority);
140  }
141  if (!m_breadcrumbs.empty()) {
142  r.set_breadcrumb(m_breadcrumbs);
143  }
144  init_common(r);
145  }
void tpie::pipelining::factory_base::init_sub_node ( node r)
inline

Initialize node constructed in a subclass.

This lets the user define a name or memory fraction for this certain node in the pipeline phase, and it lets initialization hooks do their thing.

If just one node is constructed in the subclass in construct(), the implementation should use init_node instead.

Definition at line 157 of file factory_base.h.

References tpie::pipelining::node::set_breadcrumb().

157  {
158  if (m_breadcrumbs.empty()) {
159  if (m_name.empty()) {
160  // no op
161  } else {
162  r.set_breadcrumb(m_name);
163  }
164  } else {
165  if (m_name.empty()) {
166  r.set_breadcrumb(m_breadcrumbs);
167  } else {
168  r.set_breadcrumb(m_breadcrumbs + " | " + m_name);
169  }
170  }
171  init_common(r);
172  }
void tpie::pipelining::factory_base::memory ( double  amount)
inline

Set memory fraction for this node in the pipeline phase.

In the absence of minimum and maximum memory requirements set by node implementations, the memory assigned to the node will be proportional to the amount parameter which sets the memory priority of this node in relation to the rest of the phase.

See also
factory_base::memory(double)
bits::pipe_base::memory(double)

Definition at line 89 of file factory_base.h.

Referenced by tpie::pipelining::bits::pipe_base< pipe_begin< fact_t > >::memory().

89  {
90  m_amount = amount;
91  m_set = true;
92  }
double tpie::pipelining::factory_base::memory ( ) const
inline

Set memory fraction for this node in the pipeline phase.

In the absence of minimum and maximum memory requirements set by node implementations, the memory assigned to the node will be proportional to the amount parameter which sets the memory priority of this node in relation to the rest of the phase.

See also
factory_base::memory(double)
memory(double)
bits::pipe_base::memory()

Definition at line 101 of file factory_base.h.

101  {
102  return m_amount;
103  }
void tpie::pipelining::factory_base::name ( const std::string &  n,
priority_type  p 
)
inline

Set name for this node.

The name is used in the GraphViz plot generated by pipeline::plot.

The name priority given in the second argument should indicate how important this node is for the current phase, and is used in naming the progress indicator for this phase. The node with the highest priority name gets to name the entire phase.

See also
factory_base::name
bits::pipe_base::name

Definition at line 241 of file factory_base.h.

Referenced by tpie::pipelining::bits::pipe_base< pipe_begin< fact_t > >::name().

241  {
242  m_name = n;
243  m_namePriority = p;
244  }
void tpie::pipelining::factory_base::phase_name ( const std::string &  n,
priority_type  p 
)
inline

Set name for this phase.

The maximal priority phase name given for a phase wins.

See also
factory_base::phase_name
bits::pipe_base::phase_name

Definition at line 252 of file factory_base.h.

Referenced by tpie::pipelining::bits::pipe_base< pipe_begin< fact_t > >::phase_name().

252  {
253  m_phaseName = n;
254  m_phaseNamePriority = p;
255  }
void tpie::pipelining::factory_base::push_breadcrumb ( const std::string &  n)
inline

Set a prefix for the name of this node.

The name is used in the GraphViz plot generated by pipeline::plot.

See also
factory_base::push_breadcrumb
bits::pipe_base::breadcrumb

Definition at line 264 of file factory_base.h.

Referenced by tpie::pipelining::bits::pipe_base< pipe_begin< fact_t > >::breadcrumb().

264  {
265  if (m_breadcrumbs.empty()) m_breadcrumbs = n;
266  else m_breadcrumbs = n + " | " + m_breadcrumbs;
267  }
void tpie::pipelining::factory_base::set_destination_kind_pull ( )
inline

Used by pipe_base classes to indicate that the default actor edge is a pull edge.

Definition at line 281 of file factory_base.h.

281  {
282  m_destinationKind = destination_kind::pull;
283  }
void tpie::pipelining::factory_base::set_destination_kind_push ( )
inline

Used by pipe_base classes to indicate that the default actor edge is a push edge.

Definition at line 273 of file factory_base.h.

Referenced by tpie::pipelining::pipe_middle< fact_t >::operator|().

273  {
274  m_destinationKind = destination_kind::push;
275  }

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