Tenncor
ifunctor.hpp
Go to the documentation of this file.
1 
9 #include "teq/funcarg.hpp"
10 
11 #ifndef TEQ_IFUNCTOR_HPP
12 #define TEQ_IFUNCTOR_HPP
13 
14 namespace teq
15 {
16 
18 struct Opcode final
19 {
21  std::string name_;
22 
24  size_t code_;
25 };
26 
28 struct iFunctor : public iTensor
29 {
30  virtual ~iFunctor (void) = default;
31 
33  void accept (iTraveler& visiter) override
34  {
35  visiter.visit(this);
36  }
37 
39  virtual Opcode get_opcode (void) const = 0;
40 
42  virtual const ArgsT& get_children (void) const = 0;
43 
45  virtual void update_child (FuncArg arg, size_t index) = 0;
46 };
47 
49 using FuncptrT = std::shared_ptr<iFunctor>;
50 
51 }
52 
53 #endif // TEQ_IFUNCTOR_HPP
virtual const ArgsT & get_children(void) const =0
Return children nodes as a vector of raw pointers.
Encoding of operation.
Definition: ifunctor.hpp:18
void accept(iTraveler &visiter) override
Implementation of iTensor.
Definition: ifunctor.hpp:33
Interface of iOperation-defined operation node.
Definition: ifunctor.hpp:28
std::vector< FuncArg > ArgsT
Type of functor arguments.
Definition: funcarg.hpp:101
virtual void update_child(FuncArg arg, size_t index)=0
Update child at specified index.
std::string name_
String representation of operation.
Definition: ifunctor.hpp:21
Coordinate mapper and tensor pair.
Definition: funcarg.hpp:21
size_t code_
Numerical encoding of operation.
Definition: ifunctor.hpp:24
virtual Opcode get_opcode(void) const =0
Return operation encoding.
Interface to travel through graph, treating iLeaf and iFunctor differently.
Definition: itensor.hpp:24
virtual void visit(iLeaf *leaf)=0
Visit leaf node.
virtual ~iFunctor(void)=default
Definition: coord.hpp:16
Interface of traversible and differentiable nodes with shape information.
Definition: itensor.hpp:36
NElemT index(Shape shape, CoordT coord)
std::shared_ptr< iFunctor > FuncptrT
Functor smart pointer.
Definition: ifunctor.hpp:49