EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_Transform_Composite.h
Go to the documentation of this file.
1 //@HEADER
2 // ***********************************************************************
3 //
4 // EpetraExt: Epetra Extended - Linear Algebra Services Package
5 // Copyright (2011) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
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 // EpetraExt_Transform_Composite.h
44 //-----------------------------------------------------------------------
45 
46 #ifndef EPETRAEXT_TRANSFORM_COMPOSITE_H
47 #define EPETRAEXT_TRANSFORM_COMPOSITE_H
48 
49 #if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS)
50 #ifdef __GNUC__
51 #warning "The EpetraExt package is deprecated"
52 #endif
53 #endif
54 
55 #include <EpetraExt_Transform.h>
56 
57 #include <list>
58 
59 namespace EpetraExt {
60 
62 
65 template<typename T>
67 {
68 
69  public:
70 
72 
75 
77  virtual ~Transform_Composite();
78 
80 
83  void addTransform( TransformTypePtr new_trans );
84 
86 
93  virtual
95  operator()
96  ( typename Transform<T,T>::OriginalTypeRef orig );
97 
99 
104  virtual bool fwd();
105 
107 
111  virtual bool rvs();
112 
113  protected:
114 
115  typedef typename std::list<TransformTypePtr>::iterator TransListIter;
116  typedef typename std::list<TransformTypePtr>::reverse_iterator TransListRvsIter;
117 
118  std::list<TransformTypePtr> transList_;
119 
120 }; // end class Tranform_Composite
121 
122 template<typename T>
125 {
126  TransListIter iter = transList_.begin();
127  TransListIter end = transList_.end();
128  for( ; iter != end; ++iter ) delete *iter;
129 }
130 
131 template<typename T>
132 void
135 {
136  transList_.push_back( new_trans );
137 }
138 
139 template<typename T>
142 operator()
143 ( typename Transform<T,T>::OriginalTypeRef orig )
144 {
145  this->origObj_ = &orig;
146  this->newObj_ = &orig;
147 
148  TransListIter iter = transList_.begin();
149  TransListIter end = transList_.end();
150  for( ; iter != end; ++iter )
151  this->newObj_ = &((**iter)( *(this->newObj_) ));
152 
153  return *(this->newObj_);
154 }
155 
156 template<typename T>
157 bool
160 {
161  bool success = true;
162 
163  TransListIter iter = transList_.begin();
164  TransListIter end = transList_.end();
165  for( ; iter != end; ++iter )
166  if( !(**iter).fwd() ) return false;
167 
168  return success;
169 }
170 
171 template<typename T>
172 bool
175 {
176  bool success = true;
177 
178  TransListRvsIter iter = transList_.rbegin();
179  TransListRvsIter end = transList_.rend();
180  for( ; iter != end; ++iter )
181  if( !(**iter).rvs() ) return false;
182 
183  return success;
184 }
185 
186 } //namespace EpetraExt
187 
188 #endif //EPETRAEXT_TRANSFORM_COMPOSITE_H
Composition Class for Epetra Transform SameType Operators.
Base Class for all Epetra Transform Operators.
virtual bool fwd()
Forward Data Transfer.
Transform< T, T >::NewTypeRef Transform_Composite< T >typename Transform< T, T >::OriginalTypeRef orig this origObj_
Transform_Composite()
EpetraExt::Transform_Composite Constructor.
void addTransform(TransformTypePtr new_trans)
Transform Addition.
std::list< TransformTypePtr >::reverse_iterator TransListRvsIter
std::list< TransformTypePtr >::iterator TransListIter
std::list< TransformTypePtr > transList_
virtual ~Transform_Composite()
EpetraExt::Transform_Composite Destructor.