NAP
artnetevent.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // External Includes
8 #include <nap/event.h>
9 #include <cstdint>
10 #include <vector>
11 #include <memory>
12 #include <nap/numeric.h>
13 
14 namespace nap
15 {
20  class NAPAPI ArtNetEvent : public Event
21  {
22  RTTI_ENABLE(Event)
23  public:
24 
25  ArtNetEvent() = delete;
26 
34  ArtNetEvent(uint8 sequence, uint8 physical, uint16 portAddress);
35 
41  void setData(const uint8* data, size_t size);
42 
52  uint8 getSequence() const { return mSequence; };
53 
60  uint8 getPhysical() const { return mPhysical; };
61 
66  uint8 getNet() const { return mNet; };
67 
72  uint8 getSubNet() const { return mSubNet; };
73 
78  uint8 getUniverse() const { return mUniverse; };
79 
85  uint16 getPortAddress() const { return mPortAddress; };
86 
91  size_t getChannelCount() const { return mData.size(); };
92 
97  const uint8* getChannelData() const { return mData.data(); };
98 
104  uint8 getChannelByNumber(uint16 number) const { return getChannelByIndex(number - 1); };
105 
111  uint8 getChannelByIndex(uint16 index) const;
112 
118  uint8 operator[](uint16 index) { return getChannelByIndex(index); }
119 
125  const uint8 operator[](uint16 index) const { return getChannelByIndex(index); }
126 
127  private:
128 
129  uint8 mSequence;
130  uint8 mPhysical;
131  uint8 mNet;
132  uint8 mSubNet;
133  uint8 mUniverse;
134  uint16 mPortAddress;
135  std::vector<uint8> mData;
136  };
137 
138  using ArtNetEventPtr = std::unique_ptr<nap::ArtNetEvent>;
139 }
nap::ArtNetEvent::getUniverse
uint8 getUniverse() const
Definition: artnetevent.h:78
nap::uint8
uint8_t uint8
Definition: numeric.h:16
nap::ArtNetEvent::getChannelCount
size_t getChannelCount() const
Definition: artnetevent.h:91
nap::ArtNetEvent::getPortAddress
uint16 getPortAddress() const
Definition: artnetevent.h:85
nap::Event
Definition: event.h:17
nap::ArtNetEvent::getSequence
uint8 getSequence() const
Definition: artnetevent.h:52
nap::ArtNetEvent
Definition: artnetevent.h:20
nap::ArtNetEventPtr
std::unique_ptr< nap::ArtNetEvent > ArtNetEventPtr
Definition: artnetevent.h:138
nap::ArtNetEvent::operator[]
const uint8 operator[](uint16 index) const
Definition: artnetevent.h:125
nap::ArtNetEvent::getNet
uint8 getNet() const
Definition: artnetevent.h:66
nap::ArtNetEvent::getChannelByNumber
uint8 getChannelByNumber(uint16 number) const
Definition: artnetevent.h:104
nap::ArtNetEvent::getPhysical
uint8 getPhysical() const
Definition: artnetevent.h:60
nap::ArtNetEvent::getChannelData
const uint8 * getChannelData() const
Definition: artnetevent.h:97
nap::ArtNetEvent::getSubNet
uint8 getSubNet() const
Definition: artnetevent.h:72
nap::ArtNetEvent::operator[]
uint8 operator[](uint16 index)
Definition: artnetevent.h:118
nap
Definition: templateapp.h:17
nap::uint16
uint16_t uint16
Definition: numeric.h:18