LifeV
FactoryPolicy.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5 Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6 Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8 This file is part of LifeV.
9 
10 LifeV is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14 
15 LifeV is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 /*!
27  @file
28  @brief Policies for object lifetime management
29 
30  @date 10-09-2004
31  @author Christophe Prud'homme <christophe.prudhomme@epfl.ch>
32 
33  @maintainer Radu Popescu <radu.popescu@epfl.ch>
34 */
35 
36 #ifndef FACTORY_POLICY_H
37 #define FACTORY_POLICY_H 1
38 
39 namespace LifeV
40 {
41 /**
42  @class FactoryPolicyCreationUsingNew
43 */
44 template <class T>
46 {
47  //! @name Static methods
48  //@{
49  static T* create()
50  {
51  return new T;
52  }
53 
54  static void destroy ( T* p )
55  {
56  delete p;
57  }
58  //@}
59 };
60 
61 /**
62  @class FactoryPolicyLifeTimeDefault
63 */
64 template <class T>
66 {
67  //! @name Static methods
68  //@{
69  static void scheduleDestruction ( T*, void ( *pFun ) () )
70  {
71  std::atexit ( pFun );
72  }
73 
74  static void onDeadReference()
75  {
76  throw std::logic_error ( "Dead Reference Detected" );
77  }
78  //@}
79 };
80 
81 } // Namespace LifeV
82 
83 #endif // FACTORY_POLICY_H
void updateInverseJacobian(const UInt &iQuadPt)
static void scheduleDestruction(T *, void(*pFun)())