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

Generic Substitution rule to replace all occurences of a given symbol node term with a user defined term. More...

#include <ExpressionBuilder.h>

Inheritance diagram for ExpressionBuilder::EBTermSubstitution:
[legend]

Public Member Functions

 EBTermSubstitution (const EBTerm &find, const EBTerm &replace)
 
virtual ~EBTermSubstitution ()
 
virtual EBTermNodeapply (const EBTermNode *) const
 

Protected Member Functions

virtual EBTermNodesubstitute (const EBSymbolNode &) const
 

Protected Attributes

std::string _find
 
EBTermNode_replace
 

Detailed Description

Generic Substitution rule to replace all occurences of a given symbol node term with a user defined term.

This is used by EBFunction.

Definition at line 324 of file ExpressionBuilder.h.

Constructor & Destructor Documentation

◆ EBTermSubstitution()

ExpressionBuilder::EBTermSubstitution::EBTermSubstitution ( const EBTerm find,
const EBTerm replace 
)

Definition at line 443 of file ExpressionBuilder.C.

445 {
446  // the expression we want to substitute (has to be a symbol node)
447  const EBSymbolNode * find_root = dynamic_cast<const EBSymbolNode *>(find.getRoot());
448  if (find_root == NULL)
449  mooseError("Function arguments must be pure symbols.");
450  _find = find_root->stringify();
451 
452  // the term we want to substitute with
453  if (replace.getRoot() != NULL)
454  _replace = replace.cloneRoot();
455  else
456  mooseError("Trying to substitute in an empty term for ", _find);
457 }

◆ ~EBTermSubstitution()

virtual ExpressionBuilder::EBTermSubstitution::~EBTermSubstitution ( )
inlinevirtual

Definition at line 328 of file ExpressionBuilder.h.

328 { delete _replace; }

Member Function Documentation

◆ apply()

Implements ExpressionBuilder::EBSubstitutionRule.

Definition at line 694 of file ExpressionBuilder.h.

696 {
697  const Node_T * match_node = dynamic_cast<const Node_T *>(node);
698  if (match_node == NULL)
699  return NULL;
700  else
701  return substitute(*match_node);
702 }
virtual EBTermNode * substitute(const EBSymbolNode &) const=0

◆ substitute()

ExpressionBuilder::EBTermNode * ExpressionBuilder::EBTermSubstitution::substitute ( const EBSymbolNode node) const
protectedvirtual

Implements ExpressionBuilder::EBSubstitutionRuleTyped< EBSymbolNode >.

Definition at line 460 of file ExpressionBuilder.C.

461 {
462  if (node.stringify() == _find)
463  return _replace->clone();
464  else
465  return NULL;
466 }
virtual EBTermNode * clone() const =0

Member Data Documentation

◆ _find

std::string ExpressionBuilder::EBTermSubstitution::_find
protected

Definition at line 331 of file ExpressionBuilder.h.

◆ _replace

EBTermNode* ExpressionBuilder::EBTermSubstitution::_replace
protected

Definition at line 332 of file ExpressionBuilder.h.


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