Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
aeva
graph
Commits
72dbc071
Commit
72dbc071
authored
Mar 10, 2022
by
David Thompson
Browse files
WIP: Removal of assigned IDs from ID space upon destruction.
parent
125e6efb
Changes
4
Hide whitespace changes
Inline
Side-by-side
smtk/markup/AssignedIds.cxx
View file @
72dbc071
// Copyright © Kitware Inc under the [BSD-3-clause license](https://kitware.com/licenses/bsd.md).
#include
"smtk/markup/AssignedIds.h"
#include
"smtk/markup/IdSpace.h"
namespace
smtk
{
namespace
markup
{
AssignedIds
::~
AssignedIds
()
=
default
;
AssignedIds
::~
AssignedIds
()
{
// Always remove ourselves from our containing IdSpace.
if
(
auto
idspace
=
m_space
.
lock
())
{
idspace
->
removeEntry
(
*
this
);
}
}
AssignedIds
::
IdRange
AssignedIds
::
range
()
const
{
...
...
smtk/markup/IdSpace.cxx
View file @
72dbc071
...
...
@@ -202,9 +202,14 @@ IdSpace::IdType IdSpace::numberOfIdsInRangeOfNature(IdType begin, IdType end, Na
return
count
;
}
bool
IdSpace
::
removeEntry
(
AssignedIds
&
entry
)
bool
IdSpace
::
removeEntry
(
const
AssignedIds
&
entry
)
{
return
false
;
auto
*
entryPointer
=
const_cast
<
AssignedIds
*>
(
&
entry
);
auto
span
=
std
::
make_pair
(
discrete_interval
<
IdType
>::
right_open
(
entry
.
range
()[
0
],
entry
.
range
()[
1
]),
std
::
set
<
AssignedIds
*>
{
entryPointer
});
m_entries
-=
span
;
return
true
;
}
std
::
array
<
IdSpace
::
IdType
,
2
>
IdSpace
::
clampedRange
(
...
...
smtk/markup/IdSpace.h
View file @
72dbc071
...
...
@@ -142,7 +142,7 @@ protected:
friend
class
AssignedIds
;
/// This method is called by the AssignedIds destructor to unregister itself from m_entries.
bool
removeEntry
(
AssignedIds
&
entry
);
bool
removeEntry
(
const
AssignedIds
&
entry
);
static
std
::
array
<
IdSpace
::
IdType
,
2
>
clampedRange
(
const
std
::
array
<
IdType
,
2
>&
unclamped
,
...
...
smtk/markup/testing/cxx/TestIds.cxx
View file @
72dbc071
...
...
@@ -101,5 +101,13 @@ int TestIds(int argc, char** argv)
test
(
primary3
->
range
()[
0
]
==
21
,
"Expected second range to start at 21."
);
test
(
primary3
->
range
()[
1
]
==
31
,
"Expected second range to end at 31."
);
// Now verify that deleting assigned IDs removes them from the id-space.
reference2
=
nullptr
;
// This should cause the assigned IDs to be destroyed.
nn
=
pointIds
->
numberOfIdsInRangeOfNature
(
1
,
31
,
Nature
::
Referential
);
std
::
cout
<<
nn
<<
" referential IDs in [1,31[ after removing reference2.
\n
"
;
test
(
nn
==
10
,
"Expected 10 referential IDs."
);
// TODO: Warn or fail if referential entries would remain in a range when
// removing primary or non-exclusive entries.
return
0
;
}
Write
Preview
Supports
Markdown
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