2
* Compiz configuration system library
4
* Copyright (C) 2012 Canonical Ltd.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
* Sam Spilsbury <sam.spilsbury@canonical.com>
23
#ifndef _COMPIZCONFIG_CCS_LIST_WRAPPER_H
24
#define _COMPIZCONFIG_CCS_LIST_WRAPPER_H
27
#include <ccs-setting-types.h>
29
#include <boost/shared_ptr.hpp>
30
#include <boost/noncopyable.hpp>
32
typedef struct _CCSSettingValueList * CCSSettingValueList;
33
typedef struct _CCSSetting CCSSetting;
34
typedef union _CCSSettingInfo CCSSettingInfo;
35
typedef struct _CCSSettingValue CCSSettingValue;
41
template <typename ListType, typename DataType>
42
class CCSListWrapper :
47
virtual ~CCSListWrapper () {}
49
virtual CCSListWrapper<ListType, DataType> & append (const DataType &) = 0;
50
virtual CCSListWrapper<ListType, DataType> & remove (const DataType &) = 0;
52
virtual operator const ListType & () const = 0;
53
virtual operator ListType & () = 0;
58
namespace cc = compiz::config;
59
namespace cci = compiz::config::impl;
61
typedef enum _ListStorageType
67
template <typename ListType, typename DataType>
68
class CCSListWrapper :
69
public cc::CCSListWrapper <ListType, DataType>
73
typedef ListType (*ListTypeFreeFunc) (ListType, Bool);
74
typedef ListType (*ListTypeAppendFunc) (ListType, DataType);
75
typedef ListType (*ListTypeRemoveFunc) (ListType, DataType, Bool);
77
CCSListWrapper (const ListType &list,
78
ListTypeFreeFunc freeFunc,
79
ListTypeAppendFunc appendFunc,
80
ListTypeRemoveFunc removeFunc,
81
ListStorageType storageType) :
86
mStorageType (storageType)
90
cc::CCSListWrapper<ListType, DataType> & append (DataType const &data)
92
mList = (*mAppend) (mList, data);
96
cc::CCSListWrapper<ListType, DataType> & remove (DataType const &data)
98
Bool freeObj = (mStorageType == Deep);
99
mList = (*mRemove) (mList, data, freeObj);
103
operator const ListType & () const
108
operator ListType & ()
115
Bool freeObj = (mStorageType == Deep);
117
(*mFree) (mList, freeObj);
123
ListTypeFreeFunc mFree;
124
ListTypeAppendFunc mAppend;
125
ListTypeRemoveFunc mRemove;
126
ListStorageType mStorageType;
129
class PrivateCCSSettingValueListWrapper;
131
class CCSSettingValueListWrapper :
132
public compiz::config::CCSListWrapper <CCSSettingValueList, CCSSettingValue *>
136
typedef boost::shared_ptr <CCSSettingValueListWrapper> Ptr;
137
typedef compiz::config::CCSListWrapper <CCSSettingValueList, CCSSettingValue *> InternalWrapper;
138
typedef compiz::config::impl::CCSListWrapper <CCSSettingValueList, CCSSettingValue *> InternalWrapperImpl;
140
CCSSettingValueListWrapper (CCSSettingValueList list,
141
ListStorageType storageType,
143
const boost::shared_ptr <CCSSettingInfo> &listInfo,
144
const boost::shared_ptr <CCSSetting> &settingReference);
146
CCSSettingType type ();
148
InternalWrapper & append (CCSSettingValue * const &value);
149
InternalWrapper & remove (CCSSettingValue * const &value);
150
operator const CCSSettingValueList & () const;
151
operator CCSSettingValueList & ();
152
const boost::shared_ptr <CCSSetting> & setting ();
156
boost::shared_ptr <PrivateCCSSettingValueListWrapper> priv;