Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cameo
cameo
Commits
5b70c133
Commit
5b70c133
authored
Apr 26, 2019
by
legoc
Browse files
Replaced auto_ptr by unique_ptr
parent
9ed60caa
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
5b70c133
0.2.0
-----
* Migration to C++11
0.1.4
-----
...
...
configure.ac
View file @
5b70c133
...
...
@@ -4,8 +4,8 @@
#
# -----------------------------------------------------------------------------
AC_INIT(cameo-api-cpp, 0.
1.4
)
LIBRARY_VERSION=0:
1:4
AC_INIT(cameo-api-cpp, 0.
2.0
)
LIBRARY_VERSION=0:
2:0
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR(src/cameo/Application.cpp)
...
...
@@ -23,8 +23,8 @@ AC_CONFIG_MACRO_DIR([m4])
AC_SUBST(LIBRARY_VERSION)
# temporarily disabled
#AX_CXX_COMPILE_STDCXX_11
AX_CXX_COMPILE_STDCXX_11
AX_PTHREAD(,[AC_MSG_ERROR([Posix threads required])])
AX_BOOST_BASE([1.41],, [AC_MSG_ERROR([Boost 1.41 required])])
AX_BOOST_DATE_TIME
...
...
m4/AC_CXX_CLEAN_TEMPLATE_REPOSITORY.m4
0 → 100644
View file @
5b70c133
dnl
dnl AC_CXX_CLEAN_TEMPLATE_REPOSITORY
dnl
dnl Description
dnl
dnl Sometime failed C++ compiles can leave trash in the template repository.
dnl Just clean them all away.
dnl
dnl Copyright (C) 2003, Alex Tingle <alex.autoconf@firetree.net>
dnl
dnl License:
dnl GNU General Public License
dnl [http://www.gnu.org/software/ac-archive/htmldoc/COPYING.html]
dnl with this special exception
dnl [http://www.gnu.org/software/ac-archive/htmldoc/COPYING-Exception.html].
dnl
AC_DEFUN([AC_CXX_CLEAN_TEMPLATE_REPOSITORY],[
# Sometime failed C++ compiles can leave trash in the template repository.
# Just clean them all away.
rm -rf ./SunWS_cache # Solaris/CC
rm -rf ./.cxx_repository # Tru64/cxx
# ...add more here.
])
m4/ax_cxx_compile_stdcxx.m4
0 → 100644
View file @
5b70c133
This diff is collapsed.
Click to expand it.
m4/ax_cxx_compile_stdcxx_11.m4
View file @
5b70c133
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# ============================================================================
# ============================================================================
=
# http
s
://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# ============================================================================
=
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
# AX_CXX_COMPILE_STDCXX_11([ext|noext],
[mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXXFLAGS to enable support.
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# The first argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The second argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline C++11 support is required and that the macro
# should error out if no mode with that support is found. If specified
# 'optional', then configuration proceeds regardless, after defining
# HAVE_CXX11 if and only if a supporting mode is found.
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++11. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
...
...
@@ -28,140 +25,15 @@
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 11
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
struct Base {
virtual void f() {}
};
struct Child : public Base {
virtual void f() override {}
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);
auto d = a;
auto l = [](){};
// Prevent Clang error: unused variable 'l' [-Werror,-Wunused-variable]
struct use_l { use_l() { l(); } };
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function because of this
namespace test_template_alias_sfinae {
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() {
func<foo>(0);
}
}
]])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
m4_if([$1], [], [],
[$1], [ext], [],
[$1], [noext], [],
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
[$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
[$2], [optional], [ax_cxx_compile_cxx11_required=false],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
ax_cv_cxx_compile_cxx11,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[ax_cv_cxx_compile_cxx11=yes],
[ax_cv_cxx_compile_cxx11=no])])
if test x$ax_cv_cxx_compile_cxx11 = xyes; then
ac_success=yes
fi
m4_if([$1], [noext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=gnu++11 -std=gnu++0x; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
m4_if([$1], [ext], [], [dnl
if test x$ac_success = xno; then
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
for switch in -std=c++11 -std=c++0x +std=c++11; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx11_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
fi
else
if test x$ac_success = xno; then
HAVE_CXX11=0
AC_MSG_NOTICE([No compiler with C++11 support was found])
else
HAVE_CXX11=1
AC_DEFINE(HAVE_CXX11,1,
[define if the compiler supports basic C++11 syntax])
fi
#serial 18
AC_SUBST(HAVE_CXX11)
fi
])
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])
src/cameo/Application.cpp
View file @
5b70c133
...
...
@@ -111,7 +111,7 @@ void This::terminate() {
This
::
This
()
:
Services
(),
m_impl
(
0
),
m_impl
(
nullptr
),
m_id
(
-
1
),
m_managed
(
false
),
m_starterId
(
0
)
{
...
...
@@ -185,14 +185,14 @@ void This::initApplication(int argc, char *argv[]) {
initStatus
();
// Create the local server
m_server
=
auto
_ptr
<
Server
>
(
new
Server
(
m_serverEndpoint
));
m_server
=
unique
_ptr
<
Server
>
(
new
Server
(
m_serverEndpoint
));
// Create the starter server
if
(
m_starterEndpoint
!=
""
)
{
m_starterServer
=
auto
_ptr
<
Server
>
(
new
Server
(
m_starterEndpoint
));
m_starterServer
=
unique
_ptr
<
Server
>
(
new
Server
(
m_starterEndpoint
));
}
m_waitingSet
=
auto
_ptr
<
WaitingImplSet
>
(
new
WaitingImplSet
());
m_waitingSet
=
unique
_ptr
<
WaitingImplSet
>
(
new
WaitingImplSet
());
}
This
::~
This
()
{
...
...
@@ -261,7 +261,7 @@ int This::initUnmanagedApplication() {
string
strRequestType
=
m_impl
->
createRequest
(
PROTO_STARTEDUNMANAGED
);
string
strRequestData
=
m_impl
->
createStartedUnmanagedRequest
(
m_name
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -273,7 +273,7 @@ void This::terminateUnmanagedApplication() {
string
strRequestType
=
m_impl
->
createRequest
(
PROTO_TERMINATEDUNMANAGED
);
string
strRequestData
=
m_impl
->
createTerminatedUnmanagedRequest
(
m_id
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -283,7 +283,7 @@ bool This::setRunning() {
string
strRequestType
=
m_instance
.
m_impl
->
createRequest
(
PROTO_SETSTATUS
);
string
strRequestData
=
m_instance
.
m_impl
->
createSetStatusRequest
(
m_instance
.
m_id
,
RUNNING
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_instance
.
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_instance
.
m_serverEndpoint
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -300,7 +300,7 @@ void This::setBinaryResult(const std::string& data) {
string
strRequestType
=
m_instance
.
m_impl
->
createRequest
(
PROTO_SETRESULT
);
string
strRequestData
=
m_instance
.
m_impl
->
createSetResultRequest
(
m_instance
.
m_id
,
data
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_instance
.
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_instance
.
m_serverEndpoint
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -349,7 +349,7 @@ State This::getState(int id) const {
string
strRequestType
=
m_impl
->
createRequest
(
PROTO_GETSTATUS
);
string
strRequestData
=
m_impl
->
createGetStatusRequest
(
id
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
proto
::
StatusEvent
protoStatus
;
protoStatus
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -361,7 +361,7 @@ bool This::destroyPublisher(const std::string& name) const {
string
strRequestType
=
m_impl
->
createRequest
(
PROTO_TERMINATEPUBLISHER
);
string
strRequestData
=
m_impl
->
createTerminatePublisherRequest
(
m_id
,
name
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -374,7 +374,7 @@ bool This::removePort(const std::string& name) const {
string
strRequestType
=
m_impl
->
createRequest
(
PROTO_REMOVEPORT
);
string
strRequestData
=
m_impl
->
createRemovePortRequest
(
m_id
,
name
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -386,7 +386,7 @@ bool This::removePort(const std::string& name) const {
State
This
::
waitForStop
()
{
// open the event stream
auto
_ptr
<
EventStreamSocket
>
socket
=
openEventStream
();
unique
_ptr
<
EventStreamSocket
>
socket
=
openEventStream
();
m_impl
->
setEventSocket
(
socket
);
// test if stop was requested elsewhere
...
...
@@ -398,7 +398,7 @@ State This::waitForStop() {
while
(
true
)
{
// waits for a new incoming status
auto
_ptr
<
Event
>
event
=
m_impl
->
m_eventSocket
->
receive
();
unique
_ptr
<
Event
>
event
=
m_impl
->
m_eventSocket
->
receive
();
// The socket is canceled.
if
(
event
.
get
()
==
0
)
{
...
...
@@ -422,10 +422,10 @@ State This::waitForStop() {
return
UNKNOWN
;
}
std
::
auto
_ptr
<
Instance
>
This
::
connectToStarter
()
{
std
::
unique
_ptr
<
Instance
>
This
::
connectToStarter
()
{
if
(
m_instance
.
m_starterServer
.
get
()
==
0
)
{
return
auto
_ptr
<
Instance
>
(
0
);
if
(
m_instance
.
m_starterServer
.
get
()
==
nullptr
)
{
return
unique
_ptr
<
Instance
>
(
nullptr
);
}
// Iterate the instances to find the id
...
...
@@ -433,11 +433,11 @@ std::auto_ptr<Instance> This::connectToStarter() {
for
(
int
i
=
0
;
i
<
instances
.
size
();
i
++
)
{
if
(
instances
[
i
]
->
getId
()
==
m_instance
.
m_starterId
)
{
return
auto
_ptr
<
Instance
>
(
instances
[
i
]);
return
unique
_ptr
<
Instance
>
(
std
::
move
(
instances
[
i
])
)
;
}
}
return
auto
_ptr
<
Instance
>
(
0
);
return
unique
_ptr
<
Instance
>
(
nullptr
);
}
void
This
::
handleStopImpl
(
StopFunctionType
function
)
{
...
...
@@ -447,9 +447,9 @@ void This::handleStopImpl(StopFunctionType function) {
///////////////////////////////////////////////////////////////////////////////
// Instance
Instance
::
Instance
(
const
Server
*
server
,
std
::
auto
_ptr
<
EventStreamSocket
>&
socket
)
:
Instance
::
Instance
(
const
Server
*
server
,
std
::
unique
_ptr
<
EventStreamSocket
>&
socket
)
:
m_server
(
server
),
m_eventSocket
(
socket
),
m_eventSocket
(
std
::
move
(
socket
)
)
,
m_id
(
-
1
),
m_pastStates
(
0
),
m_initialState
(
UNKNOWN
),
...
...
@@ -570,7 +570,7 @@ State Instance::waitFor(int states, const std::string& eventName, StateHandlerTy
while
(
true
)
{
// Waits for a new incoming status
auto
_ptr
<
Event
>
event
=
m_eventSocket
->
receive
(
blocking
);
unique
_ptr
<
Event
>
event
=
m_eventSocket
->
receive
(
blocking
);
// The socket is canceled or the non-blocking call returns a null message.
if
(
event
.
get
()
==
0
)
{
...
...
@@ -710,11 +710,11 @@ InstanceArray::InstanceArray() :
InstanceArray
::
InstanceArray
(
const
InstanceArray
&
array
)
:
m_size
(
array
.
m_size
),
m_array
(
new
auto
_ptr
<
Instance
>
[
m_size
])
{
m_array
(
new
unique
_ptr
<
Instance
>
[
m_size
])
{
// transferring pointers
for
(
size_t
i
=
0
;
i
<
m_size
;
i
++
)
{
m_array
[
i
]
=
array
.
m_array
[
i
];
m_array
[
i
]
=
std
::
move
(
array
.
m_array
[
i
]
)
;
}
}
...
...
@@ -724,14 +724,14 @@ InstanceArray::~InstanceArray() {
void
InstanceArray
::
allocate
(
std
::
size_t
size
)
{
m_size
=
size
;
m_array
=
new
auto
_ptr
<
Instance
>
[
size
];
m_array
=
new
unique
_ptr
<
Instance
>
[
size
];
}
std
::
size_t
InstanceArray
::
size
()
const
{
return
m_size
;
}
std
::
auto
_ptr
<
Instance
>&
InstanceArray
::
operator
[](
std
::
size_t
index
)
{
std
::
unique
_ptr
<
Instance
>&
InstanceArray
::
operator
[](
std
::
size_t
index
)
{
return
m_array
[
index
];
}
...
...
@@ -748,12 +748,12 @@ Publisher::Publisher(const This * application, int publisherPort, int synchroniz
Publisher
::~
Publisher
()
{
}
std
::
auto
_ptr
<
Publisher
>
Publisher
::
create
(
const
std
::
string
&
name
,
int
numberOfSubscribers
)
{
std
::
unique
_ptr
<
Publisher
>
Publisher
::
create
(
const
std
::
string
&
name
,
int
numberOfSubscribers
)
{
string
strRequestType
=
This
::
m_instance
.
m_impl
->
createRequest
(
PROTO_CREATEPUBLISHER
);
string
strRequestData
=
This
::
m_instance
.
m_impl
->
createCreatePublisherRequest
(
This
::
m_instance
.
m_id
,
name
,
numberOfSubscribers
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
This
::
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
This
::
m_instance
.
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
This
::
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
This
::
m_instance
.
m_serverEndpoint
);
proto
::
PublisherResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -763,7 +763,7 @@ std::auto_ptr<Publisher> Publisher::create(const std::string& name, int numberOf
}
int
synchronizerPort
=
requestResponse
.
synchronizerport
();
return
auto
_ptr
<
Publisher
>
(
new
Publisher
(
&
This
::
m_instance
,
publisherPort
,
synchronizerPort
,
name
,
numberOfSubscribers
));
return
unique
_ptr
<
Publisher
>
(
new
Publisher
(
&
This
::
m_instance
,
publisherPort
,
synchronizerPort
,
name
,
numberOfSubscribers
));
}
...
...
@@ -837,7 +837,7 @@ Subscriber::Subscriber(const Server * server, const std::string & url, int publi
Subscriber
::~
Subscriber
()
{
}
std
::
auto
_ptr
<
Subscriber
>
Subscriber
::
create
(
Instance
&
instance
,
const
std
::
string
&
publisherName
)
{
std
::
unique
_ptr
<
Subscriber
>
Subscriber
::
create
(
Instance
&
instance
,
const
std
::
string
&
publisherName
)
{
try
{
return
instance
.
m_server
->
createSubscriber
(
instance
.
m_id
,
publisherName
,
instance
.
m_name
);
...
...
@@ -853,7 +853,7 @@ std::auto_ptr<Subscriber> Subscriber::create(Instance & instance, const std::str
||
lastState
==
STOPPED
||
lastState
==
KILLED
||
lastState
==
FAILURE
)
{
return
auto
_ptr
<
Subscriber
>
(
0
);
return
unique
_ptr
<
Subscriber
>
(
nullptr
);
}
try
{
...
...
@@ -863,7 +863,7 @@ std::auto_ptr<Subscriber> Subscriber::create(Instance & instance, const std::str
// that should not happen
}
return
auto
_ptr
<
Subscriber
>
(
0
);
return
unique
_ptr
<
Subscriber
>
(
nullptr
);
}
void
Subscriber
::
init
()
{
...
...
@@ -928,8 +928,8 @@ void Subscriber::cancel() {
///////////////////////////////////////////////////////////////////////////
// Request
Request
::
Request
(
std
::
auto
_ptr
<
RequestImpl
>
&
impl
)
:
m_impl
(
impl
)
{
Request
::
Request
(
std
::
unique
_ptr
<
RequestImpl
>
&
impl
)
:
m_impl
(
std
::
move
(
impl
)
)
{
}
Request
::~
Request
()
{
...
...
@@ -959,7 +959,7 @@ void Request::reply(const std::string& response) {
m_impl
->
reply
(
response
);
}
std
::
auto
_ptr
<
Instance
>
Request
::
connectToRequester
()
{
std
::
unique
_ptr
<
Instance
>
Request
::
connectToRequester
()
{
// Instantiate the requester server if it does not exist.
if
(
m_requesterServer
.
get
()
==
0
)
{
...
...
@@ -971,16 +971,16 @@ std::auto_ptr<Instance> Request::connectToRequester() {
for
(
int
i
=
0
;
i
<
instances
.
size
();
i
++
)
{
if
(
instances
[
i
]
->
getId
()
==
m_impl
->
m_requesterApplicationId
)
{
return
auto
_ptr
<
Instance
>
(
instances
[
i
]);
return
unique
_ptr
<
Instance
>
(
std
::
move
(
instances
[
i
])
)
;
}
}
// Not found.
return
auto
_ptr
<
Instance
>
(
0
);
return
unique
_ptr
<
Instance
>
(
nullptr
);
}
std
::
auto
_ptr
<
Server
>
Request
::
getServer
()
{
return
m_requesterServer
;
std
::
unique
_ptr
<
Server
>
Request
::
getServer
()
{
return
std
::
move
(
m_requesterServer
)
;
}
///////////////////////////////////////////////////////////////////////////
...
...
@@ -996,14 +996,14 @@ Responder::Responder(const application::This * application, int responderPort, c
Responder
::~
Responder
()
{
}
std
::
auto
_ptr
<
Responder
>
Responder
::
create
(
const
std
::
string
&
name
)
{
std
::
unique
_ptr
<
Responder
>
Responder
::
create
(
const
std
::
string
&
name
)
{
string
portName
=
ResponderImpl
::
RESPONDER_PREFIX
+
name
;
string
strRequestType
=
This
::
m_instance
.
m_impl
->
createRequest
(
PROTO_REQUESTPORT
);
string
strRequestData
=
This
::
m_instance
.
m_impl
->
createRequestPortRequest
(
This
::
m_instance
.
m_id
,
portName
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
This
::
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
This
::
m_instance
.
m_serverEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
This
::
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
This
::
m_instance
.
m_serverEndpoint
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -1012,7 +1012,7 @@ std::auto_ptr<Responder> Responder::create(const std::string& name) {
throw
ResponderCreationException
(
requestResponse
.
message
());
}
return
auto
_ptr
<
Responder
>
(
new
Responder
(
&
This
::
m_instance
,
responderPort
,
name
));
return
unique
_ptr
<
Responder
>
(
new
Responder
(
&
This
::
m_instance
,
responderPort
,
name
));
}
const
std
::
string
&
Responder
::
getName
()
const
{
...
...
@@ -1023,13 +1023,13 @@ void Responder::cancel() {
m_impl
->
cancel
();
}
std
::
auto
_ptr
<
Request
>
Responder
::
receive
()
{
std
::
unique
_ptr
<
Request
>
Responder
::
receive
()
{
auto
_ptr
<
RequestImpl
>
requestImpl
=
m_impl
->
receive
();
if
(
requestImpl
.
get
()
==
0
)
{
return
auto
_ptr
<
Request
>
(
0
);
unique
_ptr
<
RequestImpl
>
requestImpl
=
m_impl
->
receive
();
if
(
requestImpl
.
get
()
==
nullptr
)
{
return
unique
_ptr
<
Request
>
(
nullptr
);
}
return
auto
_ptr
<
Request
>
(
new
Request
(
requestImpl
));
return
unique
_ptr
<
Request
>
(
new
Request
(
requestImpl
));
}
bool
Responder
::
hasEnded
()
const
{
...
...
@@ -1049,7 +1049,7 @@ Requester::Requester(const application::This * application, const std::string& u
Requester
::~
Requester
()
{
}
std
::
auto
_ptr
<
Requester
>
Requester
::
create
(
Instance
&
instance
,
const
std
::
string
&
name
)
{
std
::
unique
_ptr
<
Requester
>
Requester
::
create
(
Instance
&
instance
,
const
std
::
string
&
name
)
{
int
responderId
=
instance
.
getId
();
string
responderUrl
=
instance
.
getUrl
();
...
...
@@ -1062,7 +1062,7 @@ std::auto_ptr<Requester> Requester::create(Instance & instance, const std::strin
string
strRequestType
=
This
::
m_instance
.
m_impl
->
createRequest
(
PROTO_CONNECTPORT
);
string
strRequestData
=
This
::
m_instance
.
m_impl
->
createConnectPortRequest
(
responderId
,
responderPortName
);
auto
_ptr
<
zmq
::
message_t
>
reply
=
This
::
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
responderEndpoint
);
unique
_ptr
<
zmq
::
message_t
>
reply
=
This
::
m_instance
.
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
responderEndpoint
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
reply
.
reset
();
...
...
@@ -1096,7 +1096,7 @@ std::auto_ptr<Requester> Requester::create(Instance & instance, const std::strin
throw
RequesterCreationException
(
requestResponse
.
message
());
}
return
auto
_ptr
<
Requester
>
(
new
Requester
(
&
This
::
m_instance
,
responderUrl
,
requesterPort
,
responderPort
,
name
,
responderId
,
requesterId
));
return
unique
_ptr
<
Requester
>
(
new
Requester
(
&
This
::
m_instance
,
responderUrl
,
requesterPort
,
responderPort
,
name
,
responderId
,
requesterId
));
}
const
std
::
string
&
Requester
::
getName
()
const
{
...
...
src/cameo/Application.h
View file @
5b70c133
...
...
@@ -145,7 +145,7 @@ public:
/**
* Connects to the starter application, i.e. the application which started this application.
*/
static
std
::
auto
_ptr
<
Instance
>
connectToStarter
();
static
std
::
unique
_ptr
<
Instance
>
connectToStarter
();
private:
void
initApplication
(
int
argc
,
char
*
argv
[]);
...
...
@@ -171,10 +171,10 @@ private:
std
::
string
m_starterName
;
int
m_starterId
;
std
::
auto
_ptr
<
Server
>
m_server
;
std
::
auto
_ptr
<
Server
>
m_starterServer
;
std
::
unique
_ptr
<
Server
>
m_server
;
std
::
unique
_ptr
<
Server
>
m_starterServer
;
std
::
auto
_ptr
<
WaitingImplSet
>
m_waitingSet
;
std
::
unique
_ptr
<
WaitingImplSet
>
m_waitingSet
;
static
This
m_instance
;
static
const
std
::
string
RUNNING_STATE
;
...
...
@@ -219,7 +219,7 @@ public:
bool
getResult
(
std
::
vector
<
double
>&
result
);
private:
Instance
(
const
Server
*
server
,
std
::
auto
_ptr
<
EventStreamSocket
>&
socket
);
Instance
(
const
Server
*
server
,
std
::
unique
_ptr
<
EventStreamSocket
>&
socket
);
void
setId
(
int
id
);
void
setName
(
const
std
::
string
&
name
);
...
...
@@ -229,8 +229,8 @@ private:
State
waitFor
(
int
states
,
const
std
::
string
&
eventName
,
StateHandlerType
handler
,
bool
blocking
);
const
Server
*
m_server
;
std
::
auto
_ptr
<
EventStreamSocket
>
m_eventSocket
;
std
::
auto
_ptr
<
WaitingImpl
>
m_waiting
;
std
::
unique
_ptr
<
EventStreamSocket
>
m_eventSocket
;