From: Jan Olszak Date: Wed, 28 Nov 2012 09:24:05 +0000 (+0100) Subject: Changed ScopedPtr to std::unique_ptr. X-Git-Tag: submit/trunk/20121210.022115~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9fc19d8bff25b5e6fac41d1cdeace30c2ca11ff0;p=platform%2Fframework%2Fweb%2Fwrt-commons.git Changed ScopedPtr to std::unique_ptr. [Issue#] Code refactoring. [Bug] N/A [Cause] N/A [Solution] Used std::unique as ScopedPtr [Verification] Build commons, plugins, installer. Change-Id: I005380ec1ed31229a836d927a0d5620be163088a --- diff --git a/examples/fake_rpc/fake_rpc.cpp b/examples/fake_rpc/fake_rpc.cpp index bbf8c7d..3396a59 100644 --- a/examples/fake_rpc/fake_rpc.cpp +++ b/examples/fake_rpc/fake_rpc.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -62,8 +62,8 @@ private: int m_sentData; int m_receivedData; - DPL::ScopedPtr m_rpcUnixConnection; - DPL::ScopedPtr m_rpcFakeConnection; + std::unique_ptr m_rpcUnixConnection; + std::unique_ptr m_rpcFakeConnection; virtual void OnEventReceived(const AsyncCallEvent &event) { @@ -81,14 +81,14 @@ private: if (dynamic_cast(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::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::AddListener(this); } if(m_connections == 2){ @@ -125,19 +125,19 @@ public: 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::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::RemoveListener(this); - m_rpcFakeConnection.Reset(); + m_rpcFakeConnection.reset(); } // Detach RPC client listener @@ -169,8 +169,8 @@ private: DPL::UnixSocketRPCServer m_rpcUnixServer; DPL::FakeRpcServer m_rpcFakeServer; - DPL::ScopedPtr m_rpcUnixConnection; - DPL::ScopedPtr m_rpcFakeConnection; + std::unique_ptr m_rpcUnixConnection; + std::unique_ptr m_rpcFakeConnection; MyThread m_thread; @@ -180,15 +180,15 @@ private: 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::RemoveListener(this); - m_rpcUnixConnection.Reset(); + m_rpcUnixConnection.reset(); } - if (m_rpcFakeConnection.Get()) { + if (m_rpcFakeConnection.get()) { m_rpcFakeConnection->DPL::EventSupport::RemoveListener(this); - m_rpcFakeConnection.Reset(); + m_rpcFakeConnection.reset(); } LogInfo("SERVER: Closing Server"); @@ -227,12 +227,12 @@ private: // Save connection pointer if (dynamic_cast(event.GetArg1())){ LogInfo("SERVER: Acquiring Fake RPC connection"); - m_rpcFakeConnection.Reset(event.GetArg1()); + m_rpcFakeConnection.reset(event.GetArg1()); m_rpcFakeConnection->DPL::EventSupport::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::AddListener(this); } diff --git a/examples/metronome/metronome_client.cpp b/examples/metronome/metronome_client.cpp index 6f97652..4184f54 100644 --- a/examples/metronome/metronome_client.cpp +++ b/examples/metronome/metronome_client.cpp @@ -34,7 +34,7 @@ class MetronomeClientApplication { private: DPL::TcpSocketRPCClient m_rpcClient; - DPL::ScopedPtr m_rpcConnection; + std::unique_ptr m_rpcConnection; virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::AsyncCallEvent &event) { @@ -68,7 +68,7 @@ private: { // 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::AddListener(this); @@ -93,12 +93,12 @@ public: virtual ~MetronomeClientApplication() { // Delete all RPC connections - if (m_rpcConnection.Get()) + if (m_rpcConnection.get()) { m_rpcConnection->DPL::EventSupport::RemoveListener(this); m_rpcConnection->DPL::EventSupport::RemoveListener(this); m_rpcConnection->DPL::EventSupport::RemoveListener(this); - m_rpcConnection.Reset(); + m_rpcConnection.reset(); } // Close RPC server diff --git a/examples/rpc/rpc.cpp b/examples/rpc/rpc.cpp index cacc491..e1e2a64 100644 --- a/examples/rpc/rpc.cpp +++ b/examples/rpc/rpc.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ class MyThread { private: DPL::UnixSocketRPCClient m_rpcClient; - DPL::ScopedPtr m_rpcConnection; + std::unique_ptr m_rpcConnection; virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::AsyncCallEvent &event) { @@ -70,7 +70,7 @@ private: { // 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"); @@ -109,7 +109,7 @@ public: int ret = Exec(); // Detach RPC listeners - if (m_rpcConnection.Get()) + if (m_rpcConnection.get()) { LogInfo("CLIENT: Detaching RPC connection events"); m_rpcConnection->DPL::EventSupport::RemoveListener(this); @@ -117,7 +117,7 @@ public: m_rpcConnection->DPL::EventSupport::RemoveListener(this); LogInfo("CLIENT: Resetting connection"); - m_rpcConnection.Reset(); + m_rpcConnection.reset(); } // Detach RPC client listener @@ -147,7 +147,7 @@ class MyApplication { private: DPL::UnixSocketRPCServer m_rpcServer; - DPL::ScopedPtr m_rpcConnection; + std::unique_ptr m_rpcConnection; MyThread m_thread; @@ -185,7 +185,7 @@ private: 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::RemoveListener(this); @@ -209,7 +209,7 @@ private: { // 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"); diff --git a/modules/core/src/zip_input.cpp b/modules/core/src/zip_input.cpp index 8ce1201..691a2ec 100644 --- a/modules/core/src/zip_input.cpp +++ b/modules/core/src/zip_input.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -304,7 +304,7 @@ ZipInput::ZipInput(const std::string &fileName) // Create master device LogPedantic("Creating master device"); - ScopedPtr device(new Device(fileName)); + std::unique_ptr device(new Device(fileName)); // Open master file zlib_filefunc64_def interface; @@ -315,7 +315,7 @@ ZipInput::ZipInput(const std::string &fileName) 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); @@ -339,7 +339,7 @@ ZipInput::ZipInput(const std::string &fileName) // Release scoped unz close m_masterFile = scopedUnzClose.Release(); - m_device = device.Release(); + m_device = device.release(); LogPedantic("Zip file opened"); } diff --git a/modules/db/include/dpl/db/sql_connection.h b/modules/db/include/dpl/db/sql_connection.h index f973772..f1b3b62 100644 --- a/modules/db/include/dpl/db/sql_connection.h +++ b/modules/db/include/dpl/db/sql_connection.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -423,7 +423,7 @@ protected: int m_dataCommandsCount; // Synchronization object - ScopedPtr m_synchronizationObject; + std::unique_ptr m_synchronizationObject; virtual void Connect(const std::string &address, Flag::Type = Flag::None, Flag::Option = Flag::RO); diff --git a/modules/db/src/sql_connection.cpp b/modules/db/src/sql_connection.cpp index 26fb815..d1b44dd 100644 --- a/modules/db/src/sql_connection.cpp +++ b/modules/db/src/sql_connection.cpp @@ -69,7 +69,7 @@ SqlConnection::DataCommand::DataCommand(SqlConnection *connection, Assert(connection != NULL); // Notify all after potentially synchronized database connection access - ScopedNotifyAll notifyAll(connection->m_synchronizationObject.Get()); + ScopedNotifyAll notifyAll(connection->m_synchronizationObject.get()); for (;;) { @@ -324,7 +324,7 @@ bool SqlConnection::DataCommand::Step() { // Notify all after potentially synchronized database connection access ScopedNotifyAll notifyAll( - m_masterConnection->m_synchronizationObject.Get()); + m_masterConnection->m_synchronizationObject.get()); for (;;) { @@ -765,7 +765,7 @@ void SqlConnection::ExecCommand(const char *format, ...) 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 (;;) { diff --git a/modules/event/include/dpl/event/event_support.h b/modules/event/include/dpl/event/event_support.h index 3aaab81..2e8cfb2 100644 --- a/modules/event/include/dpl/event/event_support.h +++ b/modules/event/include/dpl/event/event_support.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -364,7 +364,7 @@ protected: double dueTime = 0.0) { // Emit event, and retrieve later in current context to dispatch - ScopedPtr lock( + std::unique_ptr lock( new Mutex::ScopedLock(&m_listenerDelegateMutex)); // Show some info @@ -583,7 +583,7 @@ protected: if (!synchronizationBarrier.empty()) { LogPedantic("Leaving lock due to existing barrier"); - lock.Reset(); + lock.reset(); } LogPedantic("Size of barrier: " << synchronizationBarrier.size()); diff --git a/modules/rpc/include/dpl/rpc/generic_rpc_connection.h b/modules/rpc/include/dpl/rpc/generic_rpc_connection.h index 1342859..353dd3a 100644 --- a/modules/rpc/include/dpl/rpc/generic_rpc_connection.h +++ b/modules/rpc/include/dpl/rpc/generic_rpc_connection.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include namespace DPL { @@ -42,7 +42,7 @@ private: virtual void OnInputStreamClosed(); virtual void OnInputStreamBroken(); - ScopedPtr m_inputOutput; + std::unique_ptr m_inputOutput; public: /**