Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PortManager.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * PortManager.h
17  * Provides a unified interface for controlling port patchings & priorities.
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef OLAD_PORTMANAGER_H_
22 #define OLAD_PORTMANAGER_H_
23 
24 #include <vector>
25 #include "olad/Device.h"
26 #include "olad/DeviceManager.h"
27 #include "olad/PortBroker.h"
28 #include "olad/UniverseStore.h"
29 #include "ola/base/Macro.h"
30 
31 
32 namespace ola {
33 
37 class PortManager {
38  public:
44  PortManager(UniverseStore *universe_store,
45  PortBroker *broker)
46  : m_universe_store(universe_store),
47  m_broker(broker) {
48  }
49 
54 
61  bool PatchPort(InputPort *port, unsigned int universe);
62 
69  bool PatchPort(OutputPort *port, unsigned int universe);
70 
76  bool UnPatchPort(InputPort *port);
77 
83  bool UnPatchPort(OutputPort *port);
84 
89  bool SetPriorityInherit(Port *port);
90 
96  bool SetPriorityStatic(Port *port, uint8_t value);
97 
98  private:
99  template<class PortClass>
100  bool GenericPatchPort(PortClass *port,
101  unsigned int new_universe_id);
102 
103  template<class PortClass>
104  bool GenericUnPatchPort(PortClass *port);
105 
106  template<class PortClass>
107  bool CheckLooping(const AbstractDevice *device,
108  unsigned int new_universe_id) const;
109 
110  template<class PortClass>
111  bool CheckMultiPort(const AbstractDevice *device,
112  unsigned int new_universe_id) const;
113 
118  bool CheckInputPortsForUniverse(const AbstractDevice *device,
119  unsigned int universe_id) const;
120 
125  bool CheckOutputPortsForUniverse(const AbstractDevice *device,
126  unsigned int universe_id) const;
127 
132  template<class PortClass>
133  bool CheckForPortMatchingUniverse(const std::vector<PortClass*> &ports,
134  unsigned int universe_id) const;
135 
136  UniverseStore * const m_universe_store;
137  PortBroker *m_broker;
138 
139  DISALLOW_COPY_AND_ASSIGN(PortManager);
140 };
141 } // namespace ola
142 #endif // OLAD_PORTMANAGER_H_