Om
default_incomplete_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_DefaultIncompleteOperation_
16 
18 
19 #else
20 
21  #include "om/language/evaluator.hpp"
22 
23 // MARK: - Om::Language::Operation::DefaultIncompleteOperation
24 
25  #define Template_ \
26  template <typename ThisImplementation>
27 
28  #define Type_ \
29  Om::Language::Operation::DefaultIncompleteOperation<ThisImplementation>
30 
31 // MARK: public (static)
32 
33 Template_
34 inline Om::Language::Operator const & Type_::GetOperator() {
35  static Operator const theOperator(
36  ThisImplementation::GetName()
37  );
38  return theOperator;
39 }
40 
41 Template_
42 inline void Type_::Give(Evaluation & theEvaluation) {
43  theEvaluation.TakeOperation(
44  std::auto_ptr<ThisImplementation>(new ThisImplementation)
45  );
46 }
47 
48 // MARK: public (non-static)
49 
50 Template_
51 inline Type_::~DefaultIncompleteOperation() {}
52 
53 Template_
54 inline void Type_::GiveElements(Consumer & theConsumer) {
55  assert(
56  dynamic_cast<ThisImplementation *>(this)
57  );
58  ThisImplementation::GiveElements(
59  static_cast<ThisImplementation &>(*this),
60  theConsumer
61  );
62 }
63 
64 Template_
65 inline void Type_::GiveElements(Consumer & theConsumer) const {
66  assert(
67  dynamic_cast<ThisImplementation const *>(this)
68  );
69  ThisImplementation::GiveElements(
70  static_cast<ThisImplementation const &>(*this),
71  theConsumer
72  );
73 }
74 
75 Template_
76 inline bool Type_::ParseQuotedElements(
77  Evaluation & theEvaluation,
78  Reader & theReader
79 ) {
80  Literal theLiteral;
81  theLiteral.ParseElements(theReader);
82  return this->TakeQuotedElements(
83  theEvaluation,
84  theLiteral
85  );
86 }
87 
88 Template_
89 inline bool Type_::TakeElement(
90  Evaluation & theEvaluation,
91  Operand & theOperand
92 ) {
93  assert(
94  !theOperand.IsEmpty()
95  );
96  assert(
97  dynamic_cast<ThisImplementation *>(this)
98  );
99  return static_cast<ThisImplementation &>(*this).TakeOperand(
100  theEvaluation,
101  theOperand
102  );
103 }
104 
105 Template_
106 inline bool Type_::TakeElement(
107  Evaluation & theEvaluation,
108  Operand const & theOperand
109 ) {
110  assert(
111  !theOperand.IsEmpty()
112  );
113  assert(
114  dynamic_cast<ThisImplementation *>(this)
115  );
116  return static_cast<ThisImplementation &>(*this).TakeOperand(
117  theEvaluation,
118  theOperand
119  );
120 }
121 
122 Template_
123 inline bool Type_::TakeQuotedElements(
124  Evaluation & theEvaluation,
125  Producer & theProducer
126 ) {
127  assert(
128  dynamic_cast<ThisImplementation *>(this)
129  );
130  return static_cast<ThisImplementation &>(*this).TakeQuotedProducer(
131  theEvaluation,
132  theProducer
133  );
134 }
135 
136 Template_
137 inline bool Type_::TakeQuotedElements(
138  Evaluation & theEvaluation,
139  Producer const & theProducer
140 ) {
141  assert(
142  dynamic_cast<ThisImplementation *>(this)
143  );
144  return static_cast<ThisImplementation &>(*this).TakeQuotedProducer(
145  theEvaluation,
146  theProducer
147  );
148 }
149 
150  #undef Type_
151  #undef Template_
152 
153 #endif
The Operator implementation.
Definition: operator.hpp:60
Om header file.
std::auto_ptr< TheGiveable > Give(TheGiveable &)
Calls Move on the object.