Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 PLUGINS_E131_E131_ROOTINFLATOR_H_
22 #define PLUGINS_E131_E131_ROOTINFLATOR_H_
23 
24 #include <ola/Callback.h>
25 #include <ola/Logging.h>
26 #include <memory>
27 #include "ola/acn/ACNVectors.h"
28 #include "plugins/e131/e131/BaseInflator.h"
29 
30 namespace ola {
31 namespace plugin {
32 namespace e131 {
33 
35  public:
36  uint32_t Id() const { return ola::acn::VECTOR_ROOT_NULL; }
37 
38  unsigned int InflatePDUBlock(OLA_UNUSED HeaderSet *headers,
39  OLA_UNUSED const uint8_t *data,
40  unsigned int len) {
41  if (len) {
42  OLA_WARN << "VECTOR_ROOT_NULL contained data of size " << len;
43  }
44  return 0;
45  }
46 };
47 
48 
49 class RootInflator: public BaseInflator {
50  public:
52 
56  explicit RootInflator(OnDataCallback *on_data = NULL)
57  : BaseInflator(),
58  m_on_data(on_data) {
59  AddInflator(&m_null_inflator);
60  }
61 
62  uint32_t Id() const { return 0; } // no effect for the root inflator
63 
64  protected:
65  // Decode a header block and adds any PduHeaders to the HeaderSet object
66  bool DecodeHeader(HeaderSet *headers, const uint8_t *data,
67  unsigned int len, unsigned int *bytes_used);
68 
69  void ResetHeaderField();
70  bool PostHeader(uint32_t vector, const HeaderSet &headers);
71 
72  private :
73  NullInflator m_null_inflator;
74  RootHeader m_last_hdr;
75  std::auto_ptr<OnDataCallback> m_on_data;
76 };
77 } // namespace e131
78 } // namespace plugin
79 } // namespace ola
80 #endif // PLUGINS_E131_E131_ROOTINFLATOR_H_