Open Lighting Architecture: libs/acn/RootInflator.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
RootInflator.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 * RootInflator.h
17 * Interface for the RootInflator class.
18 * Copyright (C) 2009 Simon Newton
19 */
20
21#ifndef LIBS_ACN_ROOTINFLATOR_H_
22#define LIBS_ACN_ROOTINFLATOR_H_
23
24#include <ola/Callback.h>
25#include <ola/Logging.h>
26#include <memory>
27#include "ola/acn/ACNVectors.h"
28#include "libs/acn/BaseInflator.h"
29
30namespace ola {
31namespace acn {
32
33 class NullInflator : public InflatorInterface {
34 public:
35 uint32_t Id() const { return ola::acn::VECTOR_ROOT_NULL; }
36
37 unsigned int InflatePDUBlock(OLA_UNUSED HeaderSet *headers,
38 OLA_UNUSED const uint8_t *data,
39 unsigned int len) {
40 if (len) {
41 OLA_WARN << "VECTOR_ROOT_NULL contained data of size " << len;
42 }
43 return 0;
44 }
45};
46
47
48 class RootInflator: public BaseInflator {
49 public:
50 typedef ola::Callback1<void, const TransportHeader&> OnDataCallback;
51
55 explicit RootInflator(OnDataCallback *on_data = NULL)
56 : BaseInflator(),
57 m_on_data(on_data) {
58 AddInflator(&m_null_inflator);
59 }
60
61 uint32_t Id() const { return 0; } // no effect for the root inflator
62
63 protected:
64 // Decode a header block and adds any PduHeaders to the HeaderSet object
65 bool DecodeHeader(HeaderSet *headers, const uint8_t *data,
66 unsigned int len, unsigned int *bytes_used);
67
68 void ResetHeaderField();
69 bool PostHeader(uint32_t vector, const HeaderSet &headers);
70
71 private :
72 NullInflator m_null_inflator;
73 RootHeader m_last_hdr;
74 std::auto_ptr<OnDataCallback> m_on_data;
75};
76} // namespace acn
77} // namespace ola
78#endif // LIBS_ACN_ROOTINFLATOR_H_
ACNVectors.h
ACN Vector values.
Callback.h
Logging.h
Header file for OLA Logging.
OLA_UNUSED
#define OLA_UNUSED
Mark unused arguments & types.
Definition Macro.h:63
ola::Callback1
A 1 argument callback which can be called multiple times.
Definition Callback.h:992
ola::acn::HeaderSet
Definition HeaderSet.h:35
ola::acn::InflatorInterface
Definition BaseInflator.h:42
ola::acn::NullInflator
Definition RootInflator.h:33
ola::acn::RootInflator::RootInflator
RootInflator(OnDataCallback *on_data=NULL)
Definition RootInflator.h:55
ola::acn::RootInflator::PostHeader
bool PostHeader(uint32_t vector, const HeaderSet &headers)
Definition RootInflator.cpp:73
ola::acn::VECTOR_ROOT_NULL
@ VECTOR_ROOT_NULL
Definition ACNVectors.h:49
OLA_WARN
#define OLA_WARN
Definition Logging.h:73
ola::acn
ACN related code.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44