Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
core
src
Teuchos_AbstractFactoryStd.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
#ifndef TEUCHOS_ABSTRACT_FACTORY_STD_HPP
43
#define TEUCHOS_ABSTRACT_FACTORY_STD_HPP
44
45
#include "
Teuchos_AbstractFactory.hpp
"
46
47
namespace
Teuchos {
48
52
template
<
class
T_impl>
53
class
PostModNothing
{
54
public
:
56
void
initialize
(T_impl*
/* p */
)
const
{}
// required!
57
};
58
62
template
<
class
T_impl>
63
class
AllocatorNew
{
64
public
:
66
typedef
Teuchos::RCP<T_impl>
ptr_t
;
// required!
68
const
ptr_t
allocate
()
const
{
return
Teuchos::rcp
(
new
T_impl()); }
// required!
69
};
70
138
template
<
class
T_itfc,
class
T_impl
139
,
class
T_PostMod = PostModNothing<T_impl>
140
,
class
T_Allocator = AllocatorNew<T_impl>
141
>
142
class
AbstractFactoryStd
:
public
AbstractFactory
<T_itfc> {
143
public
:
144
145
typedef
typename
Teuchos::AbstractFactory<T_itfc>::obj_ptr_t
obj_ptr_t
;
// RAB: 20030916: G++ 3.2 complains without this
146
148
AbstractFactoryStd
(
const
T_PostMod& post_mod = T_PostMod(),
const
T_Allocator& alloc = T_Allocator() );
149
153
obj_ptr_t
create
()
const
;
155
156
private
:
157
T_PostMod
post_mod_
;
158
T_Allocator
alloc_
;
159
160
};
161
162
167
template
<
class
T_itfc,
class
T_impl>
168
RCP<const AbstractFactory<T_itfc>
>
169
abstractFactoryStd
()
170
{
171
return
rcp
(
172
new
AbstractFactoryStd
<T_itfc,T_impl,
PostModNothing<T_impl>
,
AllocatorNew<T_impl>
>()
173
);
174
}
175
176
181
template
<
class
T_itfc,
class
T_impl,
class
T_Allocator>
182
RCP<const AbstractFactory<T_itfc>
>
183
abstractFactoryStd(
const
T_Allocator& alloc = T_Allocator() )
184
{
185
return
rcp
(
186
new
AbstractFactoryStd
<T_itfc,T_impl,
PostModNothing<T_impl>
,T_Allocator>(
187
PostModNothing<T_impl>
(), alloc
188
)
189
);
190
}
191
192
193
// ///////////////////////////////////////////////////////
194
// Template member definitions
195
196
template
<
class
T_itfc,
class
T_impl,
class
T_PostMod,
class
T_Allocator>
197
inline
198
AbstractFactoryStd<T_itfc,T_impl,T_PostMod,T_Allocator>::AbstractFactoryStd
(
199
const
T_PostMod& post_mod,
const
T_Allocator& alloc
200
)
201
:post_mod_(post_mod)
202
,alloc_(alloc)
203
{}
204
205
template
<
class
T_itfc,
class
T_impl,
class
T_PostMod,
class
T_Allocator>
206
inline
207
typename
AbstractFactoryStd<T_itfc,T_impl,T_PostMod,T_Allocator>::obj_ptr_t
208
AbstractFactoryStd<T_itfc,T_impl,T_PostMod,T_Allocator>::create
()
const
209
{
210
typename
T_Allocator::ptr_t
211
ptr = alloc_.allocate();
212
post_mod_.initialize(ptr.get());
213
return
ptr;
214
}
215
216
}
// end Teuchos
217
218
#endif // TEUCHOS_ABSTRACT_FACTORY_STD_HPP
Teuchos::AllocatorNew::allocate
const ptr_t allocate() const
Definition:
Teuchos_AbstractFactoryStd.hpp:68
Teuchos_AbstractFactory.hpp
Teuchos::AbstractFactoryStd::AbstractFactoryStd
AbstractFactoryStd(const T_PostMod &post_mod=T_PostMod(), const T_Allocator &alloc=T_Allocator())
Definition:
Teuchos_AbstractFactoryStd.hpp:198
Teuchos::AbstractFactoryStd
Simple, templated concrete subclass of universal "Abstract Factory" interface for the creation of o...
Definition:
Teuchos_AbstractFactoryStd.hpp:142
Teuchos::AllocatorNew::ptr_t
Teuchos::RCP< T_impl > ptr_t
Definition:
Teuchos_AbstractFactoryStd.hpp:66
Teuchos::AbstractFactoryStd::obj_ptr_t
Teuchos::AbstractFactory< T_itfc >::obj_ptr_t obj_ptr_t
Definition:
Teuchos_AbstractFactoryStd.hpp:145
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Definition:
Teuchos_RCPDecl.hpp:1242
Teuchos::AbstractFactoryStd::abstractFactoryStd
RCP< const AbstractFactory< T_itfc > > abstractFactoryStd()
Nonmember constructor for an standar abstract factory object.
Definition:
Teuchos_AbstractFactoryStd.hpp:169
Teuchos::AbstractFactoryStd::create
obj_ptr_t create() const
Definition:
Teuchos_AbstractFactoryStd.hpp:208
Teuchos::PostModNothing::initialize
void initialize(T_impl *) const
Definition:
Teuchos_AbstractFactoryStd.hpp:56
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition:
Teuchos_RCPDecl.hpp:429
Teuchos::PostModNothing
Default post-modification policy class for AbstractFactorStd which does nothing!
Definition:
Teuchos_AbstractFactoryStd.hpp:53
Teuchos::AbstractFactoryStd::alloc_
T_Allocator alloc_
Definition:
Teuchos_AbstractFactoryStd.hpp:158
Teuchos::AbstractFactoryStd::post_mod_
T_PostMod post_mod_
Definition:
Teuchos_AbstractFactoryStd.hpp:157
Teuchos::AbstractFactory
Simple, universal "Abstract Factory" interface for the dynamic creation of objects.
Definition:
Teuchos_AbstractFactory.hpp:61
Teuchos::AllocatorNew
Default allocation policy class for AbstractFactoryStd which returns new T_impl().
Definition:
Teuchos_AbstractFactoryStd.hpp:63
Generated by
1.8.5