Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Andrew Bauer
VTK
Commits
be68f183
Commit
be68f183
authored
Sep 12, 1994
by
Will Schroeder
Browse files
Initial revision
parent
5ff1d205
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/RefCount.hh
0 → 100644
View file @
be68f183
/*=========================================================================
Program: Visualization Library
Module: RefCount.hh
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file or its
contents may be copied, reproduced or altered in any way without the express
written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlRefCount - subclasses of this object are reference counted
// .SECTION Description
// vlRefCount is the base class for objects that are reference counted.
// Objects that are reference counted exist as long as another object
// uses them. Once the last reference to a reference counted object is
// removed, the object will spontaneously destruct. Typically only data
// objects that are passed between objects are reference counted.
#ifndef __vlRefCount_hh
#define __vlRefCount_hh
#include
"Object.hh"
class
vlRefCount
:
public
vlObject
{
public:
vlRefCount
();
~
vlRefCount
();
void
PrintSelf
(
ostream
&
os
,
vlIndent
indent
);
char
*
GetClassName
()
{
return
"vlRefCount"
;};
void
Register
(
vlObject
*
o
);
void
UnRegister
(
vlObject
*
o
);
int
GetRefCount
()
{
return
this
->
RefCount
;};
private:
int
RefCount
;
// Number of uses of this object by other objects
};
#endif
src/RefCount.cc
0 → 100644
View file @
be68f183
/*=========================================================================
Program: Visualization Library
Module: RefCount.cc
Language: C++
Date: $Date$
Version: $Revision$
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include
"RefCount.hh"
// Description:
// Construct with initial reference count = 0.
vlRefCount
::
vlRefCount
()
{
this
->
RefCount
=
0
;
}
vlRefCount
::~
vlRefCount
()
{
if
(
this
->
RefCount
>
0
)
{
vlErrorMacro
(
<<
"Trying to delete object with non-zero reference count"
);
}
}
// Description:
// Increase the reference count (mark as used by another object).
void
vlRefCount
::
Register
(
vlObject
*
o
)
{
this
->
RefCount
++
;
vlDebugMacro
(
<<
"Registered by "
<<
o
->
GetClassName
()
<<
" ("
<<
o
<<
")"
);
}
// Description:
// Decrease the reference count (release by another object).
void
vlRefCount
::
UnRegister
(
vlObject
*
o
)
{
vlDebugMacro
(
<<
"UnRegistered by "
<<
o
->
GetClassName
()
<<
" ("
<<
0
<<
")"
);
if
(
--
this
->
RefCount
<=
0
)
delete
this
;
}
void
vlRefCount
::
PrintSelf
(
ostream
&
os
,
vlIndent
indent
)
{
if
(
this
->
ShouldIPrint
(
vlRefCount
::
GetClassName
()))
{
vlObject
::
PrintSelf
(
os
,
indent
);
os
<<
indent
<<
"Reference Count: "
<<
this
->
RefCount
<<
"
\n
"
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment