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
b98cfd6e
Commit
b98cfd6e
authored
Jul 21, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix several warnings on GCC and Clang
parent
5744dc5d
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
121 additions
and
82 deletions
+121
-82
libcaf_core/caf/detail/enum_to_string.hpp
libcaf_core/caf/detail/enum_to_string.hpp
+39
-0
libcaf_core/caf/duration.hpp
libcaf_core/caf/duration.hpp
+5
-5
libcaf_core/caf/mailbox_element.hpp
libcaf_core/caf/mailbox_element.hpp
+6
-6
libcaf_core/src/abstract_actor.cpp
libcaf_core/src/abstract_actor.cpp
+13
-10
libcaf_core/src/duration.cpp
libcaf_core/src/duration.cpp
+25
-24
libcaf_core/src/exit_reason.cpp
libcaf_core/src/exit_reason.cpp
+3
-4
libcaf_core/src/logger.cpp
libcaf_core/src/logger.cpp
+2
-2
libcaf_core/src/sec.cpp
libcaf_core/src/sec.cpp
+3
-4
libcaf_core/test/serialization.cpp
libcaf_core/test/serialization.cpp
+4
-6
libcaf_io/caf/io/network/asio_multiplexer_impl.hpp
libcaf_io/caf/io/network/asio_multiplexer_impl.hpp
+5
-5
libcaf_io/src/message_type.cpp
libcaf_io/src/message_type.cpp
+16
-16
No files found.
libcaf_core/caf/detail/enum_to_string.hpp
0 → 100644
View file @
b98cfd6e
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* 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_ENUM_TO_STRING_HPP
#define CAF_DETAIL_ENUM_TO_STRING_HPP
#include <type_traits>
namespace
caf
{
namespace
detail
{
/// Converts x to its underlying type and fetches the name from the
/// lookup table. Assumes consecutive enum values.
template
<
class
E
,
size_t
N
>
const
char
*
enum_to_string
(
E
x
,
const
char
*
(
&
lookup_table
)[
N
])
{
auto
index
=
static_cast
<
typename
std
::
underlying_type
<
E
>::
type
>
(
x
);
return
index
<
N
?
lookup_table
[
index
]
:
"<unknown>"
;
}
}
// namespace detail
}
// namespace caf
#endif // CAF_DETAIL_ENUM_TO_STRING_HPP
libcaf_core/caf/duration.hpp
View file @
b98cfd6e
...
@@ -32,14 +32,14 @@ namespace caf {
...
@@ -32,14 +32,14 @@ namespace caf {
/// SI time units to specify timeouts.
/// SI time units to specify timeouts.
/// @relates duration
/// @relates duration
enum
class
time_unit
:
uint32_t
{
enum
class
time_unit
:
uint32_t
{
invalid
=
0
,
invalid
,
seconds
=
1
,
seconds
,
milliseconds
=
1000
,
milliseconds
,
microseconds
=
1000000
microseconds
};
};
/// Relates time_unit
/// Relates time_unit
std
::
string
to_string
(
const
time_unit
&
x
);
std
::
string
to_string
(
time_unit
x
);
/// Converts the ratio Num/Denom to a `time_unit` if the ratio describes
/// Converts the ratio Num/Denom to a `time_unit` if the ratio describes
/// seconds, milliseconds, microseconds, or minutes. Minutes are mapped
/// seconds, milliseconds, microseconds, or minutes. Minutes are mapped
...
...
libcaf_core/caf/mailbox_element.hpp
View file @
b98cfd6e
...
@@ -104,9 +104,9 @@ class mailbox_element_vals
...
@@ -104,9 +104,9 @@ class mailbox_element_vals
public
detail
::
tuple_vals_impl
<
type_erased_tuple
,
Ts
...
>
{
public
detail
::
tuple_vals_impl
<
type_erased_tuple
,
Ts
...
>
{
public:
public:
template
<
class
...
Us
>
template
<
class
...
Us
>
mailbox_element_vals
(
strong_actor_ptr
&&
sender
,
message_id
id
,
mailbox_element_vals
(
strong_actor_ptr
&&
x0
,
message_id
x1
,
forwarding_stack
&&
stages
,
Us
&&
...
xs
)
forwarding_stack
&&
x2
,
Us
&&
...
xs
)
:
mailbox_element
(
std
::
move
(
sender
),
id
,
std
::
move
(
stages
)),
:
mailbox_element
(
std
::
move
(
x0
),
x1
,
std
::
move
(
x2
)),
detail
::
tuple_vals_impl
<
type_erased_tuple
,
Ts
...
>
(
std
::
forward
<
Us
>
(
xs
)...)
{
detail
::
tuple_vals_impl
<
type_erased_tuple
,
Ts
...
>
(
std
::
forward
<
Us
>
(
xs
)...)
{
// nop
// nop
}
}
...
@@ -131,9 +131,9 @@ template <class... Ts>
...
@@ -131,9 +131,9 @@ template <class... Ts>
class
mailbox_element_view
:
public
mailbox_element
,
class
mailbox_element_view
:
public
mailbox_element
,
public
detail
::
type_erased_tuple_view
<
Ts
...
>
{
public
detail
::
type_erased_tuple_view
<
Ts
...
>
{
public:
public:
mailbox_element_view
(
strong_actor_ptr
&&
sender
,
message_id
id
,
mailbox_element_view
(
strong_actor_ptr
&&
x0
,
message_id
x1
,
forwarding_stack
&&
stages
,
Ts
&
...
xs
)
forwarding_stack
&&
x2
,
Ts
&
...
xs
)
:
mailbox_element
(
std
::
move
(
sender
),
id
,
std
::
move
(
stages
)),
:
mailbox_element
(
std
::
move
(
x0
),
x1
,
std
::
move
(
x2
)),
detail
::
type_erased_tuple_view
<
Ts
...
>
(
xs
...)
{
detail
::
type_erased_tuple_view
<
Ts
...
>
(
xs
...)
{
// nop
// nop
}
}
...
...
libcaf_core/src/abstract_actor.cpp
View file @
b98cfd6e
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "caf/actor_control_block.hpp"
#include "caf/actor_control_block.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/enum_to_string.hpp"
#include "caf/detail/shared_spinlock.hpp"
#include "caf/detail/shared_spinlock.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -100,17 +101,19 @@ void abstract_actor::is_registered(bool value) {
...
@@ -100,17 +101,19 @@ void abstract_actor::is_registered(bool value) {
set_flag
(
value
,
is_registered_flag
);
set_flag
(
value
,
is_registered_flag
);
}
}
namespace
{
const
char
*
linking_operation_strings
[]
=
{
"establish_link"
,
"establish_backlink"
,
"remove_link"
,
"remove_backlink"
};
}
// namespace <anonymous>
std
::
string
to_string
(
abstract_actor
::
linking_operation
op
)
{
std
::
string
to_string
(
abstract_actor
::
linking_operation
op
)
{
switch
(
op
)
{
return
detail
::
enum_to_string
(
op
,
linking_operation_strings
);
case
abstract_actor
:
:
establish_link_op
:
return
"establish_link"
;
case
abstract_actor
:
:
establish_backlink_op
:
return
"establish_backlink"
;
case
abstract_actor
:
:
remove_link_op
:
return
"remove_link"
;
default:
return
"remove_backlink"
;
}
}
}
}
// namespace caf
}
// namespace caf
libcaf_core/src/duration.cpp
View file @
b98cfd6e
...
@@ -21,36 +21,37 @@
...
@@ -21,36 +21,37 @@
#include "caf/duration.hpp"
#include "caf/duration.hpp"
#include "caf/detail/enum_to_string.hpp"
namespace
caf
{
namespace
caf
{
std
::
string
to_string
(
const
time_unit
&
x
)
{
namespace
{
switch
(
x
)
{
case
time_unit
:
:
seconds
:
const
char
*
time_unit_strings
[]
=
{
return
"seconds"
;
"invalid"
,
case
time_unit
:
:
milliseconds
:
"seconds"
,
return
"milliseconds"
;
"milliseconds"
,
case
time_unit
:
:
microseconds
:
"microseconds"
return
"microseconds"
;
};
default:
return
"invalid"
;
const
char
*
time_unit_short_strings
[]
=
{
}
"?"
,
"s"
,
"ms"
,
"us"
};
}
// namespace <anonymous>
std
::
string
to_string
(
time_unit
x
)
{
return
detail
::
enum_to_string
(
x
,
time_unit_strings
);
}
}
std
::
string
to_string
(
const
duration
&
x
)
{
std
::
string
to_string
(
const
duration
&
x
)
{
auto
result
=
std
::
to_string
(
x
.
count
);
if
(
x
.
unit
==
time_unit
::
invalid
)
switch
(
x
.
unit
)
{
case
time_unit
:
:
seconds
:
result
+=
"s"
;
break
;
case
time_unit
:
:
milliseconds
:
result
+=
"ms"
;
break
;
case
time_unit
:
:
microseconds
:
result
+=
"us"
;
break
;
default:
return
"infinite"
;
return
"infinite"
;
}
auto
result
=
std
::
to_string
(
x
.
count
);
result
+=
detail
::
enum_to_string
(
x
.
unit
,
time_unit_short_strings
);
return
result
;
return
result
;
}
}
...
...
libcaf_core/src/exit_reason.cpp
View file @
b98cfd6e
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
#include "caf/message.hpp"
#include "caf/message.hpp"
#include "caf/detail/enum_to_string.hpp"
namespace
caf
{
namespace
caf
{
namespace
{
namespace
{
...
@@ -40,10 +42,7 @@ const char* exit_reason_strings[] = {
...
@@ -40,10 +42,7 @@ const char* exit_reason_strings[] = {
std
::
string
to_string
(
exit_reason
x
)
{
std
::
string
to_string
(
exit_reason
x
)
{
auto
index
=
static_cast
<
size_t
>
(
x
);
return
detail
::
enum_to_string
(
x
,
exit_reason_strings
);
if
(
index
>
static_cast
<
size_t
>
(
exit_reason
::
unreachable
))
return
"<unknown>"
;
return
exit_reason_strings
[
index
];
}
}
error
make_error
(
exit_reason
x
)
{
error
make_error
(
exit_reason
x
)
{
...
...
libcaf_core/src/logger.cpp
View file @
b98cfd6e
...
@@ -294,7 +294,7 @@ void logger::run() {
...
@@ -294,7 +294,7 @@ void logger::run() {
}
}
void
logger
::
start
()
{
void
logger
::
start
()
{
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_INFO
#if
defined(CAF_LOG_LEVEL) &&
CAF_LOG_LEVEL >= CAF_LOG_LEVEL_INFO
const
char
*
log_level_table
[]
=
{
"ERROR"
,
"WARN"
,
"INFO"
,
"DEBUG"
,
"TRACE"
};
const
char
*
log_level_table
[]
=
{
"ERROR"
,
"WARN"
,
"INFO"
,
"DEBUG"
,
"TRACE"
};
thread_
=
std
::
thread
{[
this
]
{
this
->
run
();
}};
thread_
=
std
::
thread
{[
this
]
{
this
->
run
();
}};
std
::
string
msg
=
"ENTRY log level = "
;
std
::
string
msg
=
"ENTRY log level = "
;
...
@@ -304,7 +304,7 @@ void logger::start() {
...
@@ -304,7 +304,7 @@ void logger::start() {
}
}
void
logger
::
stop
()
{
void
logger
::
stop
()
{
#if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_INFO
#if
defined(CAF_LOG_LEVEL) &&
CAF_LOG_LEVEL >= CAF_LOG_LEVEL_INFO
log
(
CAF_LOG_LEVEL_INFO
,
"caf"
,
"caf::logger"
,
"run"
,
__FILE__
,
__LINE__
,
"EXIT"
);
log
(
CAF_LOG_LEVEL_INFO
,
"caf"
,
"caf::logger"
,
"run"
,
__FILE__
,
__LINE__
,
"EXIT"
);
// an empty string means: shut down
// an empty string means: shut down
queue_
.
synchronized_enqueue
(
queue_mtx_
,
queue_cv_
,
new
event
{
""
});
queue_
.
synchronized_enqueue
(
queue_mtx_
,
queue_cv_
,
new
event
{
""
});
...
...
libcaf_core/src/sec.cpp
View file @
b98cfd6e
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
#include "caf/sec.hpp"
#include "caf/sec.hpp"
#include "caf/detail/enum_to_string.hpp"
namespace
caf
{
namespace
caf
{
namespace
{
namespace
{
...
@@ -59,10 +61,7 @@ const char* sec_strings[] = {
...
@@ -59,10 +61,7 @@ const char* sec_strings[] = {
}
// namespace <anonymous>
}
// namespace <anonymous>
std
::
string
to_string
(
sec
x
)
{
std
::
string
to_string
(
sec
x
)
{
auto
index
=
static_cast
<
size_t
>
(
x
);
return
detail
::
enum_to_string
(
x
,
sec_strings
);
if
(
index
>
static_cast
<
size_t
>
(
sec
::
bad_function_call
))
return
"<unknown>"
;
return
sec_strings
[
index
];
}
}
error
make_error
(
sec
x
)
{
error
make_error
(
sec
x
)
{
...
...
libcaf_core/test/serialization.cpp
View file @
b98cfd6e
...
@@ -65,6 +65,7 @@
...
@@ -65,6 +65,7 @@
#include "caf/detail/int_list.hpp"
#include "caf/detail/int_list.hpp"
#include "caf/detail/safe_equal.hpp"
#include "caf/detail/safe_equal.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/enum_to_string.hpp"
#include "caf/detail/get_mac_addresses.hpp"
#include "caf/detail/get_mac_addresses.hpp"
using
namespace
std
;
using
namespace
std
;
...
@@ -94,13 +95,10 @@ enum class test_enum : uint32_t {
...
@@ -94,13 +95,10 @@ enum class test_enum : uint32_t {
c
c
};
};
const
char
*
test_enum_strings
[]
=
{
"a"
,
"b"
,
"c"
};
std
::
string
to_string
(
test_enum
x
)
{
std
::
string
to_string
(
test_enum
x
)
{
switch
(
x
)
{
return
detail
::
enum_to_string
(
x
,
test_enum_strings
);
case
test_enum
:
:
a
:
return
"a"
;
case
test_enum
:
:
b
:
return
"b"
;
case
test_enum
:
:
c
:
return
"c"
;
}
return
"???"
;
}
}
struct
test_array
{
struct
test_array
{
...
...
libcaf_io/caf/io/network/asio_multiplexer_impl.hpp
View file @
b98cfd6e
...
@@ -123,10 +123,10 @@ connection_handle asio_multiplexer::add_tcp_scribe(abstract_broker* self,
...
@@ -123,10 +123,10 @@ connection_handle asio_multiplexer::add_tcp_scribe(abstract_broker* self,
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
class
impl
:
public
scribe
{
class
impl
:
public
scribe
{
public:
public:
impl
(
abstract_broker
*
ptr
,
asio_multiplexer
&
ref
,
Socket
&&
s
)
impl
(
abstract_broker
*
ptr
,
asio_multiplexer
&
am
,
Socket
&&
s
)
:
scribe
(
ptr
,
network
::
conn_hdl_from_socket
(
s
)),
:
scribe
(
ptr
,
network
::
conn_hdl_from_socket
(
s
)),
launched_
(
false
),
launched_
(
false
),
stream_
(
ref
)
{
stream_
(
am
)
{
stream_
.
init
(
std
::
move
(
s
));
stream_
.
init
(
std
::
move
(
s
));
}
}
void
configure_read
(
receive_policy
::
config
config
)
override
{
void
configure_read
(
receive_policy
::
config
config
)
override
{
...
@@ -249,9 +249,9 @@ asio_multiplexer::add_tcp_doorman(abstract_broker* self,
...
@@ -249,9 +249,9 @@ asio_multiplexer::add_tcp_doorman(abstract_broker* self,
bool
new_connection
()
override
{
bool
new_connection
()
override
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
auto
&
am
=
acceptor_
.
backend
();
auto
&
am
=
acceptor_
.
backend
();
auto
hdl
=
am
.
add_tcp_scribe
(
parent
(),
auto
x
=
am
.
add_tcp_scribe
(
parent
(),
std
::
move
(
acceptor_
.
accepted_socket
()));
std
::
move
(
acceptor_
.
accepted_socket
()));
return
doorman
::
new_connection
(
&
am
,
hdl
);
return
doorman
::
new_connection
(
&
am
,
x
);
}
}
void
stop_reading
()
override
{
void
stop_reading
()
override
{
CAF_LOG_TRACE
(
""
);
CAF_LOG_TRACE
(
""
);
...
...
libcaf_io/src/message_type.cpp
View file @
b98cfd6e
...
@@ -19,27 +19,27 @@
...
@@ -19,27 +19,27 @@
#include "caf/io/basp/message_type.hpp"
#include "caf/io/basp/message_type.hpp"
#include "caf/detail/enum_to_string.hpp"
namespace
caf
{
namespace
caf
{
namespace
io
{
namespace
io
{
namespace
basp
{
namespace
basp
{
namespace
{
const
char
*
message_type_strings
[]
=
{
"server_handshake"
,
"client_handshake"
,
"dispatch_message"
,
"announce_proxy_instance"
,
"kill_proxy_instance"
,
"heartbeat"
};
}
// namespace <anonymous>
std
::
string
to_string
(
message_type
x
)
{
std
::
string
to_string
(
message_type
x
)
{
switch
(
x
)
{
return
detail
::
enum_to_string
(
x
,
message_type_strings
);
case
message_type
:
:
server_handshake
:
return
"server_handshake"
;
case
message_type
:
:
client_handshake
:
return
"client_handshake"
;
case
message_type
:
:
dispatch_message
:
return
"dispatch_message"
;
case
message_type
:
:
announce_proxy
:
return
"announce_proxy_instance"
;
case
message_type
:
:
kill_proxy
:
return
"kill_proxy_instance"
;
case
message_type
:
:
heartbeat
:
return
"heartbeat"
;
default:
return
"???"
;
}
}
}
}
// namespace basp
}
// namespace basp
...
...
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