From 041797aed1421b00bbd3289c66e8594fb6a32be9 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 11 Aug 2017 10:29:29 +0200 Subject: [PATCH] Add ClonableObject base class. --- src/CMakeLists.txt | 3 +++ src/object/clonable-object-p.h | 43 ++++++++++++++++++++++++++++++++ src/object/clonable-object.cpp | 35 ++++++++++++++++++++++++++ src/object/clonable-object.h | 45 ++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 src/object/clonable-object-p.h create mode 100644 src/object/clonable-object.cpp create mode 100644 src/object/clonable-object.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 823db4682..c30476f70 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,6 +30,8 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES cpim/parser/cpim-grammar.h cpim/parser/cpim-parser.h logger/logger.h + object/clonable-object.h + object/clonable-object-p.h object/object-p.h object/object.h object/singleton.h @@ -45,6 +47,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES cpim/parser/cpim-grammar.cpp cpim/parser/cpim-parser.cpp logger/logger.cpp + object/clonable-object.cpp object/object.cpp utils/utils.cpp ) diff --git a/src/object/clonable-object-p.h b/src/object/clonable-object-p.h new file mode 100644 index 000000000..94c3b4491 --- /dev/null +++ b/src/object/clonable-object-p.h @@ -0,0 +1,43 @@ +/* + * clonable-object-p.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _CLONABLE_OBJECT_P_H_ +#define _CLONABLE_OBJECT_P_H_ + +#include "utils/general.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class ClonableObject; + +class ClonableObjectPrivate { +public: + virtual ~ClonableObjectPrivate () = default; + +protected: + ClonableObject *mPublic = nullptr; + +private: + L_DECLARE_PUBLIC(ClonableObject); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _CLONABLE_OBJECT_P_H_ diff --git a/src/object/clonable-object.cpp b/src/object/clonable-object.cpp new file mode 100644 index 000000000..5b21b09b3 --- /dev/null +++ b/src/object/clonable-object.cpp @@ -0,0 +1,35 @@ +/* + * clonable-object.cpp + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "clonable-object-p.h" + +#include "clonable-object.h" + +LINPHONE_BEGIN_NAMESPACE + +// ============================================================================= + +ClonableObject::~ClonableObject () { + delete mPrivate; +} + +ClonableObject::ClonableObject (ClonableObjectPrivate &p) : mPrivate(&p) { + mPrivate->mPublic = this; +} + +LINPHONE_END_NAMESPACE diff --git a/src/object/clonable-object.h b/src/object/clonable-object.h new file mode 100644 index 000000000..bda4392e1 --- /dev/null +++ b/src/object/clonable-object.h @@ -0,0 +1,45 @@ +/* + * clonable-object.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _CLONABLE_OBJECT_H_ +#define _CLONABLE_OBJECT_H_ + +#include "utils/general.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class ClonableObjectPrivate; + +class LINPHONE_PUBLIC ClonableObject { +public: + virtual ~ClonableObject (); + +protected: + explicit ClonableObject (ClonableObjectPrivate &p); + + ClonableObjectPrivate *mPrivate = nullptr; + +private: + L_DECLARE_PRIVATE(ClonableObject); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _CLONABLE_OBJECT_H_