Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Niflib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grant Kim
Niflib
Commits
dbf35c9b
Commit
dbf35c9b
authored
18 years ago
by
Shon Ferguson
Browse files
Options
Downloads
Patches
Plain Diff
Realized that Ref's functions need to be in the header file because it is a template.
parent
f7788085
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
niflib.vcproj
+0
-3
0 additions, 3 deletions
niflib.vcproj
obj/Ref.cpp
+0
-102
0 additions, 102 deletions
obj/Ref.cpp
obj/Ref.h
+104
-0
104 additions, 0 deletions
obj/Ref.h
with
104 additions
and
105 deletions
niflib.vcproj
+
0
−
3
View file @
dbf35c9b
...
@@ -785,9 +785,6 @@
...
@@ -785,9 +785,6 @@
<File
<File
RelativePath=
".\obj\NiZBufferProperty.cpp"
>
RelativePath=
".\obj\NiZBufferProperty.cpp"
>
</File>
</File>
<File
RelativePath=
".\obj\Ref.cpp"
>
</File>
<File
<File
RelativePath=
".\obj\RootCollisionNode.cpp"
>
RelativePath=
".\obj\RootCollisionNode.cpp"
>
</File>
</File>
...
...
This diff is collapsed.
Click to expand it.
obj/Ref.cpp
deleted
100644 → 0
+
0
−
102
View file @
f7788085
/* Copyright (c) 2006, NIF File Format Library and Tools
All rights reserved. Please see niflib.h for licence. */
#include
"Ref.h"
template
<
class
T
>
Ref
<
T
>::
Ref
(
T
*
object
=
NULL
)
:
_object
(
object
)
{}
template
<
class
T
>
Ref
<
T
>::
Ref
(
const
Ref
&
ref_to_copy
)
{
_object
=
ref_to_copy
.
_object
;
//If object isn't null, increment reference count
if
(
_object
!=
NULL
)
{
_object
->
AddRef
();
}
}
template
<
class
T
>
Ref
<
T
>::
operator
T
*
()
const
{
return
_object
;
}
template
<
class
T
>
T
&
Ref
<
T
>::
operator
*
()
const
{
return
_object
;
}
template
<
class
T
>
T
*
Ref
<
T
>::
operator
->
()
const
{
return
_object
;
}
template
<
class
T
>
Ref
<
T
>
&
Ref
<
T
>::
operator
=
(
T
*
object
)
{
//Check if referenced objects are already the same
if
(
_object
==
object
)
{
return
this
;
//Do nothing
}
//Decriment reference count on previously referenced object, if any
if
(
_object
!=
NULL
)
{
_object
->
SubtractRef
();
}
//Change reference to new object
_object
=
object
;
//Increment reerence count on new object if it is not NULL
if
(
_object
!=
NULL
)
{
_object
->
AddRef
();
}
}
template
<
class
T
>
Ref
<
T
>
&
Ref
<
T
>::
operator
=
(
const
Ref
&
ref
)
{
//Check if referenced objects are already the same
if
(
_object
==
ref
.
_object
)
{
return
this
;
//Do nothing
}
//Decriment reference count on previously referenced object, if any
if
(
_object
!=
NULL
)
{
_object
->
SubtractRef
();
}
//Change reference to new object
_object
=
ref
.
_object
;
//Increment reerence count on new object if it is not NULL
if
(
_object
!=
NULL
)
{
_object
->
AddRef
();
}
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
<
(
const
Ref
&
ref
)
const
{
return
(
_object
<
ref
.
_object
);
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
==
(
T
*
object
)
const
{
//Compare pointer values of referenced objects
return
(
_object
==
object
);
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
!=
(
T
*
object
)
const
{
//Compare pointer values of referenced objects
return
(
_object
!=
object
);
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
==
(
const
Ref
&
ref
)
const
{
//Compare pointer values of referenced objects
return
(
_object
==
ref
.
_object
);
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
!=
(
const
Ref
&
ref
)
const
{
//Compare pointer values of referenced objects
return
(
_object
!=
ref
.
_object
);
}
This diff is collapsed.
Click to expand it.
obj/Ref.h
+
104
−
0
View file @
dbf35c9b
...
@@ -31,4 +31,108 @@ protected:
...
@@ -31,4 +31,108 @@ protected:
T
*
_object
;
T
*
_object
;
};
};
template
<
class
T
>
Ref
<
T
>::
Ref
(
T
*
object
=
NULL
)
:
_object
(
object
)
{}
template
<
class
T
>
Ref
<
T
>::
Ref
(
const
Ref
&
ref_to_copy
)
{
_object
=
ref_to_copy
.
_object
;
//If object isn't null, increment reference count
if
(
_object
!=
NULL
)
{
_object
->
AddRef
();
}
}
template
<
class
T
>
Ref
<
T
>::
operator
T
*
()
const
{
return
_object
;
}
template
<
class
T
>
T
&
Ref
<
T
>::
operator
*
()
const
{
return
_object
;
}
template
<
class
T
>
T
*
Ref
<
T
>::
operator
->
()
const
{
return
_object
;
}
template
<
class
T
>
Ref
<
T
>
&
Ref
<
T
>::
operator
=
(
T
*
object
)
{
//Check if referenced objects are already the same
if
(
_object
==
object
)
{
return
*
this
;
//Do nothing
}
//Decriment reference count on previously referenced object, if any
if
(
_object
!=
NULL
)
{
_object
->
SubtractRef
();
}
//Change reference to new object
_object
=
object
;
//Increment reerence count on new object if it is not NULL
if
(
_object
!=
NULL
)
{
_object
->
AddRef
();
}
return
*
this
;
}
template
<
class
T
>
Ref
<
T
>
&
Ref
<
T
>::
operator
=
(
const
Ref
&
ref
)
{
//Check if referenced objects are already the same
if
(
_object
==
ref
.
_object
)
{
return
*
this
;
//Do nothing
}
//Decriment reference count on previously referenced object, if any
if
(
_object
!=
NULL
)
{
_object
->
SubtractRef
();
}
//Change reference to new object
_object
=
ref
.
_object
;
//Increment reerence count on new object if it is not NULL
if
(
_object
!=
NULL
)
{
_object
->
AddRef
();
}
return
*
this
;
}
//Template functions must be in the header file
template
<
class
T
>
bool
Ref
<
T
>::
operator
<
(
const
Ref
&
ref
)
const
{
return
(
_object
<
ref
.
_object
);
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
==
(
T
*
object
)
const
{
//Compare pointer values of referenced objects
return
(
_object
==
object
);
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
!=
(
T
*
object
)
const
{
//Compare pointer values of referenced objects
return
(
_object
!=
object
);
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
==
(
const
Ref
&
ref
)
const
{
//Compare pointer values of referenced objects
return
(
_object
==
ref
.
_object
);
}
template
<
class
T
>
bool
Ref
<
T
>::
operator
!=
(
const
Ref
&
ref
)
const
{
//Compare pointer values of referenced objects
return
(
_object
!=
ref
.
_object
);
}
#endif
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment