www.mooseframework.org
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
ExpressionBuilder::EBTernaryFuncTermNode Class Reference

Node representing a function with three arguments. More...

#include <ExpressionBuilder.h>

Inheritance diagram for ExpressionBuilder::EBTernaryFuncTermNode:
[legend]

Public Types

enum  NodeType { CONDITIONAL }
 

Public Member Functions

 EBTernaryFuncTermNode (EBTermNode *left, EBTermNode *middle, EBTermNode *right, NodeType type)
 
virtual EBTernaryFuncTermNodeclone () const
 
virtual std::string stringify () const
 
virtual int precedence () const
 
virtual unsigned int substitute (const EBSubstitutionRuleList &rule)
 

Public Attributes

enum ExpressionBuilder::EBTernaryFuncTermNode::NodeType _type
 

Protected Attributes

EBTermNode_middle
 
EBTermNode_left
 
EBTermNode_right
 

Detailed Description

Node representing a function with three arguments.

Definition at line 273 of file ExpressionBuilder.h.

Member Enumeration Documentation

Enumerator
CONDITIONAL 

Definition at line 276 of file ExpressionBuilder.h.

277  {
279  } _type;
enum ExpressionBuilder::EBTernaryFuncTermNode::NodeType _type

Constructor & Destructor Documentation

ExpressionBuilder::EBTernaryFuncTermNode::EBTernaryFuncTermNode ( EBTermNode left,
EBTermNode middle,
EBTermNode right,
NodeType  type 
)
inline

Definition at line 281 of file ExpressionBuilder.h.

282  : EBTernaryTermNode(left, middle, right), _type(type){};
enum ExpressionBuilder::EBTernaryFuncTermNode::NodeType _type
EBTernaryTermNode(EBTermNode *left, EBTermNode *middle, EBTermNode *right)

Member Function Documentation

virtual EBTernaryFuncTermNode* ExpressionBuilder::EBTernaryFuncTermNode::clone ( ) const
inlinevirtual

Implements ExpressionBuilder::EBTermNode.

Definition at line 283 of file ExpressionBuilder.h.

284  {
286  };
enum ExpressionBuilder::EBTernaryFuncTermNode::NodeType _type
virtual EBTermNode * clone() const =0
EBTernaryFuncTermNode(EBTermNode *left, EBTermNode *middle, EBTermNode *right, NodeType type)
virtual int ExpressionBuilder::EBTernaryFuncTermNode::precedence ( ) const
inlinevirtual

Implements ExpressionBuilder::EBTermNode.

Definition at line 289 of file ExpressionBuilder.h.

289 { return 2; }
std::string ExpressionBuilder::EBTernaryFuncTermNode::stringify ( ) const
virtual

Implements ExpressionBuilder::EBTermNode.

Definition at line 141 of file ExpressionBuilder.C.

142 {
143  const char * name[] = {"if"};
144  std::ostringstream s;
145  s << name[_type] << '(' << *_left << ',' << *_middle << ',' << *_right << ')';
146  return s.str();
147 }
enum ExpressionBuilder::EBTernaryFuncTermNode::NodeType _type
unsigned int ExpressionBuilder::EBTernaryTermNode::substitute ( const EBSubstitutionRuleList rule)
virtualinherited

Reimplemented from ExpressionBuilder::EBBinaryTermNode.

Definition at line 358 of file ExpressionBuilder.C.

359 {
360  unsigned int nrule = rules.size();
361  bool left_success = false, middle_success = false, right_success = false;
362  EBTermNode * replace;
363 
364  for (unsigned int i = 0; i < nrule; ++i)
365  {
366  replace = rules[i]->apply(_left);
367  if (replace)
368  {
369  delete _left;
370  _left = replace;
371  left_success = true;
372  break;
373  }
374  }
375 
376  for (unsigned int i = 0; i < nrule; ++i)
377  {
378  replace = rules[i]->apply(_middle);
379  if (replace)
380  {
381  delete _middle;
382  _middle = replace;
383  middle_success = true;
384  break;
385  }
386  }
387 
388  for (unsigned int i = 0; i < nrule; ++i)
389  {
390  replace = rules[i]->apply(_right);
391  if (replace)
392  {
393  delete _right;
394  _right = replace;
395  right_success = true;
396  break;
397  }
398  }
399 
400  if (!left_success)
401  left_success = _left->substitute(rules);
402  if (!middle_success)
403  middle_success = _middle->substitute(rules);
404  if (!right_success)
405  right_success = _right->substitute(rules);
406 
407  return left_success + middle_success + right_success;
408 }
virtual unsigned int substitute(const EBSubstitutionRuleList &)

Member Data Documentation

EBTermNode* ExpressionBuilder::EBBinaryTermNode::_left
protectedinherited

Definition at line 196 of file ExpressionBuilder.h.

EBTermNode* ExpressionBuilder::EBTernaryTermNode::_middle
protectedinherited

Definition at line 269 of file ExpressionBuilder.h.

EBTermNode* ExpressionBuilder::EBBinaryTermNode::_right
protectedinherited

Definition at line 197 of file ExpressionBuilder.h.

enum ExpressionBuilder::EBTernaryFuncTermNode::NodeType ExpressionBuilder::EBTernaryFuncTermNode::_type

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