[Issue#] Code refactoring.
[Bug] N/A
[Cause] N/A
[Solution] Used std::unique as ScopedPtr
[Verification] Build commons, plugins, installer.
Change-Id: I005380ec1ed31229a836d927a0d5620be163088a
#include <dpl/unix_socket_rpc_server.h>
#include <dpl/unix_socket_rpc_connection.h>
#include <dpl/fake_rpc_connection.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
#include <dpl/application.h>
#include <dpl/controller.h>
#include <dpl/thread.h>
int m_sentData;
int m_receivedData;
- DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcUnixConnection;
- DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcFakeConnection;
+ std::unique_ptr<DPL::AbstractRPCConnection> m_rpcUnixConnection;
+ std::unique_ptr<DPL::AbstractRPCConnection> m_rpcFakeConnection;
virtual void OnEventReceived(const AsyncCallEvent &event)
{
if (dynamic_cast<DPL::FakeRpcConnection *>(event.GetArg1())){
++m_connections;
LogInfo("CLIENT: Acquiring new fake connection");
- m_rpcFakeConnection.Reset(event.GetArg1());
+ m_rpcFakeConnection.reset(event.GetArg1());
//this is not used on this side
// m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
}
else{
++m_connections;
LogInfo("CLIENT: Acquiring new unix connection");
- m_rpcUnixConnection.Reset(event.GetArg1());
+ m_rpcUnixConnection.reset(event.GetArg1());
m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
}
if(m_connections == 2){
LogInfo("CLIENT: Starting thread event loop");
int ret = Exec();
- if (m_rpcUnixConnection.Get()){
+ if (m_rpcUnixConnection.get()){
LogInfo("CLIENT: Removing Unix connection");
m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
- m_rpcUnixConnection.Reset();
+ m_rpcUnixConnection.reset();
}
LogInfo("CLIENT: Closing");
- if (m_rpcFakeConnection.Get()){
+ if (m_rpcFakeConnection.get()){
LogInfo("CLIENT: Removing Fake connection");
//this is not used on this side
// m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
- m_rpcFakeConnection.Reset();
+ m_rpcFakeConnection.reset();
}
// Detach RPC client listener
DPL::UnixSocketRPCServer m_rpcUnixServer;
DPL::FakeRpcServer m_rpcFakeServer;
- DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcUnixConnection;
- DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcFakeConnection;
+ std::unique_ptr<DPL::AbstractRPCConnection> m_rpcUnixConnection;
+ std::unique_ptr<DPL::AbstractRPCConnection> m_rpcFakeConnection;
MyThread m_thread;
LogInfo("SERVER: Closing RPC connection...");
// Detach RPC connection listeners
- if (m_rpcUnixConnection.Get()) {
+ if (m_rpcUnixConnection.get()) {
//this is not used on this side
// m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
- m_rpcUnixConnection.Reset();
+ m_rpcUnixConnection.reset();
}
- if (m_rpcFakeConnection.Get()) {
+ if (m_rpcFakeConnection.get()) {
m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
- m_rpcFakeConnection.Reset();
+ m_rpcFakeConnection.reset();
}
LogInfo("SERVER: Closing Server");
// Save connection pointer
if (dynamic_cast<DPL::FakeRpcConnection *>(event.GetArg1())){
LogInfo("SERVER: Acquiring Fake RPC connection");
- m_rpcFakeConnection.Reset(event.GetArg1());
+ m_rpcFakeConnection.reset(event.GetArg1());
m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
}
else{
LogInfo("SERVER: Acquiring Unix RPC connection");
- m_rpcUnixConnection.Reset(event.GetArg1());
+ m_rpcUnixConnection.reset(event.GetArg1());
//this is not used on this side
// m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
}
{
private:
DPL::TcpSocketRPCClient m_rpcClient;
- DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcConnection;
+ std::unique_ptr<DPL::AbstractRPCConnection> m_rpcConnection;
virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::AsyncCallEvent &event)
{
{
// Save connection pointer
LogInfo("Connected to metronome server");
- m_rpcConnection.Reset(event.GetArg1());
+ m_rpcConnection.reset(event.GetArg1());
// Attach event listeners
m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::AddListener(this);
virtual ~MetronomeClientApplication()
{
// Delete all RPC connections
- if (m_rpcConnection.Get())
+ if (m_rpcConnection.get())
{
m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionClosedEvent>::RemoveListener(this);
m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionBrokenEvent>::RemoveListener(this);
- m_rpcConnection.Reset();
+ m_rpcConnection.reset();
}
// Close RPC server
#include <dpl/unix_socket_rpc_client.h>
#include <dpl/unix_socket_rpc_server.h>
#include <dpl/unix_socket_rpc_connection.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
#include <dpl/application.h>
#include <dpl/controller.h>
#include <dpl/thread.h>
{
private:
DPL::UnixSocketRPCClient m_rpcClient;
- DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcConnection;
+ std::unique_ptr<DPL::AbstractRPCConnection> m_rpcConnection;
virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::AsyncCallEvent &event)
{
{
// Save connection pointer
LogInfo("CLIENT: Acquiring new connection");
- m_rpcConnection.Reset(event.GetArg1());
+ m_rpcConnection.reset(event.GetArg1());
// Attach listener to new connection
LogInfo("CLIENT: Attaching connection event listeners");
int ret = Exec();
// Detach RPC listeners
- if (m_rpcConnection.Get())
+ if (m_rpcConnection.get())
{
LogInfo("CLIENT: Detaching RPC connection events");
m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::ConnectionBrokenEvent>::RemoveListener(this);
LogInfo("CLIENT: Resetting connection");
- m_rpcConnection.Reset();
+ m_rpcConnection.reset();
}
// Detach RPC client listener
{
private:
DPL::UnixSocketRPCServer m_rpcServer;
- DPL::ScopedPtr<DPL::AbstractRPCConnection> m_rpcConnection;
+ std::unique_ptr<DPL::AbstractRPCConnection> m_rpcConnection;
MyThread m_thread;
LogInfo("SERVER: Closing RPC connection on event...");
// Detach RPC connection listeners
- if (m_rpcConnection.Get())
+ if (m_rpcConnection.get())
{
LogInfo("SERVER: Detaching connection events");
m_rpcConnection->DPL::EventSupport<DPL::AbstractRPCConnectionEvents::AsyncCallEvent>::RemoveListener(this);
{
// Save connection pointer
LogInfo("SERVER: Acquiring RPC connection");
- m_rpcConnection.Reset(event.GetArg1());
+ m_rpcConnection.reset(event.GetArg1());
// Attach event listeners
LogInfo("SERVER: Attaching connection listeners");
#include <dpl/scoped_close.h>
#include <dpl/binary_queue.h>
#include <dpl/scoped_free.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
#include <dpl/scoped_array.h>
#include <dpl/foreach.h>
#include <dpl/log/log.h>
// Create master device
LogPedantic("Creating master device");
- ScopedPtr<Device> device(new Device(fileName));
+ std::unique_ptr<Device> device(new Device(fileName));
// Open master file
zlib_filefunc64_def interface;
interface.zseek64_file = &Device::seek64_file;
interface.zclose_file = &Device::close_file;
interface.zerror_file = &Device::testerror_file;
- interface.opaque = device.Get();
+ interface.opaque = device.get();
LogPedantic("Opening zip file");
unzFile file = unzOpen2_64(NULL, &interface);
// Release scoped unz close
m_masterFile = scopedUnzClose.Release();
- m_device = device.Release();
+ m_device = device.release();
LogPedantic("Zip file opened");
}
#include <dpl/noncopyable.h>
#include <dpl/exception.h>
#include <dpl/optional.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
#include <dpl/string.h>
#include <dpl/log/log.h>
#include <sqlite3.h>
int m_dataCommandsCount;
// Synchronization object
- ScopedPtr<SynchronizationObject> m_synchronizationObject;
+ std::unique_ptr<SynchronizationObject> m_synchronizationObject;
virtual void Connect(const std::string &address,
Flag::Type = Flag::None, Flag::Option = Flag::RO);
Assert(connection != NULL);
// Notify all after potentially synchronized database connection access
- ScopedNotifyAll notifyAll(connection->m_synchronizationObject.Get());
+ ScopedNotifyAll notifyAll(connection->m_synchronizationObject.get());
for (;;)
{
{
// Notify all after potentially synchronized database connection access
ScopedNotifyAll notifyAll(
- m_masterConnection->m_synchronizationObject.Get());
+ m_masterConnection->m_synchronizationObject.get());
for (;;)
{
LogPedantic("Executing SQL command: " << buffer.Get());
// Notify all after potentially synchronized database connection access
- ScopedNotifyAll notifyAll(m_synchronizationObject.Get());
+ ScopedNotifyAll notifyAll(m_synchronizationObject.get());
for (;;)
{
#include <dpl/event/generic_event_call.h>
#include <dpl/waitable_event.h>
#include <dpl/fast_delegate.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
#include <dpl/exception.h>
#include <dpl/thread.h>
#include <dpl/assert.h>
double dueTime = 0.0)
{
// Emit event, and retrieve later in current context to dispatch
- ScopedPtr<Mutex::ScopedLock> lock(
+ std::unique_ptr<Mutex::ScopedLock> lock(
new Mutex::ScopedLock(&m_listenerDelegateMutex));
// Show some info
if (!synchronizationBarrier.empty())
{
LogPedantic("Leaving lock due to existing barrier");
- lock.Reset();
+ lock.reset();
}
LogPedantic("Size of barrier: " << synchronizationBarrier.size());
#include <dpl/rpc/abstract_rpc_connection.h>
#include <dpl/abstract_waitable_input_output.h>
#include <dpl/socket/waitable_input_output_execution_context_support.h>
-#include <dpl/scoped_ptr.h>
+#include <memory>
namespace DPL
{
virtual void OnInputStreamClosed();
virtual void OnInputStreamBroken();
- ScopedPtr<AbstractWaitableInputOutput> m_inputOutput;
+ std::unique_ptr<AbstractWaitableInputOutput> m_inputOutput;
public:
/**