Om
front_push_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_FrontPushOperation_
16 
18 
19 #else
20 
22 
23 // MARK: - Om::Language::Operation::FrontPushOperation
24 
25  #define Template_ \
26  template < \
27  typename ThisProgram, \
28  typename ThisImplementation \
29  >
30 
31  #define Type_ \
32  Om::Language::Operation::FrontPushOperation< \
33  ThisProgram, \
34  ThisImplementation \
35  >
36 
37 // MARK: public (static)
38 
39 Template_
40 template <typename TheFrontPushOperation>
41 inline void Type_::GiveElements(
42  TheFrontPushOperation & theFrontPushOperation,
43  Consumer & theConsumer
44 ) {
45  theConsumer.TakeElement(
46  GetOperator()
47  );
48  if (
49  !theFrontPushOperation.thisProgram.IsEmpty()
50  ) {
51  theConsumer.TakeQuotedElements(theFrontPushOperation.thisProgram);
52  }
53 }
54 
55 // MARK: public (non-static)
56 
57 Template_
58 inline Type_::FrontPushOperation():
59 thisProgram() {}
60 
61 Template_
62 template <typename TheProducer>
63 inline bool Type_::TakeQuotedProducer(
64  Evaluation & theEvaluation,
65  TheProducer & theProducer
66 ) {
67  if (
68  this->thisProgram.IsEmpty()
69  ) {
70  this->thisProgram.TakeElements(theProducer);
71  if (
72  this->thisProgram.IsEmpty()
73  ) {
75  return true;
76  }
77  return false;
78  }
79  this->thisProgram.TakeElements(theProducer);
80  theEvaluation.TakeQuotedProducer(this->thisProgram);
81  return true;
82 }
83 
84 Template_
85 template <typename TheOperand>
86 inline bool Type_::TakeOperand(
87  Evaluation & theEvaluation,
88  TheOperand & theOperand
89 ) {
90  assert(
91  !theOperand.IsEmpty()
92  );
93  return this->TakeQuotedProducer(
94  theEvaluation,
95  *theOperand.GetProgram()
96  );
97 }
98 
99 // MARK: private (static)
100 
101 Template_
102 inline Om::Language::Operator const & Type_::GetOperator() {
103  static Operator const theOperator(
104  ThisImplementation::GetName()
105  );
106  return theOperator;
107 }
108 
109  #undef Type_
110  #undef Template_
111 
112 #endif
The Operator implementation.
Definition: operator.hpp:60
std::auto_ptr< TheGiveable > Give(TheGiveable &)
Calls Move on the object.
Om header file.