Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_INPUT_LIST_H
21 #define OMNI_INPUT_LIST_H
22 
23 #include <algorithm>
24 #include <memory>
25 #include <map>
26 #include <omni/Id.h>
27 #include <omni/input/Interface.h>
28 #include <omni/input/Controller.h>
29 
30 
31 namespace omni {
32  namespace input {
33  class Controller;
34 
35  /**@brief Input List contains a list of inputs, accessible over an QString id
36  *@detail
37  Input List is the root input of a session's input tree.
38  Input List is serializable via QDataStream.
39  **/
40  class List : public input::Interface {
41  public:
42  List(Interface const * = nullptr);
43 
44  /// A list cannot be registered in factory
45  inline void registerInFactory() const {
46  }
47 
48  /// Type id is "List"
49  inline Id getTypeId() const {
50  return Id("List");
51  }
52 
53  /**@brief Add new input with given type id. Returns nullptr if input
54  with typeid does not exist
55  @detail Id is automatically generated
56  *@param _typeId Type id of input to determine which kind of input is
57  *created
58  *@return Pair with input id and pointer to added input
59  **/
60  std::pair<QString, Input *>addInput(Id const& _typeId);
61 
62  /// Remove input and reset current index if necessary
63  void removeInput(QString const& _id);
64 
65  /// List can have children
66  inline bool canHaveChildren() const {
67  return true;
68  }
69 
70  /// List has no size
71  inline QSize size() const {
72  return QSize(0, 0);
73  }
74 
75  /// List does not have a texture
76  inline GLuint textureId() const {
77  return 0;
78  }
79 
80  inline QWidget* widget() {
81  return nullptr;
82  }
83 
84  /// Return input at index
85  Input * operator[](QString const& _id);
86 
87  /// Returns input at index (const version)
88  Input const * operator[](QString const& _id) const;
89 
90  /// Delete all inputs
91  void clear();
92 
93  /**@brief Returns pointer to current input
94  * @detail Returns nullptr if currentIdx_ == -1 or input list is empty
95  **/
96  Input * current();
97 
98  /**@brief Returns pointer to current input (const version)
99  * @detail Returns nullptr if currentIdx_ == -1 or input list is empty
100  **/
101  Input const * current() const;
102 
103  /// Return ID of current input
104  QString currentId() const;
105 
106  /// Set current input by ID
107  void setCurrentId(QString const&);
108 
109 
110  /// Return pointer to controller
112 
113  /// Return pointer to controller (const version)
114  Controller const* controller() const;
115 
116  /// Deserialize from property map
117  void fromPropertyMap(PropertyMap const&);
118 
119  /// Serialize to property map
120  void toPropertyMap(PropertyMap&) const;
121 
122  /// Test for equality
123  friend bool operator==(List const&,
124  List const&);
125 
126  private:
127  /// Generate a new id for input
128  QString generateId() const;
129 
130  QString currentId_;
131  };
132  }
133 
135 }
136 
138 
139 
140 #endif /* OMNI_INPUT_LIST_H */
friend bool operator==(List const &, List const &)
Test for equality.
Definition: List.cpp:121
QWidget * widget()
Make new parameter widget.
Definition: List.h:80
Id type for classes An Id must only contain alpha numerical characters and must begin with a letter...
Definition: Id.h:34
GLuint textureId() const
List does not have a texture.
Definition: List.h:76
bool canHaveChildren() const
List can have children.
Definition: List.h:66
input::List InputList
Definition: List.h:134
List(Interface const *=nullptr)
Definition: List.cpp:29
Id getTypeId() const
Type id is "List".
Definition: List.h:49
Input List contains a list of inputs, accessible over an QString id Input List is the root input of ...
Definition: List.h:40
void clear()
Delete all inputs.
Definition: List.cpp:32
Input controller controls which inputs are currently active Implemented as a singleton.
Definition: Controller.h:31
QString currentId() const
Return ID of current input.
Definition: List.cpp:83
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
QSize size() const
List has no size.
Definition: List.h:71
void registerInFactory() const
A list cannot be registered in factory.
Definition: List.h:45
Input * operator[](QString const &_id)
Return input at index.
Definition: List.cpp:51
Generic input interface.
Definition: Interface.h:53
void removeInput(QString const &_id)
Remove input and reset current index if necessary.
Definition: List.cpp:43
Controller * controller()
Return pointer to controller.
Definition: List.cpp:112
QString generateId() const
Generate a new id for input.
Definition: List.cpp:139
std::pair< QString, Input * > addInput(Id const &_typeId)
Add new input with given type id. Returns nullptr if input with typeid does not exist Id is automati...
Definition: List.cpp:37
void toPropertyMap(PropertyMap &) const
Serialize to property map.
Definition: List.cpp:68
Input * current()
Returns pointer to current input Returns nullptr if currentIdx_ == -1 or input list is empty...
Definition: List.cpp:78
QString currentId_
Definition: List.h:130
void setCurrentId(QString const &)
Set current input by ID.
Definition: List.cpp:88
void fromPropertyMap(PropertyMap const &)
Deserialize from property map.
Definition: List.cpp:61