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
b88d7229
Commit
b88d7229
authored
Apr 02, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added is_comparable to makefile
parent
c7593f4f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
46 deletions
+78
-46
Makefile.am
Makefile.am
+1
-0
cppa.files
cppa.files
+1
-0
unit_testing/main.cpp
unit_testing/main.cpp
+76
-46
No files found.
Makefile.am
View file @
b88d7229
...
...
@@ -193,6 +193,7 @@ nobase_library_include_HEADERS = \
cppa/util/if_else.hpp
\
cppa/util/is_array_of.hpp
\
cppa/util/is_builtin.hpp
\
cppa/util/is_comparable.hpp
\
cppa/util/is_forward_iterator.hpp
\
cppa/util/is_iterable.hpp
\
cppa/util/is_legal_tuple_type.hpp
\
...
...
cppa.files
View file @
b88d7229
...
...
@@ -255,3 +255,4 @@ cppa/intrusive/singly_linked_list.hpp
cppa/intrusive/forward_iterator.hpp
unit_testing/test__intrusive_containers.cpp
examples/dancing_kirby.cpp
cppa/util/is_comparable.hpp
unit_testing/main.cpp
View file @
b88d7229
...
...
@@ -14,6 +14,7 @@
#include "test.hpp"
#include "cppa/cppa.hpp"
#include "cppa/tuple.hpp"
#include "cppa/config.hpp"
#include "cppa/anything.hpp"
...
...
@@ -61,6 +62,8 @@ using std::cout;
using
std
::
cerr
;
using
std
::
endl
;
using
namespace
cppa
;
void
print_node_id
()
{
auto
pinfo
=
cppa
::
process_information
::
get
();
...
...
@@ -74,10 +77,13 @@ void print_node_id()
<<
endl
;
}
char
*
find_char_or_end
(
char
*
cstr
,
const
char
what
)
std
::
vector
<
std
::
string
>
split
(
std
::
string
const
&
str
,
char
delim
)
{
for
(
char
c
=
*
cstr
;
(
c
!=
'\0'
&&
c
!=
what
);
c
=
*
(
++
cstr
))
{
}
return
cstr
;
std
::
vector
<
std
::
string
>
result
;
std
::
stringstream
strs
{
str
};
std
::
string
tmp
;
while
(
std
::
getline
(
strs
,
tmp
,
delim
))
result
.
push_back
(
tmp
);
return
result
;
}
std
::
map
<
std
::
string
,
std
::
string
>
...
...
@@ -86,26 +92,18 @@ get_kv_pairs(int argc, char** argv, int begin = 1)
std
::
map
<
std
::
string
,
std
::
string
>
result
;
for
(
int
i
=
begin
;
i
<
argc
;
++
i
)
{
char
*
pos
=
find_char_or_end
(
argv
[
i
],
'='
);
if
(
*
pos
==
'='
)
{
char
*
pos2
=
find_char_or_end
(
pos
+
1
,
'='
);
if
(
*
pos2
==
'\0'
)
{
std
::
pair
<
std
::
string
,
std
::
string
>
kvp
;
kvp
.
first
=
std
::
string
(
argv
[
i
],
pos
);
kvp
.
second
=
std
::
string
(
pos
+
1
,
pos2
);
if
(
result
.
insert
(
std
::
move
(
kvp
)).
second
==
false
)
auto
vec
=
split
(
argv
[
i
],
'='
);
if
(
vec
.
size
()
!=
2
)
{
std
::
string
err
=
"key
\"
"
;
err
+=
std
::
string
(
argv
[
i
],
pos
);
err
+=
"
\"
already defined"
;
throw
std
::
runtime_error
(
err
);
}
cerr
<<
"
\"
"
<<
argv
[
i
]
<<
"
\"
is not a key-value pair"
<<
endl
;
}
else
if
(
result
.
insert
(
std
::
make_pair
(
vec
[
0
],
vec
[
1
])).
second
==
false
)
{
cerr
<<
"key
\"
"
<<
vec
[
0
]
<<
"
\"
is already defined"
<<
endl
;
exit
(
1
);
}
}
return
std
::
move
(
result
)
;
return
result
;
}
template
<
typename
Iterator
,
class
Container
,
typename
Key
>
...
...
@@ -114,40 +112,72 @@ inline bool found_key(Iterator& i, Container& cont, Key&& key)
return
(
i
=
cont
.
find
(
std
::
forward
<
Key
>
(
key
)))
!=
cont
.
end
();
}
struct
match_helper
{
any_tuple
tup
;
template
<
class
...
Args
>
void
operator
()(
partial_function
&&
pf
,
Args
&&
...
args
)
{
partial_function
tmp
;
tmp
.
splice
(
std
::
move
(
pf
),
std
::
forward
<
Args
>
(
args
)...);
tmp
(
tup
);
}
};
template
<
typename
F
,
typename
S
>
match_helper
match
(
std
::
pair
<
F
,
S
>
const
&
what
)
{
return
{
make_tuple
(
what
.
first
,
what
.
second
)};
}
void
usage
(
char
const
*
argv0
)
{
cout
<<
"usage: "
<<
split
(
argv0
,
'/'
).
back
()
<<
" "
<<
"[run=remote_actor] "
<<
"[scheduler=(thread_pool_scheduler|mock_scheduler)]"
<<
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
auto
args
=
get_kv_pairs
(
argc
,
argv
);
if
(
!
args
.
empty
()
)
for
(
auto
&
kvp
:
args
)
{
decltype
(
args
.
find
(
""
))
i
;
if
(
found_key
(
i
,
args
,
"run"
))
match
(
kvp
)
(
on
(
"run"
,
arg_match
)
>>
[
&
](
std
::
string
const
&
what
)
{
auto
&
what
=
i
->
second
;
if
(
what
==
"remote_actor"
)
{
test__remote_actor
(
argv
[
0
],
true
,
args
);
return
0
;
exit
(
0
)
;
}
}
else
if
(
found_key
(
i
,
args
,
"scheduler"
)
)
},
on
(
"scheduler"
,
arg_match
)
>>
[](
std
::
string
const
&
sched
)
{
auto
&
sched
=
i
->
second
;
if
(
sched
==
"thread_pool_scheduler"
)
{
cout
<<
"using thread_pool_scheduler"
<<
endl
;
cppa
::
set_scheduler
(
new
cppa
::
detail
::
thread_pool_scheduler
);
set_scheduler
(
new
cppa
::
detail
::
thread_pool_scheduler
);
}
else
if
(
sched
==
"mock_scheduler"
)
{
cout
<<
"using mock_scheduler"
<<
endl
;
cppa
::
set_scheduler
(
new
cppa
::
detail
::
mock_scheduler
);
set_scheduler
(
new
cppa
::
detail
::
mock_scheduler
);
}
else
{
cerr
<<
"unknown scheduler: "
<<
sched
<<
endl
;
return
1
;
exit
(
1
)
;
}
},
on_arg_match
>>
[
&
](
std
::
string
const
&
key
,
std
::
string
const
&
)
{
cerr
<<
"unknown key:
\"
"
<<
key
<<
"
\"
"
<<
endl
;
usage
(
argv
[
0
]);
exit
(
2
);
}
);
}
//print_node_id();
std
::
cout
<<
std
::
boolalpha
;
...
...
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