Skip to content

Commit

Permalink
Add move constructor/operator for the class which support copy constr…
Browse files Browse the repository at this point in the history
…uctor/operator (rdkcentral#1511)

* Add move constructor/operator for the class which support copy constructor/operator

* Update review comments

* Moved private constuctors to public with the = delete

* move constuctors/operators are deleted for the files which are already touched
  • Loading branch information
HaseenaSainul authored Apr 15, 2024
1 parent 7d9911b commit 98a05c3
Show file tree
Hide file tree
Showing 88 changed files with 4,053 additions and 2,338 deletions.
115 changes: 112 additions & 3 deletions Source/WPEFramework/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ namespace PluginHost {
Add(_T("value"), &Value);
Add(_T("override"), &Override);
}
Environment(Environment&& move)
: Core::JSON::Container()
, Key(std::move(move.Key))
, Value(std::move(move.Value))
, Override(std::move(move.Override))
{
Add(_T("key"), &Key);
Add(_T("value"), &Value);
Add(_T("override"), &Override);
}
~Environment() override = default;
Environment& operator=(const Environment& RHS)
{
Expand All @@ -145,6 +155,16 @@ namespace PluginHost {

return (*this);
}
Environment& operator=(Environment&& move)
{
if (this != &move) {
Key = std::move(move.Key);
Value = std::move(move.Value);
Override = std::move(move.Override);
}

return (*this);
}

public:
Core::JSON::String Key;
Expand Down Expand Up @@ -190,6 +210,25 @@ namespace PluginHost {
Add(_T("stacksize"), &StackSize);
Add(_T("umask"), &Umask);
}
ProcessSet(ProcessSet&& move)
: Core::JSON::Container()
, User(std::move(move.User))
, Group(std::move(move.Group))
, Priority(std::move(move.Priority))
, OOMAdjust(std::move(move.OOMAdjust))
, Policy(std::move(move.Policy))
, StackSize(std::move(move.StackSize))
, Umask(std::move(move.Umask))
{
Add(_T("user"), &User);
Add(_T("group"), &Group);
Add(_T("priority"), &Priority);
Add(_T("policy"), &Policy);
Add(_T("oomadjust"), &OOMAdjust);
Add(_T("stacksize"), &StackSize);
Add(_T("umask"), &Umask);
}

~ProcessSet() override = default;

ProcessSet& operator=(const ProcessSet& RHS)
Expand All @@ -205,6 +244,20 @@ namespace PluginHost {
return (*this);
}

ProcessSet& operator=(ProcessSet&& move)
{
if (this != &move) {
User = std::move(move.User);
Group = std::move(move.Group);
Priority = std::move(move.Priority);
Policy = std::move(move.Policy);
OOMAdjust = std::move(move.OOMAdjust);
StackSize = std::move(move.StackSize);
Umask = std::move(move.Umask);
}
return (*this);
}

Core::JSON::String User;
Core::JSON::String Group;
Core::JSON::DecSInt8 Priority;
Expand Down Expand Up @@ -242,6 +295,17 @@ namespace PluginHost {
Add(_T("type"), &Type);
Add(_T("output"), &OutputEnabled);
}
InputConfig(InputConfig&& move)
: Core::JSON::Container()
, Locator(std::move(move.Locator))
, Type(std::move(move.Type))
, OutputEnabled(std::move(move.OutputEnabled))
{
Add(_T("locator"), &Locator);
Add(_T("type"), &Type);
Add(_T("output"), &OutputEnabled);
}

~InputConfig() override = default;

InputConfig& operator=(const InputConfig& RHS)
Expand All @@ -252,14 +316,24 @@ namespace PluginHost {
return (*this);
}

InputConfig& operator=(InputConfig&& move)
{
if (this != &move) {
Locator = std::move(move.Locator);
Type = std::move(move.Type);
OutputEnabled = std::move(move.OutputEnabled);
}
return (*this);
}
Core::JSON::String Locator;
Core::JSON::EnumType<InputHandler::type> Type;
Core::JSON::Boolean OutputEnabled;
};

class Observables : public Core::JSON::Container {
public:
Observables& operator= (const Observables&);
Observables& operator=(Observables&&);
Observables& operator=(const Observables&);

Observables()
: Core::JSON::Container()
Expand All @@ -275,6 +349,13 @@ namespace PluginHost {
Add(_T("proxystubpath"), &ProxyStubPath);
Add(_T("configpath"), &PluginConfigPath);
}
Observables(Observables&& move)
: Core::JSON::Container()
, ProxyStubPath(std::move(move.ProxyStubPath))
, PluginConfigPath(std::move(move.PluginConfigPath)) {
Add(_T("proxystubpath"), &ProxyStubPath);
Add(_T("configpath"), &PluginConfigPath);
}
~Observables() override = default;

Core::JSON::String ProxyStubPath;
Expand All @@ -296,13 +377,25 @@ namespace PluginHost {
{
Add(_T("logging"), &Logging);
}
ProcessContainerConfig(ProcessContainerConfig&& move)
: Logging(std::move(move.Logging))
{
Add(_T("logging"), &Logging);
}
~ProcessContainerConfig() override = default;

ProcessContainerConfig& operator=(const ProcessContainerConfig& RHS)
{
Logging = RHS.Logging;
return (*this);
}
ProcessContainerConfig& operator=(ProcessContainerConfig&& move)
{
if (this != &move) {
Logging = std::move(move.Logging;
}
return (*this);
}

Core::JSON::String Logging;
};
Expand All @@ -323,13 +416,25 @@ namespace PluginHost {
{
Add(_T("locator"), &Locator);
}
HibernateConfig(HibernateConfig&& move)
: Locator(std::move(move.Locator))
{
Add(_T("locator"), &Locator);
}
~HibernateConfig() override = default;

HibernateConfig& operator=(const HibernateConfig& RHS)
{
Locator = RHS.Locator;
return (*this);
}
HibernateConfig& operator=(HibernateConfig&& move)
{
if (this != &move) {
Locator = std::move(move.Locator);
}
return (*this);
}

Core::JSON::String Locator;
};
Expand Down Expand Up @@ -490,8 +595,10 @@ namespace PluginHost {
}

public:
InputInfo(InputInfo&&) = delete;
InputInfo(const InputInfo&) = delete;
InputInfo& operator= (const InputInfo&) = delete;
InputInfo& operator=(InputInfo&&) = delete;
InputInfo& operator=(const InputInfo&) = delete;

~InputInfo() = default;

Expand Down Expand Up @@ -538,8 +645,10 @@ namespace PluginHost {
}

public:
ProcessInfo(ProcessInfo&&) = delete;
ProcessInfo(const ProcessInfo&) = delete;
ProcessInfo& operator= (const ProcessInfo&) = delete;
ProcessInfo& operator=(ProcessInfo&&) = delete;
ProcessInfo& operator=(const ProcessInfo&) = delete;

~ProcessInfo() = default;

Expand Down
8 changes: 5 additions & 3 deletions Source/WPEFramework/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ namespace Plugin {
Core::JSON::Boolean Ui;
};

private:
Controller(const Controller&);
Controller& operator=(const Controller&);
public:
Controller(Controller&&) = delete;
Controller(const Controller&) = delete;
Controller& operator=(Controller&&) = delete;
Controller& operator=(const Controller&) = delete;

protected:
PUSH_WARNING(DISABLE_WARNING_THIS_IN_MEMBER_INITIALIZER_LIST)
Expand Down
41 changes: 27 additions & 14 deletions Source/WPEFramework/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ namespace PluginHost {
Composit() = delete;
Composit(Composit&&) = delete;
Composit(const Composit&&) = delete;
Composit& operator= (Composit&&) = delete;
Composit& operator= (const Composit&&) = delete;
Composit& operator=(Composit&&) = delete;
Composit& operator=(const Composit&&) = delete;

Composit(Service& parent)
: _parent(parent)
Expand Down Expand Up @@ -619,7 +619,7 @@ namespace PluginHost {
}
~ControlData() = default;

ControlData& operator= (const Core::IService::IMetadata* info) {
ControlData& operator=(const Core::IService::IMetadata* info) {
if (info != nullptr) {
const Plugin::IMetadata* extended = dynamic_cast<const Plugin::IMetadata*>(info);

Expand Down Expand Up @@ -1599,6 +1599,18 @@ namespace PluginHost {
Add(_T("startmode"), &StartMode);
Add(_T("resumed"), &Resumed);
}
Plugin(Plugin&& move)
: Core::JSON::Container()
, Configuration(std::move(move.Configuration))
, SystemRootPath(std::move(move.SystemRootPath))
, StartMode(std::move(move.StartMode))
, Resumed(std::move(move.Resumed))
{
Add(_T("configuration"), &Configuration);
Add(_T("systemrootpath"), &SystemRootPath);
Add(_T("startmode"), &StartMode);
Add(_T("resumed"), &Resumed);
}

~Plugin() override = default;

Expand Down Expand Up @@ -1795,14 +1807,15 @@ namespace PluginHost {
}
}

Iterator& operator= (Iterator&& move) {
_container = std::move(move._container);
_index = std::move(move._index);
_position = move._position;

Iterator& operator=(Iterator&& move) {
if (this != &move) {
_container = std::move(move._container);
_index = std::move(move._index);
_position = move._position;
}
return (*this);
}
Iterator& operator= (const Iterator& copy) {
Iterator& operator=(const Iterator& copy) {
_container = copy._container;
_position = copy._position;
if (_position > 0) {
Expand Down Expand Up @@ -1934,8 +1947,8 @@ namespace PluginHost {
ProxyStubObserver() = delete;
ProxyStubObserver(ProxyStubObserver&&) = delete;
ProxyStubObserver(const ProxyStubObserver&) = delete;
ProxyStubObserver& operator= (ProxyStubObserver&&) = delete;
ProxyStubObserver& operator= (const ProxyStubObserver&) = delete;
ProxyStubObserver& operator=(ProxyStubObserver&&) = delete;
ProxyStubObserver& operator=(const ProxyStubObserver&) = delete;

ProxyStubObserver(CommunicatorServer& parent,const string& observableProxyStubPath)
: _parent(parent)
Expand Down Expand Up @@ -2490,8 +2503,8 @@ namespace PluginHost {
ConfigObserver() = delete;
ConfigObserver(ConfigObserver&&) = delete;
ConfigObserver(const ConfigObserver&) = delete;
ConfigObserver& operator= (ConfigObserver&&) = delete;
ConfigObserver& operator= (const ConfigObserver&) = delete;
ConfigObserver& operator=(ConfigObserver&&) = delete;
ConfigObserver& operator=(const ConfigObserver&) = delete;

ConfigObserver(ServiceMap& parent, const string& observableConfigPath)
: _parent(parent)
Expand Down Expand Up @@ -2928,7 +2941,7 @@ namespace PluginHost {
}
inline Iterator Services()
{
Shells workingList;
Shells workingList;

Core::SafeSyncType<Core::CriticalSection> lock(_adminLock);

Expand Down
30 changes: 27 additions & 3 deletions Source/WPEFramework/PostMortem.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,23 @@ namespace PluginHost {
Add(_T("module"), &Module);
Add(_T("line"), &Line);
}
CallstackData(CallstackData&& move)
: Core::JSON::Container()
, Address(std::move(move.Address))
, Function(std::move(move.Function))
, Module(std::move(move.Module))
, Line(std::move(move.Line))
{
Add(_T("address"), &Address);
Add(_T("function"), &Function);
Add(_T("module"), &Module);
Add(_T("line"), &Line);
}

~CallstackData() override = default;

CallstackData& operator=(const CallstackData& RHS) {

CallstackData& operator=(const CallstackData& RHS)
{
Address = RHS.Address;
Function = RHS.Function;
Module = RHS.Module;
Expand All @@ -84,6 +96,17 @@ namespace PluginHost {
return (*this);
}

CallstackData& operator=(CallstackData&& move)
{
if (this != &move) {
Address = std::move(move.Address);
Function = std::move(move.Function);
Module = std::move(move.Module);
Line = std::move(move.Line);
}
return (*this);
}

public:
Core::JSON::Pointer Address;
Core::JSON::String Function;
Expand Down Expand Up @@ -129,7 +152,8 @@ namespace PluginHost {
public:
PostMortemData(PostMortemData&&) = delete;
PostMortemData(const PostMortemData&) = delete;
PostMortemData& operator= (const PostMortemData&) = delete;
PostMortemData& operator=(PostMortemData&&) = delete;
PostMortemData& operator=(const PostMortemData&) = delete;

PostMortemData()
: Core::JSON::Container()
Expand Down
Loading

0 comments on commit 98a05c3

Please sign in to comment.