EpetraExt  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 #include <EpetraExt_Transform.h>
50 
51 #include <list>
52 
53 namespace EpetraExt {
54 
56 
59 template<typename T>
61 {
62 
63  public:
64 
66 
69 
71  virtual ~Transform_Composite();
72 
74 
77  void addTransform( TransformTypePtr new_trans );
78 
80 
87  virtual
89  operator()
90  ( typename Transform<T,T>::OriginalTypeRef orig );
91 
93 
98  virtual bool fwd();
99 
101 
105  virtual bool rvs();
106 
107  protected:
108 
109  typedef typename std::list<TransformTypePtr>::iterator TransListIter;
110  typedef typename std::list<TransformTypePtr>::reverse_iterator TransListRvsIter;
111 
112  std::list<TransformTypePtr> transList_;
113 
114 }; // end class Tranform_Composite
115 
116 template<typename T>
119 {
120  TransListIter iter = transList_.begin();
121  TransListIter end = transList_.end();
122  for( ; iter != end; ++iter ) delete *iter;
123 }
124 
125 template<typename T>
126 void
129 {
130  transList_.push_back( new_trans );
131 }
132 
133 template<typename T>
136 operator()
137 ( typename Transform<T,T>::OriginalTypeRef orig )
138 {
139  this->origObj_ = &orig;
140  this->newObj_ = &orig;
141 
142  TransListIter iter = transList_.begin();
143  TransListIter end = transList_.end();
144  for( ; iter != end; ++iter )
145  this->newObj_ = &((**iter)( *(this->newObj_) ));
146 
147  return *(this->newObj_);
148 }
149 
150 template<typename T>
151 bool
154 {
155  bool success = true;
156 
157  TransListIter iter = transList_.begin();
158  TransListIter end = transList_.end();
159  for( ; iter != end; ++iter )
160  if( !(**iter).fwd() ) return false;
161 
162  return success;
163 }
164 
165 template<typename T>
166 bool
169 {
170  bool success = true;
171 
172  TransListRvsIter iter = transList_.rbegin();
173  TransListRvsIter end = transList_.rend();
174  for( ; iter != end; ++iter )
175  if( !(**iter).rvs() ) return false;
176 
177  return success;
178 }
179 
180 } //namespace EpetraExt
181 
182 #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.