Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Teuchos_StandardConditions.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Teuchos: Common Tools Package
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42
43#ifndef TEUCHOS_STANDARDCONDITION_HPP_
44#define TEUCHOS_STANDARDCONDITION_HPP_
45
50#include "Teuchos_Condition.hpp"
56
57
58namespace Teuchos{
59
60
69
70public:
71
74
81
83
85
87
88
96 virtual bool evaluateParameter() const = 0;
97
102 return parameterEntry_.getConst();
103 }
104
106
109
110 bool isConditionTrue() const{
111 return evaluateParameter();
112 }
113
115 return true;
116 }
117
118 Dependency::ConstParameterEntryList getAllParameters() const;
119
121
122private:
123
126
131
133
134};
135
145
146public:
147
150
155
157
160
168 StringCondition(RCP<const ParameterEntry> parameter, std::string value);
169
177
179
181
184
185 std::string getTypeAttributeValue() const{
186 return "StringCondition";
187 }
188
190
193
194 bool evaluateParameter() const;
195
197
200
202 const ValueList& getValueList() const{
203 return values_;
204 }
205
207
208private:
209
212
217
219 void checkParameterType();
220
222
223};
224
225
231template<>
233
234public:
235
238
242 static RCP<StringCondition> getDummyObject();
243
245
246};
247
248
259template<class T>
261
262public:
263
266
279 RCP<const SimpleFunctionObject<T> > func=null):
280 ParameterCondition(parameter),
281 func_(func)
282 {}
283
285
287
290
291 std::string getTypeAttributeValue() const{
292 return "NumberCondition(" + TypeNameTraits<T>::name() + ")";
293 }
294
296
299
301 bool evaluateParameter() const{
302 T value = getValue<T>(*getParameter());
303 if(!func_.is_null()){
304 value = func_->runFunction(value);
305 }
306 return value > 0;
307 }
308
310
313
318 return func_.getConst();
319 }
320
322
323private:
324
327
330
332
333};
334
335
341template<class T>
343
344public:
345
348
353
355
356};
357
358template<class T>
361{
362 return rcp(new NumberCondition<T>(
364}
365
366
375
376public:
377
380
387
388 virtual ~BoolCondition(){}
389
391
394
395 std::string getTypeAttributeValue() const{
396 return "BoolCondition";
397 }
398
400
403
404 bool evaluateParameter() const;
405
407
408};
409
410
416template<>
418
419public:
420
423
427 static RCP<BoolCondition > getDummyObject();
428
430
431};
432
433
442
443public:
444
447
454
459
461
465
473 void addCondition(RCP<const Condition> toAdd);
474
476
478
479
489 virtual bool applyOperator(bool op1, bool op2) const = 0;
490
495 inline
497 return conditions_;
498 }
499
501
504
506 virtual bool isConditionTrue() const;
507
509 bool containsAtLeasteOneParameter() const;
510
512 Dependency::ConstParameterEntryList getAllParameters() const;
513
515
516private:
517
520
521 /*
522 * \brief A list of conditions on which to perform some logic operation.
523 */
525
527
528};
529
538
539public:
540
543
549 OrCondition(ConstConditionList& conditions);
550
554 virtual ~OrCondition(){}
555
557
560
561 std::string getTypeAttributeValue() const{
562 return "OrCondition";
563 }
564
566
569
571 bool applyOperator(bool op1, bool op2) const;
572
574
575};
576
577
583template<>
585
586public:
587
590
594 static RCP<OrCondition> getDummyObject();
595
597
598};
599
600
609
610public:
611
614
620 AndCondition(ConstConditionList& conditions);
621
625 virtual ~AndCondition(){}
626
628
631
632 std::string getTypeAttributeValue() const{
633 return "AndCondition";
634 }
635
637
638
641
643 bool applyOperator(bool op1, bool op2) const;
644
646
647};
648
649
655template<>
657
658public:
659
662
666 static RCP<AndCondition > getDummyObject();
667
669
670};
671
672
681
682public:
683
686
693
698
700
703
704 std::string getTypeAttributeValue() const{
705 return "EqualsCondition";
706 }
707
709
712
714 bool applyOperator(bool op1, bool op2) const;
715
717
718};
719
720
726template<>
728
729public:
730
733
737 static RCP<EqualsCondition > getDummyObject();
738
740
741};
742
743
753
754public:
755
758
765
769 virtual ~NotCondition(){}
770
772
775
778 return childCondition_;
779 }
780
782
785
787 bool isConditionTrue() const;
788
790 bool containsAtLeasteOneParameter() const;
791
793 Dependency::ConstParameterEntryList getAllParameters() const;
794
795 std::string getTypeAttributeValue() const{
796 return "NotCondition";
797 }
798
800
801private:
802
805
810
812
813};
814
815
821template<>
823
824public:
825
828
832 static RCP<NotCondition> getDummyObject();
833
835
836};
837
838} //namespace Teuchos
839
840
841#endif //TEUCHOS_STANDARDCONDITION_HPP_
An object to determin if a particular set of conditions are occuring.
#define TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT
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...
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
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 > childCondition_
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...
RCP< const SimpleFunctionObject< T > > func_
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
RCP< const ParameterEntry > parameterEntry_
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.
A simple function object that applies a given operand to a spcified arguement using a specific operat...
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.
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.