summaryrefslogtreecommitdiff
path: root/inc/NCollection_TListNode.hxx
blob: ddaa93b6d3442fa6eb1c9a5881647e3ac0bfeacb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// File:        NCollection_TListNode.hxx
// Created:     Tue Apr 23 17:30:38 2002
// Author:      Alexander KARTOMIN (akm)
//              <akm@opencascade.com>

#ifndef NCollection_TListNode_HeaderFile
#define NCollection_TListNode_HeaderFile

#include <NCollection_ListNode.hxx>
#include <NCollection_BaseAllocator.hxx>

#ifdef WNT
// Disable the warning "operator new unmatched by delete"
#pragma warning (push)
#pragma warning (disable:4291)
#endif

/**
 * Purpose:     Abstract list node class. Used by BaseList
 * Remark:      Internal class
 */              
template <class TheItemType> class NCollection_TListNode 
  : public NCollection_ListNode
{
 public:
  //! Constructor
  NCollection_TListNode (const TheItemType& theItem,
                         NCollection_ListNode* theNext=NULL) :
    NCollection_ListNode  (theNext) { myValue = theItem; }
  //! Constant value access
  const TheItemType& Value () const { return myValue; }
  //! Variable value access
  TheItemType& ChangeValue () { return myValue; }
  //! Memory allocation
  void* operator new(size_t theSize,
                     const Handle(NCollection_BaseAllocator)& theAllocator) 
  { return theAllocator->Allocate(theSize); }
  //! Static deleter to be passed to BaseList
  static void delNode (NCollection_ListNode * theNode, 
                       Handle(NCollection_BaseAllocator)& theAl)
  {
    ((NCollection_TListNode *) theNode)->myValue.~TheItemType();
    theAl->Free(theNode);
  }

  
 protected:
  TheItemType    myValue; //!< The item stored in the node
  
};

#ifdef WNT
#pragma warning (pop)
#endif

#endif