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
dd8f1f1a
Commit
dd8f1f1a
authored
Nov 26, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new `deep_to_string` in actor ostream
parent
8a072b53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
33 deletions
+17
-33
libcaf_core/caf/actor_ostream.hpp
libcaf_core/caf/actor_ostream.hpp
+8
-21
libcaf_core/src/actor_ostream.cpp
libcaf_core/src/actor_ostream.cpp
+9
-12
No files found.
libcaf_core/caf/actor_ostream.hpp
View file @
dd8f1f1a
...
@@ -21,13 +21,10 @@
...
@@ -21,13 +21,10 @@
#define CAF_ACTOR_OSTREAM_HPP
#define CAF_ACTOR_OSTREAM_HPP
#include "caf/actor.hpp"
#include "caf/actor.hpp"
#include "caf/
message
.hpp"
#include "caf/
deep_to_string
.hpp"
namespace
caf
{
namespace
caf
{
class
local_actor
;
class
scoped_actor
;
/// Provides support for thread-safe output operations on character streams. The
/// Provides support for thread-safe output operations on character streams. The
/// stream operates on a per-actor basis and will print only complete lines or
/// stream operates on a per-actor basis and will print only complete lines or
/// when explicitly forced to flush its buffer. The stream will convert *any*
/// when explicitly forced to flush its buffer. The stream will convert *any*
...
@@ -45,7 +42,7 @@ public:
...
@@ -45,7 +42,7 @@ public:
/// Open redirection file in append mode.
/// Open redirection file in append mode.
static
constexpr
int
append
=
0x01
;
static
constexpr
int
append
=
0x01
;
explicit
actor_ostream
(
local
_actor
*
self
);
explicit
actor_ostream
(
abstract
_actor
*
self
);
/// Writes `arg` to the buffer allocated for the calling actor.
/// Writes `arg` to the buffer allocated for the calling actor.
actor_ostream
&
write
(
std
::
string
arg
);
actor_ostream
&
write
(
std
::
string
arg
);
...
@@ -54,31 +51,23 @@ public:
...
@@ -54,31 +51,23 @@ public:
actor_ostream
&
flush
();
actor_ostream
&
flush
();
/// Redirects all further output from `self` to `file_name`.
/// Redirects all further output from `self` to `file_name`.
static
void
redirect
(
local
_actor
*
self
,
std
::
string
file_name
,
int
flags
=
0
);
static
void
redirect
(
abstract
_actor
*
self
,
std
::
string
file_name
,
int
flags
=
0
);
/// Redirects all further output from any actor that did not
/// Redirects all further output from any actor that did not
/// redirect its output to `fname`.
/// redirect its output to `fname`.
static
void
redirect_all
(
actor_system
&
sys
,
std
::
string
fname
,
int
flags
=
0
);
static
void
redirect_all
(
actor_system
&
sys
,
std
::
string
fname
,
int
flags
=
0
);
/// Writes `arg` to the buffer allocated for the calling actor.
inline
actor_ostream
&
operator
<<
(
std
::
string
arg
)
{
return
write
(
std
::
move
(
arg
));
}
/// Writes `arg` to the buffer allocated for the calling actor.
/// Writes `arg` to the buffer allocated for the calling actor.
inline
actor_ostream
&
operator
<<
(
const
char
*
arg
)
{
inline
actor_ostream
&
operator
<<
(
const
char
*
arg
)
{
return
*
this
<<
std
::
string
{
arg
}
;
return
write
(
arg
)
;
}
}
/// Writes `to_string(arg)` to the buffer allocated for the calling actor,
/// Writes `to_string(arg)` to the buffer allocated for the calling actor,
/// calling either `std::to_string` or `caf::to_string` depending on
/// calling either `std::to_string` or `caf::to_string` depending on
/// the argument.
/// the argument.
template
<
class
T
>
template
<
class
T
>
inline
typename
std
::
enable_if
<
inline
actor_ostream
&
operator
<<
(
const
T
&
arg
)
{
!
std
::
is_convertible
<
T
,
std
::
string
>::
value
,
actor_ostream
&
return
write
(
deep_to_string
(
arg
));
>::
type
operator
<<
(
const
T
&
arg
)
{
using
std
::
to_string
;
return
write
(
to_string
(
arg
));
}
}
/// Apply `f` to `*this`.
/// Apply `f` to `*this`.
...
@@ -86,15 +75,13 @@ public:
...
@@ -86,15 +75,13 @@ public:
return
f
(
*
this
);
return
f
(
*
this
);
}
}
actor_ostream
&
operator
<<
(
const
message
&
msg
);
private:
private:
local_actor
*
self_
;
intrusive_ptr
<
abstract_actor
>
self_
;
actor
printer_
;
actor
printer_
;
};
};
/// Convenience factory function for creating an actor output stream.
/// Convenience factory function for creating an actor output stream.
actor_ostream
aout
(
local
_actor
*
self
);
actor_ostream
aout
(
abstract
_actor
*
self
);
/// Convenience factory function for creating an actor output stream.
/// Convenience factory function for creating an actor output stream.
actor_ostream
aout
(
scoped_actor
&
self
);
actor_ostream
aout
(
scoped_actor
&
self
);
...
...
libcaf_core/src/actor_ostream.cpp
View file @
dd8f1f1a
...
@@ -19,34 +19,35 @@
...
@@ -19,34 +19,35 @@
#include "caf/actor_ostream.hpp"
#include "caf/actor_ostream.hpp"
#include "caf/all.hpp"
#include "caf/send.hpp"
#include "caf/local_actor.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/abstract_actor.hpp"
#include "caf/scheduler/abstract_coordinator.hpp"
#include "caf/scheduler/abstract_coordinator.hpp"
namespace
caf
{
namespace
caf
{
actor_ostream
::
actor_ostream
(
local
_actor
*
self
)
actor_ostream
::
actor_ostream
(
abstract
_actor
*
self
)
:
self_
(
self
),
:
self_
(
self
),
printer_
(
self
->
system
().
scheduler
().
printer
())
{
printer_
(
self
->
system
().
scheduler
().
printer
())
{
// nop
// nop
}
}
actor_ostream
&
actor_ostream
::
write
(
std
::
string
arg
)
{
actor_ostream
&
actor_ostream
::
write
(
std
::
string
arg
)
{
send_as
(
self_
,
printer_
,
add_atom
::
value
,
std
::
move
(
arg
));
send_as
(
actor_cast
<
actor
>
(
self_
)
,
printer_
,
add_atom
::
value
,
std
::
move
(
arg
));
return
*
this
;
return
*
this
;
}
}
actor_ostream
&
actor_ostream
::
flush
()
{
actor_ostream
&
actor_ostream
::
flush
()
{
send_as
(
self_
,
printer_
,
flush_atom
::
value
);
send_as
(
actor_cast
<
actor
>
(
self_
)
,
printer_
,
flush_atom
::
value
);
return
*
this
;
return
*
this
;
}
}
void
actor_ostream
::
redirect
(
local
_actor
*
self
,
std
::
string
fn
,
int
flags
)
{
void
actor_ostream
::
redirect
(
abstract
_actor
*
self
,
std
::
string
fn
,
int
flags
)
{
if
(
!
self
)
if
(
!
self
)
return
;
return
;
send_as
(
self
,
self
->
system
().
scheduler
().
printer
(),
intrusive_ptr
<
abstract_actor
>
ptr
{
self
};
send_as
(
actor_cast
<
actor
>
(
ptr
),
self
->
system
().
scheduler
().
printer
(),
redirect_atom
::
value
,
self
->
address
(),
std
::
move
(
fn
),
flags
);
redirect_atom
::
value
,
self
->
address
(),
std
::
move
(
fn
),
flags
);
}
}
...
@@ -55,11 +56,7 @@ void actor_ostream::redirect_all(actor_system& sys, std::string fn, int flags) {
...
@@ -55,11 +56,7 @@ void actor_ostream::redirect_all(actor_system& sys, std::string fn, int flags) {
redirect_atom
::
value
,
std
::
move
(
fn
),
flags
);
redirect_atom
::
value
,
std
::
move
(
fn
),
flags
);
}
}
actor_ostream
&
actor_ostream
::
operator
<<
(
const
message
&
)
{
actor_ostream
aout
(
abstract_actor
*
self
)
{
return
*
this
<<
"-message-to-string-not-implemented-yet-"
;
}
actor_ostream
aout
(
local_actor
*
self
)
{
return
actor_ostream
{
self
};
return
actor_ostream
{
self
};
}
}
...
...
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