Allolib  1.0
C++ Components For Interactive Multimedia
al_PresetMapper.hpp
1 #ifndef AL_PRESETMAPPER_H
2 #define AL_PRESETMAPPER_H
3 
4 /* Allocore --
5  Multimedia / virtual environment application class library
6 
7  Copyright (C) 2009. AlloSphere Research Group, Media Arts & Technology,
8  UCSB. Copyright (C) 2012-2016. The Regents of the University of California.
9  All rights reserved.
10 
11  Redistribution and use in source and binary forms, with or without
12  modification, are permitted provided that the following conditions are
13  met:
14 
15  Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17 
18  Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the following disclaimer in the
20  documentation and/or other materials provided with the
21  distribution.
22 
23  Neither the name of the University of California nor the names
24  of its contributors may be used to endorse or promote products derived from
25  this software without specific prior written permission.
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
28  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
31  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
34  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
36  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
37  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39  File description:
40  Preset mapping: Organizing preset groups
41 
42  File author(s):
43  AndrĂ©s Cabrera mantaraya36@gmail.com
44 */
45 
46 #include <string>
47 #include <vector>
48 
49 #include "al/io/al_File.hpp"
50 #include "al/protocol/al_OSC.hpp"
51 #include "al/ui/al_PresetHandler.hpp"
52 
53 namespace al {
54 
78  public:
79  PresetMapper(bool findAutomatically = true)
80  : mFindAutomatically(findAutomatically) {}
81 
82  virtual ~PresetMapper();
83 
84  PresetMapper &registerPresetHandler(PresetHandler &handler);
85 
86  bool archive(std::string mapName = "default", bool overwrite = true);
87 
88  bool load(std::string mapName);
89 
93  bool restore(std::string mapName = "default", bool overwrite = true,
94  bool autoCreate = false);
95 
99  std::vector<std::string> listAvailableMaps(bool listArchives = true);
100 
101  PresetMapper &operator<<(PresetHandler &handler) {
102  registerPresetHandler(handler);
103  return *this;
104  }
105 
106  protected:
107  virtual bool consumeMessage(osc::Message &m,
108  std::string rootOSCPath) override;
109 
110  private:
111  void findPresetMaps();
112  void readEntries(std::string path);
113 
114  bool mFindAutomatically;
115  PresetHandler *mPresetHandler;
116 };
117 
118 } // namespace al
119 
120 #endif // AL_PRESETMAPPER_H
The PresetHandler class handles sorting and recalling of presets.
The PresetMapper class allows archiving and recalling preset maps.
std::vector< std::string > listAvailableMaps(bool listArchives=true)
virtual bool consumeMessage(osc::Message &m, std::string rootOSCPath) override
Returns true if message was consumed by this class.
bool restore(std::string mapName="default", bool overwrite=true, bool autoCreate=false)
Definition: al_App.hpp:23