LMMS
Loading...
Searching...
No Matches
SerializingObject.h
Go to the documentation of this file.
1/*
2 * SerializingObject.h - declaration of class SerializingObject
3 *
4 * Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_SERIALIZING_OBJECT_H
26#define LMMS_SERIALIZING_OBJECT_H
27
28#include <QString>
29
30#include "lmms_export.h"
31
32
33class QDomDocument;
34class QDomElement;
35
36namespace lmms
37{
38
40
41
42class LMMS_EXPORT SerializingObject
43{
44public:
46 virtual ~SerializingObject();
47
48 virtual QDomElement saveState( QDomDocument & _doc, QDomElement & _parent );
49
50 virtual void restoreState( const QDomElement & _this );
51
52
53 // to be implemented by actual object
54 virtual QString nodeName() const = 0;
55
56 void setHook( SerializingObjectHook * _hook );
57
59 {
60 return m_hook;
61 }
62
63
64protected:
65 // to be implemented by sub-objects
66 virtual void saveSettings( QDomDocument& doc, QDomElement& element ) = 0;
67 virtual void loadSettings( const QDomElement& element ) = 0;
68
69
70private:
72
73} ;
74
75
77{
78public:
84 {
85 if( m_hookedIn != nullptr )
86 {
87 m_hookedIn->setHook( nullptr );
88 }
89 }
90
91 virtual void saveSettings( QDomDocument & _doc, QDomElement & _this ) = 0;
92 virtual void loadSettings( const QDomElement & _this ) = 0;
93
94private:
96
97 friend class SerializingObject;
98
99} ;
100
101
102} // namespace lmms
103
104#endif // LMMS_SERIALIZING_OBJECT_H
#define nullptr
Definition DistrhoDefines.h:75
Definition SerializingObject.h:77
SerializingObjectHook()
Definition SerializingObject.h:79
SerializingObject * m_hookedIn
Definition SerializingObject.h:95
virtual void saveSettings(QDomDocument &_doc, QDomElement &_this)=0
virtual ~SerializingObjectHook()
Definition SerializingObject.h:83
friend class SerializingObject
Definition SerializingObject.h:97
virtual void loadSettings(const QDomElement &_this)=0
virtual QDomElement saveState(QDomDocument &_doc, QDomElement &_parent)
Definition SerializingObject.cpp:51
virtual QString nodeName() const =0
void setHook(SerializingObjectHook *_hook)
Definition SerializingObject.cpp:82
SerializingObjectHook * hook()
Definition SerializingObject.h:58
SerializingObject()
Definition SerializingObject.cpp:32
SerializingObjectHook * m_hook
Definition SerializingObject.h:71
virtual void restoreState(const QDomElement &_this)
Definition SerializingObject.cpp:69
Definition AudioAlsa.cpp:35