Open Lighting Architecture  0.9.0
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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(HeaderSet *headers,
39  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  (void) data;
46  (void) headers;
47  }
48 };
49 
50 
51 class RootInflator: public BaseInflator {
52  public:
54 
58  explicit RootInflator(OnDataCallback *on_data = NULL)
59  : BaseInflator(),
60  m_on_data(on_data) {
61  AddInflator(&m_null_inflator);
62  }
63 
64  uint32_t Id() const { return 0; } // no effect for the root inflator
65 
66  protected:
67  // Decode a header block and adds any PduHeaders to the HeaderSet object
68  bool DecodeHeader(HeaderSet *headers, const uint8_t *data,
69  unsigned int len, unsigned int *bytes_used);
70 
71  void ResetHeaderField();
72  bool PostHeader(uint32_t vector, const HeaderSet &headers);
73 
74  private :
75  NullInflator m_null_inflator;
76  RootHeader m_last_hdr;
77  std::auto_ptr<OnDataCallback> m_on_data;
78 };
79 } // namespace e131
80 } // namespace plugin
81 } // namespace ola
82 #endif // PLUGINS_E131_E131_ROOTINFLATOR_H_