Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
d4d2794c
Commit
d4d2794c
authored
Sep 14, 2017
by
Ronan
Browse files
feat(Object): add a PropertyContainer class
parent
af09244d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
123 additions
and
52 deletions
+123
-52
src/CMakeLists.txt
src/CMakeLists.txt
+2
-0
src/object/clonable-object-p.h
src/object/clonable-object-p.h
+0
-4
src/object/clonable-object.cpp
src/object/clonable-object.cpp
+0
-16
src/object/clonable-object.h
src/object/clonable-object.h
+3
-7
src/object/object.cpp
src/object/object.cpp
+0
-16
src/object/object.h
src/object/object.h
+3
-9
src/object/property-container.cpp
src/object/property-container.cpp
+61
-0
src/object/property-container.h
src/object/property-container.h
+54
-0
No files found.
src/CMakeLists.txt
View file @
d4d2794c
...
...
@@ -89,6 +89,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
object/clonable-object.h
object/object-p.h
object/object.h
object/property-container.h
object/singleton.h
utils/payload-type-handler.h
variant/variant.h
...
...
@@ -140,6 +141,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
nat/stun-client.cpp
object/clonable-object.cpp
object/object.cpp
object/property-container.cpp
utils/general.cpp
utils/payload-type-handler.cpp
utils/utils.cpp
...
...
src/object/clonable-object-p.h
View file @
d4d2794c
...
...
@@ -23,8 +23,6 @@
#include "linphone/utils/general.h"
#include "variant/variant.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
...
...
@@ -43,8 +41,6 @@ private:
int
nRefs
=
0
;
std
::
unordered_map
<
std
::
string
,
Variant
>
properties
;
L_DECLARE_PUBLIC
(
ClonableObject
);
// It's forbidden to copy directly one Clonable object private.
...
...
src/object/clonable-object.cpp
View file @
d4d2794c
...
...
@@ -82,20 +82,4 @@ void ClonableObject::setRef (const ClonableObjectPrivate &p) {
mPrivate
->
ref
();
}
Variant
ClonableObject
::
getProperty
(
const
string
&
name
)
const
{
L_D
(
const
ClonableObject
);
auto
it
=
d
->
properties
.
find
(
name
);
return
it
==
d
->
properties
.
cend
()
?
Variant
()
:
it
->
second
;
}
void
ClonableObject
::
setProperty
(
const
string
&
name
,
const
Variant
&
value
)
{
L_D
(
ClonableObject
);
d
->
properties
[
name
]
=
value
;
}
void
ClonableObject
::
setProperty
(
const
string
&
name
,
Variant
&&
value
)
{
L_D
(
ClonableObject
);
d
->
properties
[
name
]
=
move
(
value
);
}
LINPHONE_END_NAMESPACE
src/object/clonable-object.h
View file @
d4d2794c
...
...
@@ -23,20 +23,16 @@
#include "linphone/utils/general.h"
#include "property-container.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class
Variant
;
class
LINPHONE_PUBLIC
ClonableObject
{
class
LINPHONE_PUBLIC
ClonableObject
:
public
PropertyContainer
{
public:
virtual
~
ClonableObject
();
Variant
getProperty
(
const
std
::
string
&
name
)
const
;
void
setProperty
(
const
std
::
string
&
name
,
const
Variant
&
value
);
void
setProperty
(
const
std
::
string
&
name
,
Variant
&&
value
);
protected:
// Use a new ClonableObjectPrivate without owner.
explicit
ClonableObject
(
ClonableObjectPrivate
&
p
);
...
...
src/object/object.cpp
View file @
d4d2794c
...
...
@@ -34,20 +34,4 @@ Object::Object (ObjectPrivate &p) : mPrivate(&p) {
mPrivate
->
mPublic
=
this
;
}
Variant
Object
::
getProperty
(
const
string
&
name
)
const
{
L_D
(
const
Object
);
auto
it
=
d
->
properties
.
find
(
name
);
return
it
==
d
->
properties
.
cend
()
?
Variant
()
:
it
->
second
;
}
void
Object
::
setProperty
(
const
string
&
name
,
const
Variant
&
value
)
{
L_D
(
Object
);
d
->
properties
[
name
]
=
value
;
}
void
Object
::
setProperty
(
const
string
&
name
,
Variant
&&
value
)
{
L_D
(
Object
);
d
->
properties
[
name
]
=
move
(
value
);
}
LINPHONE_END_NAMESPACE
src/object/object.h
View file @
d4d2794c
...
...
@@ -19,24 +19,18 @@
#ifndef _OBJECT_H_
#define _OBJECT_H_
#include <string>
#include "linphone/utils/general.h"
#include "property-container.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class
Variant
;
class
LINPHONE_PUBLIC
Object
{
class
LINPHONE_PUBLIC
Object
:
public
PropertyContainer
{
public:
virtual
~
Object
();
Variant
getProperty
(
const
std
::
string
&
name
)
const
;
void
setProperty
(
const
std
::
string
&
name
,
const
Variant
&
value
);
void
setProperty
(
const
std
::
string
&
name
,
Variant
&&
value
);
protected:
explicit
Object
(
ObjectPrivate
&
p
);
...
...
src/object/property-container.cpp
0 → 100644
View file @
d4d2794c
/*
* property-container.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 <http://www.gnu.org/licenses/>.
*/
#include <unordered_map>
#include "property-container.h"
// =============================================================================
using
namespace
std
;
LINPHONE_BEGIN_NAMESPACE
class
PropertyContainerPrivate
{
public:
unordered_map
<
std
::
string
,
Variant
>
properties
;
};
// -----------------------------------------------------------------------------
// Empty copy constructor. Don't change this pattern.
// PropertyContainer is an Entity component, not a simple structure.
// An Entity is UNIQUE.
PropertyContainer
::
PropertyContainer
(
const
PropertyContainer
&
)
{}
PropertyContainer
&
PropertyContainer
::
operator
=
(
const
PropertyContainer
&
)
{
return
*
this
;
}
Variant
PropertyContainer
::
getProperty
(
const
string
&
name
)
const
{
L_D
(
const
PropertyContainer
);
auto
it
=
d
->
properties
.
find
(
name
);
return
it
==
d
->
properties
.
cend
()
?
Variant
()
:
it
->
second
;
}
void
PropertyContainer
::
setProperty
(
const
string
&
name
,
const
Variant
&
value
)
{
L_D
(
PropertyContainer
);
d
->
properties
[
name
]
=
value
;
}
void
PropertyContainer
::
setProperty
(
const
string
&
name
,
Variant
&&
value
)
{
L_D
(
PropertyContainer
);
d
->
properties
[
name
]
=
move
(
value
);
}
LINPHONE_END_NAMESPACE
src/object/property-container.h
0 → 100644
View file @
d4d2794c
/*
* property-container.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 <http://www.gnu.org/licenses/>.
*/
#ifndef _PROPERTY_CONTAINER_H_
#define _PROPERTY_CONTAINER_H_
#include <string>
#include "linphone/utils/general.h"
#include "variant/variant.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class
PropertyContainerPrivate
;
class
LINPHONE_PUBLIC
PropertyContainer
{
public:
PropertyContainer
()
=
default
;
PropertyContainer
(
const
PropertyContainer
&
src
);
virtual
~
PropertyContainer
()
=
default
;
PropertyContainer
&
operator
=
(
const
PropertyContainer
&
src
);
Variant
getProperty
(
const
std
::
string
&
name
)
const
;
void
setProperty
(
const
std
::
string
&
name
,
const
Variant
&
value
);
void
setProperty
(
const
std
::
string
&
name
,
Variant
&&
value
);
private:
PropertyContainerPrivate
*
mPrivate
=
nullptr
;
L_DECLARE_PRIVATE
(
PropertyContainer
);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _PROPERTY_CONTAINER_H_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment