Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_StandardConditions.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_STANDARDCONDITION_HPP_
11 #define TEUCHOS_STANDARDCONDITION_HPP_
12 
17 #include "Teuchos_Condition.hpp"
22 #include "Teuchos_ScalarTraits.hpp"
23 
24 
25 namespace Teuchos{
26 
27 
36 
37 public:
38 
41 
48 
49  virtual ~ParameterCondition(){}
50 
52 
54 
55 
63  virtual bool evaluateParameter() const = 0;
64 
69  return parameterEntry_.getConst();
70  }
71 
73 
76 
77  bool isConditionTrue() const{
78  return evaluateParameter();
79  }
80 
82  return true;
83  }
84 
85  Dependency::ConstParameterEntryList getAllParameters() const;
86 
88 
89 private:
90 
93 
98 
100 
101 };
102 
112 
113 public:
114 
117 
122 
124 
127 
135  StringCondition(RCP<const ParameterEntry> parameter, std::string value);
136 
144 
145  virtual ~StringCondition(){}
146 
148 
151 
152  std::string getTypeAttributeValue() const{
153  return "StringCondition";
154  }
155 
157 
160 
161  bool evaluateParameter() const;
162 
164 
167 
169  const ValueList& getValueList() const{
170  return values_;
171  }
172 
174 
175 private:
176 
179 
184 
186  void checkParameterType();
187 
189 
190 };
191 
192 
198 template<>
200 
201 public:
202 
205 
209  static RCP<StringCondition> getDummyObject();
210 
212 
213 };
214 
215 
226 template<class T>
228 
229 public:
230 
233 
245  RCP<const ParameterEntry> parameter,
246  RCP<const SimpleFunctionObject<T> > func=null):
247  ParameterCondition(parameter),
248  func_(func)
249  {}
250 
251  virtual ~NumberCondition(){}
252 
254 
257 
258  std::string getTypeAttributeValue() const{
259  return "NumberCondition(" + TypeNameTraits<T>::name() + ")";
260  }
261 
263 
266 
268  bool evaluateParameter() const{
269  T value = getValue<T>(*getParameter());
270  if(!func_.is_null()){
271  value = func_->runFunction(value);
272  }
273  return value > 0;
274  }
275 
277 
280 
285  return func_.getConst();
286  }
287 
289 
290 private:
291 
294 
297 
299 
300 };
301 
302 
308 template<class T>
310 
311 public:
312 
315 
320 
322 
323 };
324 
325 template<class T>
328 {
329  return rcp(new NumberCondition<T>(
331 }
332 
333 
342 
343 public:
344 
347 
354 
355  virtual ~BoolCondition(){}
356 
358 
361 
362  std::string getTypeAttributeValue() const{
363  return "BoolCondition";
364  }
365 
367 
370 
371  bool evaluateParameter() const;
372 
374 
375 };
376 
377 
383 template<>
385 
386 public:
387 
390 
394  static RCP<BoolCondition > getDummyObject();
395 
397 
398 };
399 
400 
409 
410 public:
411 
414 
420  BoolLogicCondition(ConstConditionList& conditions);
421 
426 
428 
432 
440  void addCondition(RCP<const Condition> toAdd);
441 
443 
445 
446 
456  virtual bool applyOperator(bool op1, bool op2) const = 0;
457 
462  inline
463  const ConstConditionList& getConditions() const{
464  return conditions_;
465  }
466 
468 
471 
473  virtual bool isConditionTrue() const;
474 
476  bool containsAtLeasteOneParameter() const;
477 
479  Dependency::ConstParameterEntryList getAllParameters() const;
480 
482 
483 private:
484 
487 
488  /*
489  * \brief A list of conditions on which to perform some logic operation.
490  */
491  ConstConditionList conditions_;
492 
494 
495 };
496 
505 
506 public:
507 
510 
516  OrCondition(ConstConditionList& conditions);
517 
521  virtual ~OrCondition(){}
522 
524 
527 
528  std::string getTypeAttributeValue() const{
529  return "OrCondition";
530  }
531 
533 
536 
538  bool applyOperator(bool op1, bool op2) const;
539 
541 
542 };
543 
544 
550 template<>
552 
553 public:
554 
557 
561  static RCP<OrCondition> getDummyObject();
562 
564 
565 };
566 
567 
576 
577 public:
578 
581 
587  AndCondition(ConstConditionList& conditions);
588 
592  virtual ~AndCondition(){}
593 
595 
598 
599  std::string getTypeAttributeValue() const{
600  return "AndCondition";
601  }
602 
604 
605 
608 
610  bool applyOperator(bool op1, bool op2) const;
611 
613 
614 };
615 
616 
622 template<>
624 
625 public:
626 
629 
633  static RCP<AndCondition > getDummyObject();
634 
636 
637 };
638 
639 
648 
649 public:
650 
653 
659  EqualsCondition(ConstConditionList& conditions);
660 
664  virtual ~EqualsCondition(){}
665 
667 
670 
671  std::string getTypeAttributeValue() const{
672  return "EqualsCondition";
673  }
674 
676 
679 
681  bool applyOperator(bool op1, bool op2) const;
682 
684 
685 };
686 
687 
693 template<>
695 
696 public:
697 
700 
704  static RCP<EqualsCondition > getDummyObject();
705 
707 
708 };
709 
710 
720 
721 public:
722 
725 
732 
736  virtual ~NotCondition(){}
737 
739 
742 
745  return childCondition_;
746  }
747 
749 
752 
754  bool isConditionTrue() const;
755 
757  bool containsAtLeasteOneParameter() const;
758 
760  Dependency::ConstParameterEntryList getAllParameters() const;
761 
762  std::string getTypeAttributeValue() const{
763  return "NotCondition";
764  }
765 
767 
768 private:
769 
772 
777 
779 
780 };
781 
782 
788 template<>
790 
791 public:
792 
795 
799  static RCP<NotCondition> getDummyObject();
800 
802 
803 };
804 
805 } //namespace Teuchos
806 
807 
808 #endif //TEUCHOS_STANDARDCONDITION_HPP_
A Bool Logic Condition that returns the result or perfroming a logical OR on the conditions.
RCP< const ParameterEntry > parameterEntry_
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
virtual ~NotCondition()
Deconstructs a Not Condition.
std::set< RCP< const ParameterEntry >, RCPConstComp > ConstParameterEntryList
A list of dependents.
Array< std::string > ValueList
Convience typedef representing an array of strings.
This object is held as the &quot;value&quot; in the Teuchos::ParameterList std::map.
A Bool Logic Condition that returns the result or perfroming a logical AND on the conditions...
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
A Not condition returns the result of performing a logical NOT on a given condition.
An object to determin if a particular set of conditions are occuring.
const ValueList & getValueList() const
Returns the value list being used with this StringCondition.
A Number Condition is a Parameter Condition that evaluates whether or not a number parameter is great...
NumberCondition(RCP< const ParameterEntry > parameter, RCP< const SimpleFunctionObject< T > > func=null)
Constructs a Number Condition.
virtual ~EqualsCondition()
Deconstructs an Equals Condition.
This structure defines some basic traits for a scalar field type.
RCP< const Condition > childCondition_
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
RCP< const SimpleFunctionObject< T > > getFunctionObject() const
Gets the funciton this NumberCondition is using. Returns null if the NumberCondition is not using one...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated Parameter List class.
A String Condition is a Parameter Condition that evaluates whether or not a string parameter has take...
virtual ~OrCondition()
Deconstructs an Or Condition.
A Bool Logic Condition that returns the result or perfroming a logical EQUALS on the conditions...
RCP< const Condition > getChildCondition() const
Retrieve the child condition.
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
A Bool Condition is a Parameter Condition that evaluates whether or not a Boolean parameter is ture...
virtual ~BoolLogicCondition()
Deconstructor for a BoolLogicCondition.
const ConstConditionList & getConditions() const
Gets a list of all conditions that are a part of this BoolLogicCondition/.
Class for retrieving a dummy object of type T.
A Condition determines whether or not a particular set of conditions are currently occuring...
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
Defines basic traits for the scalar field type.
virtual ~AndCondition()
Deconstructs an And Condition.
An abstract parent class for all Bool Logic Conditions.
RCP< const ParameterEntry > getParameter() const
Gets a const pointer to the Parameter being evaluated by this ParameterCondition. ...
bool isConditionTrue() const
Determins whether or not a condition is true.
Smart reference counting pointer class for automatic garbage collection.
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
An Abstract Base class for all ParameterConditions.
bool containsAtLeasteOneParameter() const
Determines whether or not the evaluation of a parameter occurs somewhere in this condition.
RCP< const SimpleFunctionObject< T > > func_