Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
3b71faa5
Commit
3b71faa5
authored
Jan 05, 2008
by
coppro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compatibility updates step 1.
parent
a40a3427
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
819 additions
and
778 deletions
+819
-778
Makefile.am
Makefile.am
+126
-120
Makefile.in
Makefile.in
+553
-517
data/vs-oversize.mse-style/card-sample.png
data/vs-oversize.mse-style/card-sample.png
+0
-0
src/data/field.cpp
src/data/field.cpp
+6
-6
src/gui/control/gallery_list.cpp
src/gui/control/gallery_list.cpp
+25
-42
src/gui/control/gallery_list.hpp
src/gui/control/gallery_list.hpp
+19
-7
src/gui/control/tree_list.cpp
src/gui/control/tree_list.cpp
+53
-53
src/gui/images_export_window.cpp
src/gui/images_export_window.cpp
+2
-2
src/gui/images_export_window.hpp
src/gui/images_export_window.hpp
+2
-1
src/gui/packages_window.cpp
src/gui/packages_window.cpp
+17
-16
src/main.cpp
src/main.cpp
+2
-2
src/util/atomic.hpp
src/util/atomic.hpp
+4
-5
src/util/smart_ptr.hpp
src/util/smart_ptr.hpp
+10
-7
No files found.
Makefile.am
View file @
3b71faa5
This diff is collapsed.
Click to expand it.
Makefile.in
View file @
3b71faa5
This diff is collapsed.
Click to expand it.
data/vs-oversize.mse-style/card-sample.
PNG
→
data/vs-oversize.mse-style/card-sample.
png
View file @
3b71faa5
File moved
src/data/field.cpp
View file @
3b71faa5
//+----------------------------------------------------------------------------+
//
//
+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
...
...
@@ -131,7 +131,7 @@ inline bool is_set(const Scriptable<double>& x) {
return
x
.
isScripted
()
||
x
<
100000
;
}
inline
bool
is_setw
(
const
Scriptable
<
double
>&
x
)
{
return
x
.
isScripted
()
||
abs
(
x
)
>
0.001
;
return
x
.
isScripted
()
||
f
abs
(
x
)
>
0.001
;
}
int
Style
::
update
(
Context
&
ctx
)
{
...
...
@@ -187,11 +187,11 @@ int Style::update(Context& ctx) {
bool
Style
::
isVisible
()
const
{
return
visible
&&
(
width
)
>
0
&&
abs
(
left
)
<
100000
&&
abs
(
right
)
<
100000
&&
f
abs
(
left
)
<
100000
&&
f
abs
(
right
)
<
100000
&&
(
height
)
>
0
&&
abs
(
top
)
<
100000
&&
abs
(
bottom
)
<
100000
;
&&
f
abs
(
top
)
<
100000
&&
f
abs
(
bottom
)
<
100000
;
}
bool
Style
::
hasSize
()
const
{
int
h
=
is_setw
(
width
)
+
is_set
(
left
)
+
is_set
(
right
);
...
...
src/gui/control/gallery_list.cpp
View file @
3b71faa5
...
...
@@ -18,10 +18,6 @@ DEFINE_EVENT_TYPE(EVENT_GALLERY_ACTIVATE);
// ----------------------------------------------------------------------------- : GalleryList
const
int
MARGIN
=
1
;
// margin between items (excluding border)
const
int
BORDER
=
1
;
// border aroung items
const
int
SPACING
=
MARGIN
+
2
*
BORDER
;
// distance between items
GalleryList
::
GalleryList
(
Window
*
parent
,
int
id
,
int
direction
,
bool
always_focused
)
:
wxPanel
(
parent
,
id
,
wxDefaultPosition
,
wxDefaultSize
,
wxSUNKEN_BORDER
|
wxWANTS_CHARS
|
(
direction
==
wxHORIZONTAL
?
wxHSCROLL
:
wxVSCROLL
)
)
,
selection
(
NO_SELECTION
)
...
...
@@ -72,19 +68,6 @@ wxPoint GalleryList::itemPos(size_t item) const {
// ----------------------------------------------------------------------------- : Scrolling & sizing
int
GalleryList
::
visibleEnd
()
const
{
return
visible_start
+
mainSize
(
GetClientSize
());
}
int
GalleryList
::
itemStart
(
size_t
item
)
const
{
return
(
int
)
item
*
(
mainSize
(
item_size
)
+
SPACING
);
}
int
GalleryList
::
itemEnd
(
size_t
item
)
const
{
return
(
int
)(
item
+
1
)
*
(
mainSize
(
item_size
)
+
SPACING
)
+
MARGIN
;
}
int
GalleryList
::
mainSize
(
wxSize
s
)
const
{
return
direction
==
wxHORIZONTAL
?
s
.
x
:
s
.
y
;
}
void
GalleryList
::
scrollTo
(
int
top
,
bool
update_scrollbar
)
{
wxSize
cs
=
GetClientSize
();
int
total_height
=
itemEnd
(
itemCount
()
-
1
);
...
...
@@ -101,12 +84,12 @@ void GalleryList::scrollTo(int top, bool update_scrollbar) {
}
}
void
GalleryList
::
updateScrollbar
()
{
scrollTo
(
visible_start
,
false
);
// how many lines fit on the screen?
void
GalleryList
::
updateScrollbar
()
{
scrollTo
(
visible_start
,
false
);
// how many lines fit on the screen?
int
screen_height
=
mainSize
(
GetClientSize
());
int
total_height
=
itemEnd
(
itemCount
()
-
1
);
// set the scrollbar parameters to reflect this
int
total_height
=
itemEnd
(
itemCount
()
-
1
);
// set the scrollbar parameters to reflect this
SetScrollbar
(
direction
,
visible_start
,
screen_height
,
total_height
);
}
...
...
@@ -114,26 +97,26 @@ void GalleryList::RefreshItem(size_t item) {
if
(
item
>=
itemCount
())
return
;
RefreshRect
(
wxRect
(
itemPos
(
item
),
item_size
).
Inflate
(
BORDER
,
BORDER
),
false
);
}
void
GalleryList
::
onScroll
(
wxScrollWinEvent
&
ev
)
{
wxEventType
type
=
ev
.
GetEventType
();
if
(
type
==
wxEVT_SCROLLWIN_TOP
)
{
scrollTo
(
0
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_BOTTOM
)
{
scrollTo
(
INT_MAX
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_LINEUP
)
{
scrollTo
(
visible_start
-
(
mainSize
(
item_size
)
+
SPACING
));
}
else
if
(
type
==
wxEVT_SCROLLWIN_LINEDOWN
)
{
scrollTo
(
visible_start
+
(
mainSize
(
item_size
)
+
SPACING
));
}
else
if
(
type
==
wxEVT_SCROLLWIN_PAGEUP
)
{
scrollTo
(
visible_start
-
visibleEnd
()
+
mainSize
(
item_size
));
}
else
if
(
type
==
wxEVT_SCROLLWIN_PAGEDOWN
)
{
scrollTo
(
visibleEnd
()
-
mainSize
(
item_size
));
}
else
{
scrollTo
(
ev
.
GetPosition
());
}
}
void
GalleryList
::
onScroll
(
wxScrollWinEvent
&
ev
)
{
wxEventType
type
=
ev
.
GetEventType
();
if
(
type
==
wxEVT_SCROLLWIN_TOP
)
{
scrollTo
(
0
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_BOTTOM
)
{
scrollTo
(
INT_MAX
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_LINEUP
)
{
scrollTo
(
visible_start
-
(
mainSize
(
item_size
)
+
SPACING
));
}
else
if
(
type
==
wxEVT_SCROLLWIN_LINEDOWN
)
{
scrollTo
(
visible_start
+
(
mainSize
(
item_size
)
+
SPACING
));
}
else
if
(
type
==
wxEVT_SCROLLWIN_PAGEUP
)
{
scrollTo
(
visible_start
-
visibleEnd
()
+
mainSize
(
item_size
));
}
else
if
(
type
==
wxEVT_SCROLLWIN_PAGEDOWN
)
{
scrollTo
(
visibleEnd
()
-
mainSize
(
item_size
));
}
else
{
scrollTo
(
ev
.
GetPosition
());
}
}
void
GalleryList
::
onSize
(
wxSizeEvent
&
ev
)
{
update
();
ev
.
Skip
();
...
...
src/gui/control/gallery_list.hpp
View file @
3b71faa5
...
...
@@ -73,25 +73,37 @@ class GalleryList : public wxPanel {
wxPoint
itemPos
(
size_t
item
)
const
;
/// Scroll to the given position (note: 'top' can also mean 'left')
void
GalleryList
::
scrollTo
(
int
top
,
bool
update_scrollbar
=
true
);
void
scrollTo
(
int
top
,
bool
update_scrollbar
=
true
);
/// Update the scrollbar(s)
void
GalleryList
::
updateScrollbar
();
void
updateScrollbar
();
/// Redraw just a single item
void
GalleryList
::
RefreshItem
(
size_t
item
);
void
RefreshItem
(
size_t
item
);
/// First visible pixel position
int
visible_start
;
/// First no-longer-visible pixel position
inline
int
GalleryList
::
visibleEnd
()
const
;
inline
int
visibleEnd
()
const
{
return
visible_start
+
mainSize
(
GetClientSize
());
}
/// Pixel position of an item
inline
int
GalleryList
::
itemStart
(
size_t
item
)
const
;
inline
int
GalleryList
::
itemEnd
(
size_t
item
)
const
;
inline
int
itemStart
(
size_t
item
)
const
{
return
(
int
)
item
*
(
mainSize
(
item_size
)
+
SPACING
);
}
inline
int
itemEnd
(
size_t
item
)
const
{
return
(
int
)(
item
+
1
)
*
(
mainSize
(
item_size
)
+
SPACING
)
+
MARGIN
;
}
/// Main component of a size (i.e. in the direction of this list)
inline
int
GalleryList
::
mainSize
(
wxSize
s
)
const
;
inline
int
mainSize
(
wxSize
s
)
const
{
return
direction
==
wxHORIZONTAL
?
s
.
x
:
s
.
y
;
}
protected:
/// Send an event
void
sendEvent
(
WXTYPE
type
);
static
const
int
MARGIN
=
1
;
// margin between items (excluding border)
static
const
int
BORDER
=
1
;
// border aroung items
static
const
int
SPACING
=
MARGIN
+
2
*
BORDER
;
// distance between items
};
// ----------------------------------------------------------------------------- : EOF
...
...
src/gui/control/tree_list.cpp
View file @
3b71faa5
...
...
@@ -224,11 +224,11 @@ void TreeList::onChar(wxKeyEvent& ev) {
expand
(
selection
,
true
);
}
}
break
;
}
case
WXK_PAGEUP
:
case
WXK_PRIOR
:
{
ScrollToLine
(
first_line
>
visible_lines_t
?
first_line
-
visible_lines_t
:
0
);
break
;
}
case
WXK_PAGEDOWN
:
case
WXK_NEXT
:
{
break
;
}
case
WXK_PAGEUP
:
{
ScrollToLine
(
first_line
>
visible_lines_t
?
first_line
-
visible_lines_t
:
0
);
break
;
}
case
WXK_PAGEDOWN
:
{
ScrollToLine
(
first_line
+
visible_lines_t
);
break
;
}
case
WXK_HOME
:
{
...
...
@@ -272,56 +272,56 @@ void TreeList::onLeftDClick(wxMouseEvent& ev) {
// ----------------------------------------------------------------------------- : TreeList : Copy of VScrolledWindow
void
TreeList
::
ScrollToLine
(
size_t
line
)
{
// determine the real first line to scroll to: we shouldn't scroll beyond the end
line
=
(
size_t
)
max
((
int
)
line
,
0
);
line
=
(
size_t
)
min
((
int
)
line
,
max
(
0
,
(
int
)(
total_lines
-
visible_lines_t
)));
// nothing to do?
if
(
line
==
first_line
)
return
;
first_line
=
line
;
UpdateScrollbar
();
// determine the real first line to scroll to: we shouldn't scroll beyond the end
line
=
(
size_t
)
max
((
int
)
line
,
0
);
line
=
(
size_t
)
min
((
int
)
line
,
max
(
0
,
(
int
)(
total_lines
-
visible_lines_t
)));
// nothing to do?
if
(
line
==
first_line
)
return
;
first_line
=
line
;
UpdateScrollbar
();
Refresh
(
false
);
}
void
TreeList
::
UpdateScrollbar
()
{
// how many lines fit on the screen?
int
h
=
GetClientSize
().
y
-
header_height
;
visible_lines
=
(
h
+
item_height
-
1
)
/
item_height
;
visible_lines_t
=
h
/
item_height
;
// set the scrollbar parameters to reflect this
SetScrollbar
(
wxVERTICAL
,
(
int
)
first_line
,
(
int
)
visible_lines_t
,
(
int
)
total_lines
);
}
void
TreeList
::
RefreshLine
(
size_t
line
)
{
if
(
line
<
first_line
||
line
>=
first_line
+
visible_lines
)
return
;
// calculate the rect occupied by this line on screen
wxRect
rect
;
rect
.
x
=
0
;
rect
.
y
=
header_height
+
(
int
)(
line
-
first_line
)
*
item_height
;
rect
.
width
=
GetClientSize
().
x
;
rect
.
height
=
item_height
;
// do refresh it
RefreshRect
(
rect
,
false
);
}
void
TreeList
::
onScroll
(
wxScrollWinEvent
&
ev
)
{
wxEventType
type
=
ev
.
GetEventType
();
if
(
type
==
wxEVT_SCROLLWIN_TOP
)
{
ScrollToLine
(
0
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_BOTTOM
)
{
ScrollToLine
(
total_lines
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_LINEUP
)
{
ScrollToLine
(
first_line
>
0
?
first_line
-
1
:
0
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_LINEDOWN
)
{
ScrollToLine
(
first_line
+
1
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_PAGEUP
)
{
ScrollToLine
(
first_line
>
visible_lines_t
?
first_line
-
visible_lines_t
:
0
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_PAGEDOWN
)
{
ScrollToLine
(
first_line
+
visible_lines_t
);
}
else
{
ScrollToLine
(
ev
.
GetPosition
());
}
}
void
TreeList
::
UpdateScrollbar
()
{
// how many lines fit on the screen?
int
h
=
GetClientSize
().
y
-
header_height
;
visible_lines
=
(
h
+
item_height
-
1
)
/
item_height
;
visible_lines_t
=
h
/
item_height
;
// set the scrollbar parameters to reflect this
SetScrollbar
(
wxVERTICAL
,
(
int
)
first_line
,
(
int
)
visible_lines_t
,
(
int
)
total_lines
);
}
void
TreeList
::
RefreshLine
(
size_t
line
)
{
if
(
line
<
first_line
||
line
>=
first_line
+
visible_lines
)
return
;
// calculate the rect occupied by this line on screen
wxRect
rect
;
rect
.
x
=
0
;
rect
.
y
=
header_height
+
(
int
)(
line
-
first_line
)
*
item_height
;
rect
.
width
=
GetClientSize
().
x
;
rect
.
height
=
item_height
;
// do refresh it
RefreshRect
(
rect
,
false
);
}
void
TreeList
::
onScroll
(
wxScrollWinEvent
&
ev
)
{
wxEventType
type
=
ev
.
GetEventType
();
if
(
type
==
wxEVT_SCROLLWIN_TOP
)
{
ScrollToLine
(
0
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_BOTTOM
)
{
ScrollToLine
(
total_lines
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_LINEUP
)
{
ScrollToLine
(
first_line
>
0
?
first_line
-
1
:
0
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_LINEDOWN
)
{
ScrollToLine
(
first_line
+
1
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_PAGEUP
)
{
ScrollToLine
(
first_line
>
visible_lines_t
?
first_line
-
visible_lines_t
:
0
);
}
else
if
(
type
==
wxEVT_SCROLLWIN_PAGEDOWN
)
{
ScrollToLine
(
first_line
+
visible_lines_t
);
}
else
{
ScrollToLine
(
ev
.
GetPosition
());
}
}
void
TreeList
::
onSize
(
wxSizeEvent
&
ev
)
{
UpdateScrollbar
();
Refresh
(
false
);
...
...
src/gui/images_export_window.cpp
View file @
3b71faa5
...
...
@@ -57,7 +57,7 @@ ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set)
// ----------------------------------------------------------------------------- : Exporting the images
void
ExportCardImages
::
export
(
const
SetP
&
set
,
wxFileName
&
fn
,
const
String
&
filename_template
,
FilenameConflicts
conflicts
)
{
void
ExportCardImages
::
export
Images
(
const
SetP
&
set
,
wxFileName
&
fn
,
const
String
&
filename_template
,
FilenameConflicts
conflicts
)
{
// Script
ScriptP
filename_script
=
parse
(
filename_template
,
nullptr
,
true
);
// Export
...
...
@@ -116,7 +116,7 @@ void ImagesExportWindow::onOk(wxCommandEvent&) {
if
(
name
.
empty
())
return
;
wxFileName
fn
(
name
);
// Export
export
(
set
,
fn
,
gs
.
images_export_filename
,
gs
.
images_export_conflicts
);
export
Images
(
set
,
fn
,
gs
.
images_export_filename
,
gs
.
images_export_conflicts
);
// Done
EndModal
(
wxID_OK
);
}
...
...
src/gui/images_export_window.hpp
View file @
3b71faa5
...
...
@@ -19,7 +19,8 @@ class wxFileName;
/// Export the cards in a set
class
ExportCardImages
{
public:
void
export
(
const
SetP
&
set
,
wxFileName
&
filename
,
const
String
&
filename_template
,
FilenameConflicts
conflicts
);
void
exportImages
(
const
SetP
&
set
,
wxFileName
&
filename
,
const
String
&
filename_template
,
FilenameConflicts
conflicts
);
virtual
~
ExportCardImages
()
{}
protected:
virtual
bool
exportCard
(
const
CardP
&
card
)
const
{
return
true
;
}
};
...
...
src/gui/packages_window.cpp
View file @
3b71faa5
...
...
@@ -284,21 +284,21 @@ class SeekAtStartInputStream : public wxFilterInputStream {
}
bool
IsSeekable
()
const
{
return
true
;
}
protected:
virtual
size_t
OnSysRead
(
void
*
buffer
,
size_t
bufsize
)
{
size_t
len
=
min
(
buffer_size
-
buffer_pos
,
bufsize
);
memcpy
(
buffer
,
this
->
buffer
+
buffer_pos
,
len
);
buffer_pos
+=
len
;
m_parent_i_stream
->
Read
((
Byte
*
)
buffer
+
len
,
bufsize
-
len
);
return
m_parent_i_stream
->
LastRead
()
+
len
;
}
virtual
wxFileOffset
OnSysSeek
(
wxFileOffset
seek
,
wxSeekMode
mode
)
{
if
(
mode
==
wxFromStart
)
buffer_pos
=
seek
;
else
if
(
mode
==
wxFromCurrent
)
buffer_pos
+=
seek
;
else
assert
(
false
);
assert
(
buffer_pos
<
buffer_size
);
return
buffer_pos
;
}
protected:
virtual
size_t
OnSysRead
(
void
*
buffer
,
size_t
bufsize
)
{
size_t
len
=
min
(
buffer_size
-
buffer_pos
,
bufsize
);
memcpy
(
buffer
,
this
->
buffer
+
buffer_pos
,
len
);
buffer_pos
+=
len
;
m_parent_i_stream
->
Read
((
Byte
*
)
buffer
+
len
,
bufsize
-
len
);
return
m_parent_i_stream
->
LastRead
()
+
len
;
}
virtual
wxFileOffset
OnSysSeek
(
wxFileOffset
seek
,
wxSeekMode
mode
)
{
if
(
mode
==
wxFromStart
)
buffer_pos
=
seek
;
else
if
(
mode
==
wxFromCurrent
)
buffer_pos
+=
seek
;
else
assert
(
false
);
assert
(
buffer_pos
<
buffer_size
);
return
buffer_pos
;
}
virtual
wxFileOffset
OnSysTell
()
const
{
assert
(
buffer_pos
<
buffer_size
);
return
buffer_pos
;
...
...
@@ -606,7 +606,8 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
packages
.
install
(
*
ip
);
}
// Done
wxDialog
::
OnOK
(
ev
);
// Continue event propagation into the dialog window so that it closes.
ev
.
Skip
();
}
void
PackagesWindow
::
onUpdateUI
(
wxUpdateUIEvent
&
ev
)
{
...
...
src/main.cpp
View file @
3b71faa5
...
...
@@ -174,8 +174,8 @@ int MSE::OnRun() {
}
wxFileName
fn
(
path
);
// export
ExportCardImages
export
;
export
.
export
(
set
,
fn
,
out
,
CONFLICT_NUMBER_OVERWRITE
);
ExportCardImages
export
er
;
export
er
.
exportImages
(
set
,
fn
,
out
,
CONFLICT_NUMBER_OVERWRITE
);
return
EXIT_SUCCESS
;
}
else
{
handle_error
(
_
(
"Invalid command line argument:
\n
"
)
+
String
(
argv
[
1
]));
...
...
src/util/atomic.hpp
View file @
3b71faa5
...
...
@@ -17,7 +17,6 @@
// ----------------------------------------------------------------------------- : AtomicInt : windows
#if defined(__WXMSW__)
#ifdef _MSC_VER
extern
"C"
{
LONG
__cdecl
_InterlockedIncrement
(
LONG
volatile
*
Addend
);
...
...
@@ -61,16 +60,16 @@
typedef
unsigned
int
AtomicIntEquiv
;
/// An integer that can be incremented and decremented atomicly
class
AtomicInt
Equiv
{
class
AtomicInt
{
public:
AtomicInt
Equiv
(
AtomicIntEquiv
v
)
:
v
(
v
)
{}
AtomicInt
(
AtomicIntEquiv
v
)
:
v
(
v
)
{}
inline
operator
AtomicIntEquiv
()
const
{
return
v
;
}
inline
AtomicInt
Equiv
operator
++
()
{
inline
AtomicInt
operator
++
()
{
return
__sync_add_and_fetch
(
&
v
,
1
);
}
inline
AtomicInt
Equiv
operator
--
()
{
inline
AtomicInt
operator
--
()
{
return
__sync_add_and_fetch
(
&
v
,(
AtomicIntEquiv
)
-
1
);
}
private:
...
...
src/util/smart_ptr.hpp
View file @
3b71faa5
...
...
@@ -149,6 +149,9 @@ inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
// ----------------------------------------------------------------------------- : Intrusive pointer base
template
<
typename
T
>
class
IntrusivePtrBase
;
template
<
typename
T
>
void
intrusive_ptr_add_ref
(
IntrusivePtrBase
<
T
>*
);
template
<
typename
T
>
void
intrusive_ptr_release
(
IntrusivePtrBase
<
T
>*
);
/// Base class for objects wishing to use intrusive_ptrs.
/** There is no implicit virtual destructor, objects are destructed as type T
* Usage:
...
...
@@ -171,19 +174,19 @@ inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
}
private:
AtomicInt
ref_count
;
template
<
typename
T
>
friend
void
intrusive_ptr_add_ref
(
IntrusivePtrBase
*
);
template
<
typename
T
>
friend
void
intrusive_ptr_release
(
IntrusivePtrBase
*
);
friend
void
intrusive_ptr_add_ref
<>
(
IntrusivePtrBase
*
);
friend
void
intrusive_ptr_release
<>
(
IntrusivePtrBase
*
);
};
template
<
typename
T
>
inline
void
intrusive_ptr_add_ref
(
IntrusivePtrBase
<
T
>*
p
)
{
++
p
->
ref_count
;
template
<
typename
T
>
void
intrusive_ptr_add_ref
(
IntrusivePtrBase
<
T
>*
p
)
{
++
(
p
->
ref_count
)
;
}
template
<
typename
T
>
inline
void
intrusive_ptr_release
(
IntrusivePtrBase
<
T
>*
p
)
{
template
<
typename
T
>
void
intrusive_ptr_release
(
IntrusivePtrBase
<
T
>*
p
)
{
if
(
--
p
->
ref_count
==
0
)
{
static_cast
<
T
*>
(
p
)
->
destroy
();
}
}
// ----------------------------------------------------------------------------- : Intrusive pointer base : virtual
/// IntrusivePtrBase with a virtual destructor
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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