Open Lighting Architecture
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * PortManager.h
17  * Provides a unified interface for controlling port patchings & priorities.
18  * Copyright (C) 2005-2010 Simon Newton
19  */
20 
21 #ifndef OLAD_PORTMANAGER_H_
22 #define OLAD_PORTMANAGER_H_
23 
24 #include <string>
25 #include <vector>
26 #include "olad/Device.h"
27 #include "olad/DeviceManager.h"
28 #include "olad/PortBroker.h"
29 #include "olad/UniverseStore.h"
30 
31 
32 namespace ola {
33 
34 class PortManager {
35  public:
36  explicit PortManager(UniverseStore *universe_store,
37  PortBroker *broker)
38  : m_universe_store(universe_store),
39  m_broker(broker) {
40  }
41  ~PortManager() {}
42 
43  bool PatchPort(InputPort *port, unsigned int universe);
44  bool PatchPort(OutputPort *port, unsigned int universe);
45  bool UnPatchPort(InputPort *port);
46  bool UnPatchPort(OutputPort *port);
47 
48  bool SetPriorityInherit(Port *port);
49  bool SetPriorityOverride(Port *port, uint8_t value);
50 
51  private:
52  PortManager(const PortManager&);
53  PortManager& operator=(const PortManager&);
54 
55  template<class PortClass>
56  bool GenericPatchPort(PortClass *port,
57  unsigned int new_universe_id);
58 
59  template<class PortClass>
60  bool GenericUnPatchPort(PortClass *port);
61 
62  template<class PortClass>
63  bool CheckLooping(const AbstractDevice *device,
64  unsigned int new_universe_id) const;
65 
66  template<class PortClass>
67  bool CheckMultiPort(const AbstractDevice *device,
68  unsigned int new_universe_id) const;
69 
70  bool CheckInputPortsForUniverse(const AbstractDevice *device,
71  unsigned int universe_id) const;
72  bool CheckOutputPortsForUniverse(const AbstractDevice *device,
73  unsigned int universe_id) const;
74 
75  template<class PortClass>
76  bool CheckForPortMatchingUniverse(const vector<PortClass*> &ports,
77  unsigned int universe_id) const;
78 
79  UniverseStore * const m_universe_store;
80  PortBroker *m_broker;
81 };
82 } // namespace ola
83 #endif // OLAD_PORTMANAGER_H_