Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_AbstractFactoryStd.hpp
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_ABSTRACT_FACTORY_STD_HPP
11#define TEUCHOS_ABSTRACT_FACTORY_STD_HPP
12
13#include "Teuchos_AbstractFactory.hpp"
14
15namespace Teuchos {
16
20template<class T_impl>
22public:
24 void initialize(T_impl* /* p */) const {} // required!
25};
26
30template<class T_impl>
32public:
34 typedef Teuchos::RCP<T_impl> ptr_t; // required!
36 const ptr_t allocate() const { return Teuchos::rcp(new T_impl()); } // required!
37};
38
106template<class T_itfc, class T_impl
107 ,class T_PostMod = PostModNothing<T_impl>
108 ,class T_Allocator = AllocatorNew<T_impl>
109 >
110class AbstractFactoryStd : public AbstractFactory<T_itfc> {
111public:
112
113 typedef typename Teuchos::AbstractFactory<T_itfc>::obj_ptr_t obj_ptr_t; // RAB: 20030916: G++ 3.2 complains without this
114
117
121 obj_ptr_t create() const;
123
124private:
125 T_PostMod post_mod_;
126 T_Allocator alloc_;
127
128};
129
130
135template<class T_itfc, class T_impl>
143
144
149template<class T_itfc, class T_impl, class T_Allocator>
159
160
161// ///////////////////////////////////////////////////////
162// Template member definitions
163
164template<class T_itfc, class T_impl, class T_PostMod, class T_Allocator>
165inline
172
173template<class T_itfc, class T_impl, class T_PostMod, class T_Allocator>
174inline
175typename AbstractFactoryStd<T_itfc,T_impl,T_PostMod,T_Allocator>::obj_ptr_t
177{
178 typename T_Allocator::ptr_t
179 ptr = alloc_.allocate();
180 post_mod_.initialize(ptr.get());
181 return ptr;
182}
183
184} // end Teuchos
185
186#endif // TEUCHOS_ABSTRACT_FACTORY_STD_HPP
Simple, templated concrete subclass of universal "Abstract Factory" interface for the creation of o...
RCP< const AbstractFactory< T_itfc > > abstractFactoryStd()
Nonmember constructor for an standar abstract factory object.
AbstractFactoryStd(const T_PostMod &post_mod=T_PostMod(), const T_Allocator &alloc=T_Allocator())
RCP< const AbstractFactory< T_itfc > > abstractFactoryStd(const T_Allocator &alloc=T_Allocator())
Nonmember constructor for an standar abstract factory object.
Simple, universal "Abstract Factory" interface for the dynamic creation of objects.
Default allocation policy class for AbstractFactoryStd which returns new T_impl().
Default post-modification policy class for AbstractFactorStd which does nothing!
Smart reference counting pointer class for automatic garbage collection.
Ptr< T > ptr() const
Get a safer wrapper raw C++ pointer to the underlying object.
T * get() const
Get the raw C++ pointer to the underlying object.
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.