SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XmlFactory.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Martin Hansen
3  *
4  * This file is part of SPAOP (Spatial Audio Object Positioner).
5  *
6  * SPAOP is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * SPAOP 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPAOP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef XMLFACTORY_H_INCLUDED
21 #define XMLFACTORY_H_INCLUDED
22 
23 #include "Source.h"
24 #include "SourceController.h"
25 #include "SourceCollection.h"
26 #include "Room.h"
27 #include "XmlParser.h"
28 #include "JuceHeader.h"
29 
30 namespace wonderjuce {
31 
37 class XmlFactory final
38 {
39 private:
40  XmlFactory();
41  ~XmlFactory();
42 public:
43 
47  static wonder::XmlParser* getParser();
48 
57  static void updateSourceFromXml(const XmlElement* sourceElement,
58  wonder::Source* source);
59 
70  static void updateSourceFromCWonderProject(const std::string& cwProjectXml,
71  wonder::Source* source);
72 
80  static void updateSourceCollectionFromCWonderProject(const std::string& cwProjectXml,
81  wonder::SourceCollection& sources);
82 
90  static XmlElement* createSourceXml(const wonder::Source& source);
91 
100  static const wonder::Room createRoomFromXml (const XmlElement* roomElement);
101 
107  static XmlElement* createRoomXml (const wonder::Room& room);
108 
117  static void updateSourceControllerFromXml(const XmlElement* connectionElement,
118  wonder::SourceController* controller);
119 
128  static XmlElement* createConnectionXml(const wonder::SourceController* controller);
129 
139  static XmlElement* createGuiXml(float zoomFactor, bool showOthers, bool showNames);
140 
141 private:
146  class JuceXmlParser : public wonder::XmlParser
147  {
148  public:
149  virtual ~JuceXmlParser();
150 
151  void updateSourceFromCWonderProject(const std::string& cwProjectXml,
152  wonder::Source* source);
153 
154  void updateSourceCollectionFromCWonderProject(const std::string& cwProjectXml,
155  wonder::SourceCollection& sources);
156  };
157 };
158 
159 }
160 
161 #endif // XMLFACTORY_H_INCLUDED
static XmlElement * createConnectionXml(const wonder::SourceController *controller)
Creates an XmlElement representing a wonder::SourceController's connection state. ...
Definition: XmlFactory.cpp:204
A container class holding multiple sources (IDs 0 to maxSources-1), accessible via their sourceIDs...
Definition: SourceCollection.h:37
static wonder::XmlParser * getParser()
Singleton-getter for a wonder::XmlParser implementation that wraps the corresponding static functions...
Definition: XmlFactory.cpp:24
static XmlElement * createGuiXml(float zoomFactor, bool showOthers, bool showNames)
Creates an XmlElement that holds the parameters of a SPAOP gui that need to be stored.
Definition: XmlFactory.cpp:214
static void updateSourceControllerFromXml(const XmlElement *connectionElement, wonder::SourceController *controller)
Sets the properties of a wonder::SourceController to the values given in an XmlElement that was creat...
Definition: XmlFactory.cpp:186
static void updateSourceFromCWonderProject(const std::string &cwProjectXml, wonder::Source *source)
Sets the properties of a wonder::Source object to the values given in an XML formatted string describ...
Definition: XmlFactory.cpp:59
static void updateSourceCollectionFromCWonderProject(const std::string &cwProjectXml, wonder::SourceCollection &sources)
Sets the properties of a wonder::SourceCollection to the values given in a cWONDER project XML string...
Definition: XmlFactory.cpp:86
A class containing the wonder-specific information about a room (name and vertices).
Definition: Room.h:35
static const wonder::Room createRoomFromXml(const XmlElement *roomElement)
Creates a wonder::Room object from an XmlElement that was created by the createRoomFromXml method...
Definition: XmlFactory.cpp:161
A class for objects representing a WONDER source with all its properties.
Definition: Source.h:60
static void updateSourceFromXml(const XmlElement *sourceElement, wonder::Source *source)
Sets the properties of a wonder::Source object to the values given in an XML element.
Definition: XmlFactory.cpp:30
A class with static functions to create XmlElements from Objects, create Objects from XmlElements and...
Definition: XmlFactory.h:37
The main communication node that keeps track of all virtual sources and enables the host DAW to contr...
Definition: SourceController.h:42
static XmlElement * createSourceXml(const wonder::Source &source)
Creates an XmlElement representing a WONDER source as defined in cwonder_project.dtd.
Definition: XmlFactory.cpp:118
static XmlElement * createRoomXml(const wonder::Room &room)
Creates an XmlElement representing a wonder::Room object.
Definition: XmlFactory.cpp:137
An interface defining a class that sets the parameters of one or several sources from an XML formatte...
Definition: XmlParser.h:30