Open Lighting Architecture  Latest Git
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 
30 namespace ola {
31 namespace acn {
32 
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:
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_
Definition: HeaderSet.h:35
The inflator interface.
Definition: BaseInflator.h:42
An abstract PDU inflator.
Definition: BaseInflator.h:64
ACN Vector values.
uint32_t Id() const
Definition: RootInflator.h:35
#define OLA_WARN
Definition: Logging.h:75
Definition: RootInflator.h:33
#define OLA_UNUSED
Mark unused arguments & types.
Definition: Macro.h:62
Definition: RootInflator.h:48
unsigned int InflatePDUBlock(HeaderSet *headers, const uint8_t *data, unsigned int len)
Parse a block of PDU data.
Definition: RootInflator.h:37
uint32_t Id() const
Definition: RootInflator.h:61
Definition: ACNVectors.h:49
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: RootHeader.h:32
RootInflator(OnDataCallback *on_data=NULL)
Definition: RootInflator.h:55
Header file for OLA Logging.
A 1 argument callback which can be called multiple times.
Definition: Callback.h:992