H3D API  2.4.1
MFNodeAutoRefVector.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
26 //
28 #ifndef __MFNODEAUTOREFVECTOR_H__
29 #define __MFNODEAUTOREFVECTOR_H__
30 
31 #include <H3DUtil/AutoRefVector.h>
32 
33 namespace H3D {
34 
35  // forward declaration
36  template< class RefClass >
37  class RefCountMField;
38 
39  namespace FieldInternals {
40 
41 #if _MSC_VER >= 1500
42 #pragma warning( disable : 4275 )
43 #endif
49  template< class RefClass >
50  class H3DAPI_API MFNodeAutoRefVector: public AutoRefVector< RefClass > {
51  public :
52 #if _MSC_VER >= 1500
53 #pragma warning( default : 4275 )
54 #endif
55 
57  inline MFNodeAutoRefVector() : owner( NULL ) {}
58 
60  inline MFNodeAutoRefVector( typename AutoRefVector< RefClass >::size_type n ) :
61  AutoRefVector< RefClass >( n ),
62  owner( NULL ) {}
63 
65  inline virtual ~MFNodeAutoRefVector() {
66  this->clear();
67  }
68 
70  inline MFNodeAutoRefVector &operator=(
71  const MFNodeAutoRefVector &v ) {
73  return *this;
74  }
75 
77  inline MFNodeAutoRefVector &operator=(
78  const AutoRefVector< RefClass > &v ) {
80  return *this;
81  }
82 
84  inline MFNodeAutoRefVector &operator=(
85  const vector< RefClass *> &v ) {
87  return *this;
88  }
89 
96  virtual void ref( RefClass *n ) const {
97  if( n ) {
99  owner->onAdd( owner->preOnAdd( n ) );
100  }
101  }
102 
110  virtual void unref( RefClass *n ) const {
111  if( n ) {
112  owner->onRemove( owner->preOnRemove( n ) );
114  }
115  }
116 
118  RefCountMField< RefClass > *owner;
119  };
120  }
121 }
122 
123 
124 
125 #endif
std::vector< RefCountedClassType * >::size_type size_type
virtual void ref(RefCountedClassType *n) const
virtual void unref(RefCountedClassType *n) const
AutoRefVector< RefCountedClassType > & operator=(const AutoRefVector< RefCountedClassType > &v)
H3D API namespace.
Definition: Anchor.h:38