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
537de9e6
Commit
537de9e6
authored
Jan 10, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move rtti_pair to its own header
parent
2aad39d0
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
158 additions
and
64 deletions
+158
-64
doc/tex/Messages.tex
doc/tex/Messages.tex
+1
-5
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+1
-0
libcaf_core/caf/actor_system.hpp
libcaf_core/caf/actor_system.hpp
+0
-8
libcaf_core/caf/detail/tuple_vals.hpp
libcaf_core/caf/detail/tuple_vals.hpp
+5
-20
libcaf_core/caf/rtti_pair.hpp
libcaf_core/caf/rtti_pair.hpp
+53
-0
libcaf_core/caf/type_erased_tuple.hpp
libcaf_core/caf/type_erased_tuple.hpp
+5
-9
libcaf_core/caf/type_erased_value.hpp
libcaf_core/caf/type_erased_value.hpp
+2
-5
libcaf_core/src/concatenated_tuple.cpp
libcaf_core/src/concatenated_tuple.cpp
+1
-1
libcaf_core/src/decorated_tuple.cpp
libcaf_core/src/decorated_tuple.cpp
+1
-1
libcaf_core/src/merged_tuple.cpp
libcaf_core/src/merged_tuple.cpp
+1
-1
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+1
-1
libcaf_core/src/rtti_pair.cpp
libcaf_core/src/rtti_pair.cpp
+32
-0
libcaf_core/test/match.cpp
libcaf_core/test/match.cpp
+4
-13
libcaf_core/test/rtti_pair.cpp
libcaf_core/test/rtti_pair.cpp
+51
-0
No files found.
doc/tex/Messages.tex
View file @
537de9e6
...
@@ -43,11 +43,7 @@ behavior.
...
@@ -43,11 +43,7 @@ behavior.
\begin{center}
\begin{center}
\begin{tabular}
{
ll
}
\begin{tabular}
{
ll
}
\textbf
{
Types
}
&
~
\\
\textbf
{
Observers
}
&
~
\\
\hline
\lstinline
^
rtti
_
pair
^
&
\lstinline
^
std::pair<uint16
_
t, const std::type
_
info*>
^
\\
\hline
~
&
~
\\
\textbf
{
Observers
}
&
~
\\
\hline
\hline
\lstinline
^
bool empty()
^
&
Returns whether this message is empty.
\\
\lstinline
^
bool empty()
^
&
Returns whether this message is empty.
\\
\hline
\hline
...
...
libcaf_core/CMakeLists.txt
View file @
537de9e6
...
@@ -91,6 +91,7 @@ set(LIBCAF_CORE_SRCS
...
@@ -91,6 +91,7 @@ set(LIBCAF_CORE_SRCS
src/response_promise.cpp
src/response_promise.cpp
src/resumable.cpp
src/resumable.cpp
src/ripemd_160.cpp
src/ripemd_160.cpp
src/rtti_pair.cpp
src/runtime_settings_map.cpp
src/runtime_settings_map.cpp
src/scheduled_actor.cpp
src/scheduled_actor.cpp
src/scoped_actor.cpp
src/scoped_actor.cpp
...
...
libcaf_core/caf/actor_system.hpp
View file @
537de9e6
...
@@ -53,14 +53,6 @@
...
@@ -53,14 +53,6 @@
namespace
caf
{
namespace
caf
{
using
rtti_pair
=
std
::
pair
<
uint16_t
,
const
std
::
type_info
*>
;
using
rtti_pair_vec
=
std
::
vector
<
rtti_pair
>
;
using
rtti_pair_vec_triple
=
std
::
tuple
<
rtti_pair_vec
,
rtti_pair_vec
,
rtti_pair_vec
>
;
template
<
class
T
>
template
<
class
T
>
struct
mpi_field_access
{
struct
mpi_field_access
{
std
::
string
operator
()(
const
uniform_type_info_map
&
types
)
{
std
::
string
operator
()(
const
uniform_type_info_map
&
types
)
{
...
...
libcaf_core/caf/detail/tuple_vals.hpp
View file @
537de9e6
...
@@ -21,11 +21,12 @@
...
@@ -21,11 +21,12 @@
#include <tuple>
#include <tuple>
#include <stdexcept>
#include <stdexcept>
#include "caf/type_nr.hpp"
#include "caf/serializer.hpp"
#include "caf/deserializer.hpp"
#include "caf/deep_to_string.hpp"
#include "caf/deep_to_string.hpp"
#include "caf/deserializer.hpp"
#include "caf/make_type_erased_value.hpp"
#include "caf/make_type_erased_value.hpp"
#include "caf/rtti_pair.hpp"
#include "caf/serializer.hpp"
#include "caf/type_nr.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/safe_equal.hpp"
#include "caf/detail/safe_equal.hpp"
...
@@ -65,20 +66,6 @@ struct void_ptr_access {
...
@@ -65,20 +66,6 @@ struct void_ptr_access {
}
}
};
};
template
<
class
T
,
uint16_t
N
=
type_nr
<
T
>
::
value
>
struct
tuple_vals_type_helper
{
static
typename
message_data
::
rtti_pair
get
()
noexcept
{
return
{
N
,
nullptr
};
}
};
template
<
class
T
>
struct
tuple_vals_type_helper
<
T
,
0
>
{
static
typename
message_data
::
rtti_pair
get
()
noexcept
{
return
{
0
,
&
typeid
(
T
)};
}
};
template
<
class
Base
,
class
...
Ts
>
template
<
class
Base
,
class
...
Ts
>
class
tuple_vals_impl
:
public
Base
{
class
tuple_vals_impl
:
public
Base
{
public:
public:
...
@@ -90,8 +77,6 @@ public:
...
@@ -90,8 +77,6 @@ public:
using
super
=
message_data
;
using
super
=
message_data
;
using
rtti_pair
=
typename
message_data
::
rtti_pair
;
using
data_type
=
std
::
tuple
<
Ts
...
>
;
using
data_type
=
std
::
tuple
<
Ts
...
>
;
// -- friend functions -------------------------------------------------------
// -- friend functions -------------------------------------------------------
...
@@ -107,7 +92,7 @@ public:
...
@@ -107,7 +92,7 @@ public:
template
<
class
...
Us
>
template
<
class
...
Us
>
tuple_vals_impl
(
Us
&&
...
xs
)
tuple_vals_impl
(
Us
&&
...
xs
)
:
data_
(
std
::
forward
<
Us
>
(
xs
)...),
:
data_
(
std
::
forward
<
Us
>
(
xs
)...),
types_
{{
tuple_vals_type_helper
<
Ts
>::
get
()...}}
{
types_
{{
make_rtti_pair
<
Ts
>
()...}}
{
// nop
// nop
}
}
...
...
libcaf_core/caf/rtti_pair.hpp
0 → 100644
View file @
537de9e6
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* 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. *
******************************************************************************/
#pragma once
#include <cstdint>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include "caf/type_nr.hpp"
namespace
caf
{
/// Bundles the type number with its C++ `type_info` object. The type number is
/// non-zero for builtin types and the pointer to the `type_info` object is
/// non-null for custom types.
using
rtti_pair
=
std
::
pair
<
uint16_t
,
const
std
::
type_info
*>
;
/// @relates rtti_pair
template
<
class
T
>
typename
std
::
enable_if
<
type_nr
<
T
>::
value
==
0
,
rtti_pair
>::
type
make_rtti_pair
()
{
return
{
0
,
&
typeid
(
T
)};
}
/// @relates rtti_pair
template
<
class
T
>
typename
std
::
enable_if
<
type_nr
<
T
>::
value
!=
0
,
rtti_pair
>::
type
make_rtti_pair
()
{
auto
n
=
type_nr
<
T
>::
value
;
return
{
n
,
nullptr
};
}
/// @relates rtti_pair
std
::
string
to_string
(
rtti_pair
x
);
}
// namespace caf
libcaf_core/caf/type_erased_tuple.hpp
View file @
537de9e6
...
@@ -23,24 +23,20 @@
...
@@ -23,24 +23,20 @@
#include <cstdint>
#include <cstdint>
#include <typeinfo>
#include <typeinfo>
#include "caf/detail/apply_args.hpp"
#include "caf/detail/pseudo_tuple.hpp"
#include "caf/detail/try_match.hpp"
#include "caf/fwd.hpp"
#include "caf/fwd.hpp"
#include "caf/type_nr.hpp"
#include "caf/optional.hpp"
#include "caf/optional.hpp"
#include "caf/rtti_pair.hpp"
#include "caf/type_erased_value.hpp"
#include "caf/type_erased_value.hpp"
#include "caf/type_nr.hpp"
#include "caf/detail/try_match.hpp"
#include "caf/detail/apply_args.hpp"
#include "caf/detail/pseudo_tuple.hpp"
namespace
caf
{
namespace
caf
{
/// Represents a tuple of type-erased values.
/// Represents a tuple of type-erased values.
class
type_erased_tuple
{
class
type_erased_tuple
{
public:
public:
// -- member types -----------------------------------------------------------
using
rtti_pair
=
std
::
pair
<
uint16_t
,
const
std
::
type_info
*>
;
// -- constructors, destructors, and assignment operators --------------------
// -- constructors, destructors, and assignment operators --------------------
type_erased_tuple
()
=
default
;
type_erased_tuple
()
=
default
;
...
...
libcaf_core/caf/type_erased_value.hpp
View file @
537de9e6
...
@@ -22,8 +22,9 @@
...
@@ -22,8 +22,9 @@
#include <typeinfo>
#include <typeinfo>
#include <functional>
#include <functional>
#include "caf/fwd.hpp"
#include "caf/error.hpp"
#include "caf/error.hpp"
#include "caf/fwd.hpp"
#include "caf/rtti_pair.hpp"
#include "caf/type_nr.hpp"
#include "caf/type_nr.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -31,10 +32,6 @@ namespace caf {
...
@@ -31,10 +32,6 @@ namespace caf {
/// Represents a single type-erased value.
/// Represents a single type-erased value.
class
type_erased_value
{
class
type_erased_value
{
public:
public:
// -- member types -----------------------------------------------------------
using
rtti_pair
=
std
::
pair
<
uint16_t
,
const
std
::
type_info
*>
;
// -- constructors, destructors, and assignment operators --------------------
// -- constructors, destructors, and assignment operators --------------------
virtual
~
type_erased_value
();
virtual
~
type_erased_value
();
...
...
libcaf_core/src/concatenated_tuple.cpp
View file @
537de9e6
...
@@ -77,7 +77,7 @@ uint32_t concatenated_tuple::type_token() const noexcept {
...
@@ -77,7 +77,7 @@ uint32_t concatenated_tuple::type_token() const noexcept {
return
type_token_
;
return
type_token_
;
}
}
message_data
::
rtti_pair
concatenated_tuple
::
type
(
size_t
pos
)
const
noexcept
{
rtti_pair
concatenated_tuple
::
type
(
size_t
pos
)
const
noexcept
{
CAF_ASSERT
(
pos
<
size
());
CAF_ASSERT
(
pos
<
size
());
auto
selected
=
select
(
pos
);
auto
selected
=
select
(
pos
);
return
selected
.
first
->
type
(
selected
.
second
);
return
selected
.
first
->
type
(
selected
.
second
);
...
...
libcaf_core/src/decorated_tuple.cpp
View file @
537de9e6
...
@@ -71,7 +71,7 @@ uint32_t decorated_tuple::type_token() const noexcept {
...
@@ -71,7 +71,7 @@ uint32_t decorated_tuple::type_token() const noexcept {
return
type_token_
;
return
type_token_
;
}
}
message_data
::
rtti_pair
decorated_tuple
::
type
(
size_t
pos
)
const
noexcept
{
rtti_pair
decorated_tuple
::
type
(
size_t
pos
)
const
noexcept
{
CAF_ASSERT
(
pos
<
size
());
CAF_ASSERT
(
pos
<
size
());
return
decorated_
->
type
(
mapping_
[
pos
]);
return
decorated_
->
type
(
mapping_
[
pos
]);
}
}
...
...
libcaf_core/src/merged_tuple.cpp
View file @
537de9e6
...
@@ -77,7 +77,7 @@ uint32_t merged_tuple::type_token() const noexcept {
...
@@ -77,7 +77,7 @@ uint32_t merged_tuple::type_token() const noexcept {
return
type_token_
;
return
type_token_
;
}
}
merged_tuple
::
rtti_pair
merged_tuple
::
type
(
size_t
pos
)
const
noexcept
{
rtti_pair
merged_tuple
::
type
(
size_t
pos
)
const
noexcept
{
CAF_ASSERT
(
pos
<
mapping_
.
size
());
CAF_ASSERT
(
pos
<
mapping_
.
size
());
auto
&
p
=
mapping_
[
pos
];
auto
&
p
=
mapping_
[
pos
];
return
data_
[
p
.
first
]
->
type
(
p
.
second
);
return
data_
[
p
.
first
]
->
type
(
p
.
second
);
...
...
libcaf_core/src/message.cpp
View file @
537de9e6
...
@@ -77,7 +77,7 @@ uint32_t message::type_token() const noexcept {
...
@@ -77,7 +77,7 @@ uint32_t message::type_token() const noexcept {
return
vals_
!=
nullptr
?
vals_
->
type_token
()
:
0xFFFFFFFF
;
return
vals_
!=
nullptr
?
vals_
->
type_token
()
:
0xFFFFFFFF
;
}
}
message
::
rtti_pair
message
::
type
(
size_t
pos
)
const
noexcept
{
rtti_pair
message
::
type
(
size_t
pos
)
const
noexcept
{
CAF_ASSERT
(
vals_
!=
nullptr
);
CAF_ASSERT
(
vals_
!=
nullptr
);
return
vals_
->
type
(
pos
);
return
vals_
->
type
(
pos
);
}
}
...
...
libcaf_core/src/rtti_pair.cpp
0 → 100644
View file @
537de9e6
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* 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/rtti_pair.hpp"
namespace
caf
{
std
::
string
to_string
(
rtti_pair
x
)
{
std
::
string
result
=
"("
;
result
+=
std
::
to_string
(
x
.
first
);
result
+=
", "
;
result
+=
x
.
second
!=
nullptr
?
x
.
second
->
name
()
:
"<null>"
;
result
+=
")"
;
return
result
;
}
}
// namespace caf
libcaf_core/test/match.cpp
View file @
537de9e6
...
@@ -16,16 +16,18 @@
...
@@ -16,16 +16,18 @@
* http://www.boost.org/LICENSE_1_0.txt. *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
******************************************************************************/
#include "caf/
config
.hpp"
#include "caf/
message
.hpp"
#define CAF_SUITE match
#define CAF_SUITE match
#include "caf/test/unit_test.hpp"
#include "caf/test/unit_test.hpp"
#include <functional>
#include <functional>
#include "caf/make_type_erased_tuple_view.hpp"
#include "caf/message_builder.hpp"
#include "caf/message_builder.hpp"
#include "caf/message_handler.hpp"
#include "caf/message_handler.hpp"
#include "caf/
make_type_erased_tuple_view
.hpp"
#include "caf/
rtti_pair
.hpp"
using
namespace
caf
;
using
namespace
caf
;
using
namespace
std
;
using
namespace
std
;
...
@@ -35,17 +37,6 @@ using ho_atom = atom_constant<atom("ho")>;
...
@@ -35,17 +37,6 @@ using ho_atom = atom_constant<atom("ho")>;
namespace
{
namespace
{
using
rtti_pair
=
std
::
pair
<
uint16_t
,
const
std
::
type_info
*>
;
std
::
string
to_string
(
const
rtti_pair
&
x
)
{
std
::
string
result
=
"("
;
result
+=
std
::
to_string
(
x
.
first
);
result
+=
", "
;
result
+=
x
.
second
!=
nullptr
?
x
.
second
->
name
()
:
"<null>"
;
result
+=
")"
;
return
result
;
}
struct
fixture
{
struct
fixture
{
using
array_type
=
std
::
array
<
bool
,
4
>
;
using
array_type
=
std
::
array
<
bool
,
4
>
;
...
...
libcaf_core/test/rtti_pair.cpp
0 → 100644
View file @
537de9e6
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2019 Dominik Charousset *
* *
* 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. *
******************************************************************************/
#define CAF_SUITE rtti_pair
#include "caf/rtti_pair.hpp"
#include "caf/test/dsl.hpp"
using
namespace
caf
;
namespace
{
struct
foo
{
int
x
;
int
y
;
};
}
// namespace <anonymous>
CAF_TEST
(
make_rtti_pair
)
{
auto
n
=
type_nr
<
int32_t
>::
value
;
CAF_REQUIRE_NOT_EQUAL
(
n
,
0u
);
auto
x1
=
make_rtti_pair
<
int32_t
>
();
CAF_CHECK_EQUAL
(
x1
.
first
,
n
);
CAF_CHECK_EQUAL
(
x1
.
second
,
nullptr
);
auto
x2
=
make_rtti_pair
<
foo
>
();
CAF_CHECK_EQUAL
(
x2
.
first
,
0
);
CAF_CHECK_EQUAL
(
x2
.
second
,
&
typeid
(
foo
));
}
CAF_TEST
(
to_string
)
{
auto
n
=
type_nr
<
int32_t
>::
value
;
CAF_CHECK_EQUAL
(
to_string
(
make_rtti_pair
<
int32_t
>
()),
"("
+
std
::
to_string
(
n
)
+
", <null>)"
);
}
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