Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
condenser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
hive
condenser
Commits
8e05ca8f
Commit
8e05ca8f
authored
8 years ago
by
theoreticalbts
Browse files
Options
Downloads
Patches
Plain Diff
Move undo_state out of class
#3
Also add typedef for id_type_set
parent
a1ca9309
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/chainbase/chainbase.hpp
+28
-24
28 additions, 24 deletions
include/chainbase/chainbase.hpp
with
28 additions
and
24 deletions
include/chainbase/chainbase.hpp
+
28
−
24
View file @
8e05ca8f
...
@@ -112,6 +112,30 @@ namespace chainbase {
...
@@ -112,6 +112,30 @@ namespace chainbase {
template<typename Constructor, typename Allocator> \
template<typename Constructor, typename Allocator> \
OBJECT_TYPE( Constructor&& c, Allocator&& ) { c(*this); }
OBJECT_TYPE( Constructor&& c, Allocator&& ) { c(*this); }
template
<
typename
value_type
>
class
undo_state
{
public:
typedef
typename
value_type
::
id_type
id_type
;
typedef
allocator
<
std
::
pair
<
const
id_type
,
value_type
>
>
id_value_allocator_type
;
typedef
allocator
<
id_type
>
id_allocator_type
;
template
<
typename
T
>
undo_state
(
allocator
<
T
>
al
)
:
old_values
(
id_value_allocator_type
(
al
.
get_segment_manager
()
)
),
removed_values
(
id_value_allocator_type
(
al
.
get_segment_manager
()
)
),
new_ids
(
id_allocator_type
(
al
.
get_segment_manager
()
)
){}
typedef
boost
::
interprocess
::
map
<
id_type
,
value_type
,
std
::
less
<
id_type
>
,
id_value_allocator_type
>
id_value_type_map
;
typedef
boost
::
interprocess
::
set
<
id_type
,
std
::
less
<
id_type
>
,
id_allocator_type
>
id_type_set
;
id_value_type_map
old_values
;
id_value_type_map
removed_values
;
id_type_set
new_ids
;
id_type
old_next_id
=
0
;
int64_t
revision
=
0
;
};
/**
/**
* The value_type stored in the multiindex container must have a integer field with the name 'id'. This will
* The value_type stored in the multiindex container must have a integer field with the name 'id'. This will
* be the primary key and it will be assigned and managed by generic_index.
* be the primary key and it will be assigned and managed by generic_index.
...
@@ -119,12 +143,14 @@ namespace chainbase {
...
@@ -119,12 +143,14 @@ namespace chainbase {
* Additionally, the constructor for value_type must take an allocator
* Additionally, the constructor for value_type must take an allocator
*/
*/
template
<
typename
MultiIndexType
>
template
<
typename
MultiIndexType
>
class
generic_index
{
class
generic_index
{
public:
public:
typedef
bip
::
managed_mapped_file
::
segment_manager
segment_manager_type
;
typedef
bip
::
managed_mapped_file
::
segment_manager
segment_manager_type
;
typedef
MultiIndexType
index_type
;
typedef
MultiIndexType
index_type
;
typedef
typename
index_type
::
value_type
value_type
;
typedef
typename
index_type
::
value_type
value_type
;
typedef
bip
::
allocator
<
generic_index
,
segment_manager_type
>
allocator_type
;
typedef
bip
::
allocator
<
generic_index
,
segment_manager_type
>
allocator_type
;
typedef
undo_state
<
value_type
>
undo_state_type
;
generic_index
(
allocator
<
value_type
>
a
)
generic_index
(
allocator
<
value_type
>
a
)
:
_stack
(
a
),
_indices
(
a
),
_size_of_value_type
(
sizeof
(
typename
MultiIndexType
::
node_type
)
),
_size_of_this
(
sizeof
(
*
this
)){}
:
_stack
(
a
),
_indices
(
a
),
_size_of_value_type
(
sizeof
(
typename
MultiIndexType
::
node_type
)
),
_size_of_this
(
sizeof
(
*
this
)){}
...
@@ -186,28 +212,6 @@ namespace chainbase {
...
@@ -186,28 +212,6 @@ namespace chainbase {
const
index_type
&
indices
()
const
{
return
_indices
;
}
const
index_type
&
indices
()
const
{
return
_indices
;
}
class
undo_state
{
public:
typedef
typename
value_type
::
id_type
id_type
;
typedef
allocator
<
std
::
pair
<
const
id_type
,
value_type
>
>
id_value_allocator_type
;
typedef
allocator
<
id_type
>
id_allocator_type
;
template
<
typename
T
>
undo_state
(
allocator
<
T
>
al
)
:
old_values
(
id_value_allocator_type
(
al
.
get_segment_manager
()
)
),
removed_values
(
id_value_allocator_type
(
al
.
get_segment_manager
()
)
),
new_ids
(
id_allocator_type
(
al
.
get_segment_manager
()
)
){}
typedef
boost
::
interprocess
::
map
<
id_type
,
value_type
,
std
::
less
<
id_type
>
,
id_value_allocator_type
>
id_value_type_map
;
id_value_type_map
old_values
;
id_value_type_map
removed_values
;
boost
::
interprocess
::
set
<
id_type
,
std
::
less
<
id_type
>
,
id_allocator_type
>
new_ids
;
id_type
old_next_id
=
0
;
int64_t
revision
=
0
;
};
class
session
{
class
session
{
public:
public:
session
(
session
&&
mv
)
session
(
session
&&
mv
)
...
@@ -483,7 +487,7 @@ namespace chainbase {
...
@@ -483,7 +487,7 @@ namespace chainbase {
head
.
new_ids
.
insert
(
v
.
id
);
head
.
new_ids
.
insert
(
v
.
id
);
}
}
boost
::
interprocess
::
deque
<
undo_state
,
allocator
<
undo_state
>
>
_stack
;
boost
::
interprocess
::
deque
<
undo_state
_type
,
allocator
<
undo_state
_type
>
>
_stack
;
/**
/**
* Each new session increments the revision, a squash will decrement the revision by combining
* Each new session increments the revision, a squash will decrement the revision by combining
...
...
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