DUNE-FEM (unstable)

objpointer.hh
1#ifndef DUNE_FEM_OBJPOINTER_HH
2#define DUNE_FEM_OBJPOINTER_HH
3
4namespace Dune
5{
6
7 namespace Fem
8 {
9
12 template <class ObjType>
14 {
17 ObjType * item;
18 ObjPointerType *next;
19
21 ObjPointer () : item (0) , next (0) {}
22
24 ObjPointer (ObjType *t) : item (t) , next (0) {}
25
28 virtual ~ObjPointer ()
29 {
30 if(next)
31 delete next;
32 next = 0;
33 if(item)
34 delete item;
35 item = 0;
36 }
37 };
38
42 {
44 public:
46 ObjPointerStorage () : item_ (0) {}
47
50 {
51 if(item_)
52 delete item_;
53 item_ = 0;
54 }
55
57 template <class DiscrOpType>
58 void saveObjPointer ( DiscrOpType * discrOp )
59 {
60 ObjPointerType *next = new ObjPointerType ( discrOp );
61 next->next = item_;
62 item_ = next;
63 }
64
67 template <class DiscrOpType, class LocalOpType >
68 void saveObjPointer ( DiscrOpType * discrOp , LocalOpType * lop )
69 {
70 saveObjPointer( discrOp );
71 saveObjPointer( lop );
72 }
73
74 private:
75 // store the objects created by operator + in here
76 typedef ObjPointer<MyType> ObjPointerType;
77 ObjPointerType * item_;
78
79 };
80
81 } // namespace Fem
82
83} // namespace Dune
84
85#endif // #ifndef DUNE_FEM_OBJPOINTER_HH
Definition: objpointer.hh:42
void saveObjPointer(DiscrOpType *discrOp, LocalOpType *lop)
Definition: objpointer.hh:68
virtual ~ObjPointerStorage()
need virtual desctructor for deleting the real objects.
Definition: objpointer.hh:49
ObjPointerStorage()
make new operator with item points to null
Definition: objpointer.hh:46
void saveObjPointer(DiscrOpType *discrOp)
Store new generated DiscreteOperator Pointer.
Definition: objpointer.hh:58
Dune namespace.
Definition: alignedallocator.hh:13
Definition: objpointer.hh:14
ObjPointer()
new ObjPointer is only created with pointer for item
Definition: objpointer.hh:21
ObjPointer(ObjType *t)
new ObjPointer is only created with pointer for item
Definition: objpointer.hh:24
ObjType * item
remember object item and next pointer
Definition: objpointer.hh:17
virtual ~ObjPointer()
Definition: objpointer.hh:28
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)