Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CIDImpl.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  * CIDImpl.h
17  * The actual implementation of a CID. The implementation changes based on
18  * which uuid library is installed.
19  * Copyright (C) 2007 Simon Newton
20  */
21 
22 #ifndef PLUGINS_E131_E131_CIDIMPL_H_
23 #define PLUGINS_E131_E131_CIDIMPL_H_
24 
25 #if HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 
29 #include <stdint.h>
30 
31 #ifdef HAVE_OSSP_UUID_H
32 #include <ossp/uuid.h>
33 #else
34 #ifdef HAVE_UUID_UUID_H
35 #include <uuid/uuid.h>
36 #else
37 #include <uuid.h>
38 #endif
39 #endif
40 
41 #include <iostream>
42 #include <string>
43 
44 #include "ola/io/OutputBuffer.h"
45 
46 namespace ola {
47 namespace acn {
48 
49 class CIDImpl {
50  public :
51  enum { CIDImpl_LENGTH = 16 };
52 
53  CIDImpl();
54  CIDImpl(const CIDImpl& other);
55  ~CIDImpl();
56 
57  bool IsNil() const;
58  void Pack(uint8_t *buf) const;
59  std::string ToString() const;
60  void Write(ola::io::OutputBufferInterface *output) const;
61 
62  CIDImpl& operator=(const CIDImpl& c1);
63  bool operator==(const CIDImpl& c1) const;
64  bool operator!=(const CIDImpl& c1) const;
65 
66  static CIDImpl* Generate();
67  static CIDImpl* FromData(const uint8_t *data);
68  static CIDImpl* FromString(const std::string &cid);
69 
70  private:
71 #ifdef USE_OSSP_UUID
72  uuid_t *m_uuid;
73  explicit CIDImpl(uuid_t *uuid);
74 #else
75  uuid_t m_uuid;
76  explicit CIDImpl(uuid_t uuid);
77 #endif
78 };
79 } // namespace acn
80 } // namespace ola
81 #endif // PLUGINS_E131_E131_CIDIMPL_H_