Allolib  1.0
C++ Components For Interactive Multimedia
al_ParameterBundle.hpp
1 #ifndef AL_PARAMETERBUNDLE_H
2 #define AL_PARAMETERBUNDLE_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-2015. 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  Class to group parameters to simplify multiple instantiation
41  File author(s):
42  AndrĂ©s Cabrera mantaraya36@gmail.com
43 */
44 
45 #include <string>
46 #include <vector>
47 
48 #include "al/ui/al_Parameter.hpp"
49 
50 namespace al {
51 
52 class OSCNotifier;
53 
57  public:
65  ParameterBundle(std::string name = "");
66 
71  std::string name() const;
72 
79  void name(std::string newName);
80 
86  std::string bundlePrefix() const;
87 
88  int bundleIndex() const;
89 
90  void addParameter(ParameterMeta *parameter);
91  void addParameter(ParameterMeta &parameter);
92 
93  void addBundle(ParameterBundle &bundle, std::string id = "");
94 
101  void clear() { mParameters.clear(); }
102 
103  std::vector<ParameterMeta *> &parameters() { return mParameters; }
104 
105  std::map<std::string, std::vector<ParameterBundle *>> &bundles() {
106  return mBundles;
107  }
108 
109  ParameterBundle &operator<<(ParameterMeta *parameter);
110  ParameterBundle &operator<<(ParameterMeta &parameter);
111 
112  void addNotifier(OSCNotifier *notifier);
113 
114  private:
115  static std::map<std::string, int> mBundleCounter;
116  int mBundleIndex = -1;
117  std::string mBundleName;
118  std::string mParentPrefix;
119  std::string mBundleId; // If this is set, it will be used instead of bundle
120  // index to identify bundle.
121 
122  std::vector<ParameterMeta *> mParameters;
123  std::map<std::string, std::vector<ParameterBundle *>> mBundles;
124  std::vector<OSCNotifier *> mNotifiers;
125 };
126 
127 } // namespace al
128 
129 #endif // AL_PARAMETERBUNDLE_H
void name(std::string newName)
set the name for this bundle
std::string name() const
get the name for this bundle
ParameterBundle(std::string name="")
ParameterBundle.
std::string bundlePrefix() const
get the prefix for this bundle
void clear()
clear bundle
The ParameterMeta class defines the base interface for Parameter metadata.
Definition: al_App.hpp:23