Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
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
cpp-libs
Actor Framework
Commits
d5284194
Commit
d5284194
authored
Feb 02, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `message_iterator`
parent
18c47cbd
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
229 deletions
+20
-229
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+0
-1
libcaf_core/caf/detail/message_data.hpp
libcaf_core/caf/detail/message_data.hpp
+0
-26
libcaf_core/caf/detail/message_iterator.hpp
libcaf_core/caf/detail/message_iterator.hpp
+0
-111
libcaf_core/caf/detail/try_match.hpp
libcaf_core/caf/detail/try_match.hpp
+3
-3
libcaf_core/caf/message.hpp
libcaf_core/caf/message.hpp
+0
-15
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+0
-8
libcaf_core/src/message_builder.cpp
libcaf_core/src/message_builder.cpp
+0
-2
libcaf_core/src/message_data.cpp
libcaf_core/src/message_data.cpp
+0
-4
libcaf_core/src/message_iterator.cpp
libcaf_core/src/message_iterator.cpp
+0
-43
libcaf_core/src/try_match.cpp
libcaf_core/src/try_match.cpp
+17
-16
No files found.
libcaf_core/CMakeLists.txt
View file @
d5284194
...
...
@@ -58,7 +58,6 @@ set (LIBCAF_CORE_SRCS
src/message_builder.cpp
src/message_data.cpp
src/message_handler.cpp
src/message_iterator.cpp
src/node_id.cpp
src/ref_counted.cpp
src/response_promise.cpp
...
...
libcaf_core/caf/detail/message_data.hpp
View file @
d5284194
...
...
@@ -31,30 +31,20 @@
#include "caf/uniform_type_info.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/message_iterator.hpp"
namespace
caf
{
namespace
detail
{
class
message_data
:
public
ref_counted
{
using
super
=
ref_counted
;
public:
message_data
();
// mutators
virtual
void
*
mutable_at
(
size_t
pos
)
=
0
;
virtual
void
*
mutable_native_data
();
// accessors
virtual
size_t
size
()
const
=
0
;
virtual
message_data
*
copy
()
const
=
0
;
virtual
const
void
*
at
(
size_t
pos
)
const
=
0
;
std
::
string
tuple_type_names
()
const
;
/**
...
...
@@ -78,22 +68,6 @@ class message_data : public ref_counted {
bool
equals
(
const
message_data
&
other
)
const
;
using
const_iterator
=
message_iterator
;
inline
const_iterator
begin
()
const
{
return
{
this
};
}
inline
const_iterator
cbegin
()
const
{
return
{
this
};
}
inline
const_iterator
end
()
const
{
return
{
this
,
size
()};
}
inline
const_iterator
cend
()
const
{
return
{
this
,
size
()};
}
class
ptr
{
public:
...
...
libcaf_core/caf/detail/message_iterator.hpp
deleted
100644 → 0
View file @
18c47cbd
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_MESSAGE_ITERATOR_HPP
#define CAF_DETAIL_MESSAGE_ITERATOR_HPP
#include <cstddef>
#include <typeinfo>
#include "caf/fwd.hpp"
namespace
caf
{
namespace
detail
{
class
message_data
;
class
message_iterator
{
public:
using
pointer
=
message_data
*
;
using
const_pointer
=
const
message_data
*
;
message_iterator
(
const_pointer
data
,
size_t
pos
=
0
);
message_iterator
(
const
message_iterator
&
)
=
default
;
message_iterator
&
operator
=
(
const
message_iterator
&
)
=
default
;
inline
message_iterator
&
operator
++
()
{
++
m_pos
;
return
*
this
;
}
inline
message_iterator
&
operator
--
()
{
--
m_pos
;
return
*
this
;
}
inline
message_iterator
operator
+
(
size_t
offset
)
{
return
{
m_data
,
m_pos
+
offset
};
}
inline
message_iterator
&
operator
+=
(
size_t
offset
)
{
m_pos
+=
offset
;
return
*
this
;
}
inline
message_iterator
operator
-
(
size_t
offset
)
{
return
{
m_data
,
m_pos
-
offset
};
}
inline
message_iterator
&
operator
-=
(
size_t
offset
)
{
m_pos
-=
offset
;
return
*
this
;
}
inline
size_t
position
()
const
{
return
m_pos
;
}
inline
const_pointer
data
()
const
{
return
m_data
;
}
const
void
*
value
()
const
;
bool
match_element
(
uint16_t
typenr
,
const
std
::
type_info
*
rtti
)
const
;
template
<
class
T
>
const
T
&
value_as
()
const
{
return
*
reinterpret_cast
<
const
T
*>
(
value
());
}
inline
message_iterator
&
operator
*
()
{
return
*
this
;
}
private:
size_t
m_pos
;
const
message_data
*
m_data
;
};
inline
bool
operator
==
(
const
message_iterator
&
lhs
,
const
message_iterator
&
rhs
)
{
return
lhs
.
data
()
==
rhs
.
data
()
&&
lhs
.
position
()
==
rhs
.
position
();
}
inline
bool
operator
!=
(
const
message_iterator
&
lhs
,
const
message_iterator
&
rhs
)
{
return
!
(
lhs
==
rhs
);
}
}
// namespace detail
}
// namespace caf
#endif // CAF_DETAIL_MESSAGE_ITERATOR_HPP
libcaf_core/caf/detail/try_match.hpp
View file @
d5284194
...
...
@@ -40,12 +40,12 @@ struct meta_element {
atom_value
v
;
uint16_t
typenr
;
const
std
::
type_info
*
type
;
bool
(
*
fun
)(
const
meta_element
&
,
const
message
_iterator
&
,
void
**
);
bool
(
*
fun
)(
const
meta_element
&
,
const
message
&
,
size_t
,
void
**
);
};
bool
match_element
(
const
meta_element
&
,
const
message
_iterator
&
,
void
**
);
bool
match_element
(
const
meta_element
&
,
const
message
&
,
size_t
,
void
**
);
bool
match_atom_constant
(
const
meta_element
&
,
const
message
_iterator
&
,
void
**
);
bool
match_atom_constant
(
const
meta_element
&
,
const
message
&
,
size_t
,
void
**
);
template
<
class
T
,
uint16_t
TN
=
detail
::
type_nr
<
T
>
::
value
>
struct
meta_element_factory
{
...
...
libcaf_core/caf/message.hpp
View file @
d5284194
...
...
@@ -58,11 +58,6 @@ class message {
*/
using
data_ptr
=
detail
::
message_data
::
ptr
;
/**
* An iterator to access each element as `const void*.
*/
using
const_iterator
=
detail
::
message_data
::
const_iterator
;
/**
* Creates an empty tuple.
*/
...
...
@@ -166,16 +161,6 @@ class message {
return
*
reinterpret_cast
<
T
*>
(
mutable_at
(
p
));
}
/**
* Returns an iterator to the beginning.
*/
const_iterator
begin
()
const
;
/**
* Returns an iterator to the end.
*/
const_iterator
end
()
const
;
/**
* Returns a copy-on-write pointer to the internal data.
*/
...
...
libcaf_core/src/message.cpp
View file @
d5284194
...
...
@@ -112,14 +112,6 @@ optional<message> message::apply(message_handler handler) {
return
handler
(
*
this
);
}
message
::
const_iterator
message
::
begin
()
const
{
return
m_vals
?
m_vals
->
begin
()
:
const_iterator
{
nullptr
,
0
};
}
message
::
const_iterator
message
::
end
()
const
{
return
m_vals
?
m_vals
->
end
()
:
const_iterator
{
nullptr
,
0
};
}
message
message
::
filter_impl
(
size_t
start
,
message_handler
handler
)
const
{
auto
s
=
size
();
for
(
size_t
i
=
start
;
i
<
s
;
++
i
)
{
...
...
libcaf_core/src/message_builder.cpp
View file @
d5284194
...
...
@@ -29,8 +29,6 @@ class message_builder::dynamic_msg_data : public detail::message_data {
public:
using
super
=
message_data
;
using
message_data
::
const_iterator
;
dynamic_msg_data
()
:
m_type_token
(
0xFFFFFFFF
)
{
// nop
}
...
...
libcaf_core/src/message_data.cpp
View file @
d5284194
...
...
@@ -24,10 +24,6 @@
namespace
caf
{
namespace
detail
{
message_data
::
message_data
()
{
// nop
}
bool
message_data
::
equals
(
const
message_data
&
other
)
const
{
if
(
this
==
&
other
)
{
return
true
;
...
...
libcaf_core/src/message_iterator.cpp
deleted
100644 → 0
View file @
18c47cbd
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/detail/message_iterator.hpp"
#include "caf/detail/message_data.hpp"
namespace
caf
{
namespace
detail
{
message_iterator
::
message_iterator
(
const_pointer
dataptr
,
size_t
pos
)
:
m_pos
(
pos
),
m_data
(
dataptr
)
{
// nop
}
const
void
*
message_iterator
::
value
()
const
{
return
m_data
->
at
(
m_pos
);
}
bool
message_iterator
::
match_element
(
uint16_t
typenr
,
const
std
::
type_info
*
rtti
)
const
{
return
m_data
->
match_element
(
m_pos
,
typenr
,
rtti
);
}
}
// namespace detail
}
// namespace caf
libcaf_core/src/try_match.cpp
View file @
d5284194
...
...
@@ -28,26 +28,27 @@ bool is_wildcard(const meta_element& me) {
return
me
.
typenr
==
0
&&
me
.
type
==
nullptr
;
}
bool
match_element
(
const
meta_element
&
me
,
const
message
_iterator
&
iter
,
void
**
storage
)
{
bool
match_element
(
const
meta_element
&
me
,
const
message
&
msg
,
size_t
pos
,
void
**
storage
)
{
CAF_REQUIRE
(
me
.
typenr
!=
0
||
me
.
type
!=
nullptr
);
if
(
!
iter
.
match_element
(
me
.
typenr
,
me
.
type
))
{
if
(
!
msg
.
match_element
(
pos
,
me
.
typenr
,
me
.
type
))
{
return
false
;
}
if
(
storage
)
{
*
storage
=
const_cast
<
void
*>
(
iter
.
value
(
));
*
storage
=
const_cast
<
void
*>
(
msg
.
at
(
pos
));
}
return
true
;
}
bool
match_atom_constant
(
const
meta_element
&
me
,
const
message
_iterator
&
iter
,
void
**
storage
)
{
bool
match_atom_constant
(
const
meta_element
&
me
,
const
message
&
msg
,
size_t
pos
,
void
**
storage
)
{
CAF_REQUIRE
(
me
.
typenr
==
detail
::
type_nr
<
atom_value
>::
value
);
if
(
!
iter
.
match_element
(
detail
::
type_nr
<
atom_value
>::
value
,
nullptr
))
{
if
(
!
msg
.
match_element
(
pos
,
detail
::
type_nr
<
atom_value
>::
value
,
nullptr
))
{
return
false
;
}
if
(
storage
)
{
if
(
iter
.
value_as
<
atom_value
>
()
!=
me
.
v
)
{
auto
ptr
=
msg
.
at
(
pos
);
if
(
me
.
v
!=
*
reinterpret_cast
<
const
atom_value
*>
(
ptr
))
{
return
false
;
}
// This assignment casts `atom_value` to `atom_constant<V>*`.
...
...
@@ -56,7 +57,7 @@ bool match_atom_constant(const meta_element& me, const message_iterator& iter,
// throughout the runtime of the program and the atom constant
// does not have any members. Hence, this is nonetheless safe since
// we are never actually going to dereference the pointer.
*
storage
=
const_cast
<
void
*>
(
iter
.
value
()
);
*
storage
=
const_cast
<
void
*>
(
ptr
);
}
return
true
;
}
...
...
@@ -87,10 +88,10 @@ class set_commit_rollback {
size_t
m_fallback_pos
;
};
bool
try_match
(
message_iterator
mbegin
,
message_iterator
mend
,
bool
try_match
(
const
message
&
msg
,
size_t
msg_pos
,
size_t
msg_size
,
pattern_iterator
pbegin
,
pattern_iterator
pend
,
set_commit_rollback
&
storage
)
{
while
(
m
begin
!=
mend
)
{
while
(
m
sg_pos
<
msg_size
)
{
if
(
pbegin
==
pend
)
{
return
false
;
}
...
...
@@ -104,8 +105,8 @@ bool try_match(message_iterator mbegin, message_iterator mend,
// safe current mapping as fallback
storage
.
commit
();
// iterate over remaining values until we found a match
for
(;
m
begin
!=
mend
;
++
mbegin
)
{
if
(
try_match
(
m
begin
,
mend
,
pbegin
,
pend
,
storage
))
{
for
(;
m
sg_pos
<
msg_size
;
++
msg_pos
)
{
if
(
try_match
(
m
sg
,
msg_pos
,
msg_size
,
pbegin
,
pend
,
storage
))
{
return
true
;
}
// restore mapping to fallback (delete invalid mappings)
...
...
@@ -114,13 +115,13 @@ bool try_match(message_iterator mbegin, message_iterator mend,
return
false
;
// no submatch found
}
// inspect current element
if
(
!
pbegin
->
fun
(
*
pbegin
,
m
begin
,
storage
.
current
()))
{
if
(
!
pbegin
->
fun
(
*
pbegin
,
m
sg
,
msg_pos
,
storage
.
current
()))
{
// type mismatch
return
false
;
}
// next iteration
storage
.
inc
();
++
m
begin
;
++
m
sg_pos
;
++
pbegin
;
}
// we found a match if we've inspected each element and consumed
...
...
@@ -130,7 +131,7 @@ bool try_match(message_iterator mbegin, message_iterator mend,
bool
try_match
(
const
message
&
msg
,
pattern_iterator
pb
,
size_t
ps
,
void
**
out
)
{
set_commit_rollback
scr
{
out
};
return
try_match
(
msg
.
begin
(),
msg
.
end
(),
pb
,
pb
+
ps
,
scr
);
return
try_match
(
msg
,
0
,
msg
.
size
(),
pb
,
pb
+
ps
,
scr
);
}
}
// namespace detail
...
...
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