Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
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"
18#include "Teuchos_InvalidConditionException.hpp"
20#include "Teuchos_StandardFunctionObjects.hpp"
23
24
25namespace Teuchos{
26
27
35class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT ParameterCondition : public Condition{
36
37public:
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
89private:
90
93
97 RCP<const ParameterEntry> parameterEntry_;
98
100
101};
102
111class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT StringCondition : public ParameterCondition{
112
113public:
114
117
122
124
127
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
175private:
176
179
183 ValueList values_;
184
186 void checkParameterType();
187
189
190};
191
192
198template<>
199class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<StringCondition>{
200
201public:
202
205
209 static RCP<StringCondition> getDummyObject();
210
212
213};
214
215
226template<class T>
228
229public:
230
233
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
287
289
290private:
291
294
297
299
300};
301
302
308template<class T>
310
311public:
312
315
320
322
323};
324
325template<class T>
328{
329 return rcp(new NumberCondition<T>(
331}
332
333
341class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT BoolCondition : public ParameterCondition{
342
343public:
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
383template<>
384class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<BoolCondition>{
385
386public:
387
390
394 static RCP<BoolCondition > getDummyObject();
395
397
398};
399
400
408class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT BoolLogicCondition : public Condition{
409
410public:
411
414
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
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
483private:
484
487
488 /*
489 * \brief A list of conditions on which to perform some logic operation.
490 */
491 ConstConditionList conditions_;
492
494
495};
496
504class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT OrCondition : public BoolLogicCondition{
505
506public:
507
510
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
550template<>
551class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<OrCondition>{
552
553public:
554
557
561 static RCP<OrCondition> getDummyObject();
562
564
565};
566
567
575class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT AndCondition : public BoolLogicCondition{
576
577public:
578
581
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
622template<>
623class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<AndCondition>{
624
625public:
626
629
633 static RCP<AndCondition > getDummyObject();
634
636
637};
638
639
647class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT EqualsCondition : public BoolLogicCondition{
648
649public:
650
653
660
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
693template<>
694class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<EqualsCondition>{
695
696public:
697
700
704 static RCP<EqualsCondition > getDummyObject();
705
707
708};
709
710
719class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT NotCondition : public Condition{
720
721public:
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
768private:
769
772
776 RCP<const Condition> childCondition_;
777
779
780};
781
782
788template<>
789class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT DummyObjectGetter<NotCondition>{
790
791public:
792
795
799 static RCP<NotCondition> getDummyObject();
800
802
803};
804
805} //namespace Teuchos
806
807
808#endif //TEUCHOS_STANDARDCONDITION_HPP_
An object to determin if a particular set of conditions are occuring.
Templated Parameter List class.
Defines basic traits for the scalar field type.
A Bool Logic Condition that returns the result or perfroming a logical AND on the conditions.
virtual ~AndCondition()
Deconstructs an And Condition.
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
A Bool Condition is a Parameter Condition that evaluates whether or not a Boolean parameter is ture.
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
An abstract parent class for all Bool Logic Conditions.
const ConstConditionList & getConditions() const
Gets a list of all conditions that are a part of this BoolLogicCondition/.
virtual ~BoolLogicCondition()
Deconstructor for a BoolLogicCondition.
virtual bool applyOperator(bool op1, bool op2) const =0
Applies a Bool Logic operator to two operands and returns the result.
A Condition determines whether or not a particular set of conditions are currently occuring.
std::set< RCP< const ParameterEntry >, RCPConstComp > ConstParameterEntryList
A list of dependents.
Class for retrieving a dummy object of type T.
static RCP< T > getDummyObject()
Retrieves a dummy object of type T.
A Bool Logic Condition that returns the result or perfroming a logical EQUALS 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...
virtual ~EqualsCondition()
Deconstructs an Equals Condition.
A Not condition returns the result of performing a logical NOT on a given condition.
RCP< const Condition > getChildCondition() const
Retrieve the child condition.
virtual ~NotCondition()
Deconstructs a Not Condition.
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
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.
RCP< const SimpleFunctionObject< T > > getFunctionObject() const
Gets the funciton this NumberCondition is using. Returns null if the NumberCondition is not using one...
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
A Bool Logic Condition that returns the result or perfroming a logical OR 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...
virtual ~OrCondition()
Deconstructs an Or Condition.
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 ParameterEntry > getParameter() const
Gets a const pointer to the Parameter being evaluated by this ParameterCondition.
virtual bool evaluateParameter() const =0
bool isConditionTrue() const
Determins whether or not a condition is true.
This object is held as the "value" in the Teuchos::ParameterList std::map.
Smart reference counting pointer class for automatic garbage collection.
RCP< const T > getConst() const
Return an RCP<const T> version of *this.
bool is_null() const
Returns true if the underlying pointer is null.
A String Condition is a Parameter Condition that evaluates whether or not a string parameter has take...
std::string getTypeAttributeValue() const
Get the value that should be used for the condition type attribute when converting a condition to XML...
Array< std::string > ValueList
Convience typedef representing an array of strings.
const ValueList & getValueList() const
Returns the value list being used with this StringCondition.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
This structure defines some basic traits for a scalar field type.