-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathProduct.h
161 lines (132 loc) · 4.9 KB
/
Product.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef HEADER_OPENHOME_PRODUCT
#define HEADER_OPENHOME_PRODUCT
#include <OpenHome/OhNetTypes.h>
#include <OpenHome/Buffer.h>
#include <OpenHome/Net/Core/DvDevice.h>
#include <OpenHome/Private/Thread.h>
#include <OpenHome/Private/Timer.h>
//#include "DvAvOpenhomeOrgProduct1.h"
using namespace OpenHome::Net;
namespace Openhome {
namespace Av {
class ILockable
{
public:
virtual void Wait() = 0;
virtual void Signal() = 0;
virtual ~ILockable() {}
};
class IObserver
{
virtual void Changed() = 0;
virtual ~IObserver() {}
};
// This observable class is not thread safe on adding observers
class CObservable
{
public:
CObservable();
void Add(IObserver& aObserver);
protected:
void InformObservers() const;
private:
std::vector<IObserver*> iObserverList;
};
class IStandbyHandler
{
public:
virtual void SetStandby(TBool aValue) = 0;
virtual ~IStandbyHandler() {}
};
class ISourceIndexHandler
{
public:
virtual void SetSourceIndex(TUint aValue) = 0;
virtual ~ISourceIndexHandler() {}
};
class CSourceManager;
class CSource : public CObservable
{
friend class CSourceManager;
static const TUint kMaxTypeBytes = 20;
static const TUint kMaxNameBytes = 20;
public:
TBool Visible(Bwx& aSystemName, Bwx& aType, Bwx& aName);
void SetName(const Brx& aValue);
void SetVisible(const Brx& aValue);
void Add(IObserver& aObserver);
private:
void Wait();
void Signal();
CSource(const Brx& aSystemName, const Brx& aType, const Brx& aName, TBool aVisible, ILockable& aLockable);
private:
Bws<kMaxNameBytes) iSystemName;
Bws<kMaxTypeBytes) iType;
Bws<kMaxNameBytes) iName;
TBool iVisible;
ILockable& iLockable;
};
class CSourceManager : public CObservable, public IObserver, ILockable
{
public:
CSourceManager();
CSource& Create(const Brx& aSystemName, const Brx& aType, const Brx& aName, TBool aVisible);
TUint SourceCount() const;
CSource& Source(TUint aIndex);
private:
virtual void Changed();
void UpdateSourceXml();
private:
mutable Mutex iMutex;
std::vector<CSource*> iSourceList;
Bws<kMaxSourceXmlBytes> iSourceXml;
};
class CProduct : public OpenHome::Net::DvProviderAvOpenhomeOrgProduct1
{
static const TUint kMaxRoomBytes = 20;
static const TUint kMaxNameBytes = 20;
public:
CProduct(DvDevice& aDevice
, IStandbyHandler& aStandbyHandler
, ISourceIndexHandler& aSourceIndexHandler
, TBool aStandby
, const TChar* aAtrributes
, const TChar* aManufacturerName
, const TChar* aManufacturerInfo
, const TChar* aManufacturerUrl
, const TChar* aManufacturerImageUri
, const TChar* aModelName
, const TChar* aModelInfo
, const TChar* aModelUrl
, const TChar* aModelImageUri
, const TChar* aProductRoom
, const TChar* aProductName
, const TChar* aProductInfo
, const TChar* aProductUrl
, const TChar* aProductImageUri);
void SetRoom(const Brx& aRoom);
void SetName(const Brx& aName);
void SetStandby(TBool aStandby);
private:
virtual void Manufacturer(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseString& aName, IInvocationResponseString& aInfo, IInvocationResponseString& aUrl, IInvocationResponseString& aImageUri);
virtual void Model(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseString& aName, IInvocationResponseString& aInfo, IInvocationResponseString& aUrl, IInvocationResponseString& aImageUri);
virtual void Product(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseString& aRoom, IInvocationResponseString& aName, IInvocationResponseString& aInfo, IInvocationResponseString& aUrl, IInvocationResponseString& aImageUri);
virtual void Standby(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseBool& aValue);
virtual void SetStandby(IInvocationResponse& aResponse, TUint aVersion, TBool aValue);
virtual void SourceCount(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseUint& aValue);
virtual void SourceXml(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseString& aValue);
virtual void SourceIndex(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseUint& aValue);
virtual void SetSourceIndex(IInvocationResponse& aResponse, TUint aVersion, TUint aValue);
virtual void SetSourceIndexByName(IInvocationResponse& aResponse, TUint aVersion, const Brx& aValue);
virtual void Source(IInvocationResponse& aResponse, TUint aVersion, TUint aIndex, IInvocationResponseString& aSystemName, IInvocationResponseString& aType, IInvocationResponseString& aName, IInvocationResponseBool& aVisible);
virtual void Attributes(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseString& aValue);
virtual void SourceXmlChangeCount(IInvocationResponse& aResponse, TUint aVersion, IInvocationResponseUint& aValue);
private:
IStandbyHandler& iStandbyHandler;
ISourceIndexHandler& iSourceIndexHandler;
TUint iSourceXmlChangeCount;
mutable Mutex iMutex;
};
} // namespace Av
} // namespace Openhome
#endif // HEADER_OPENHOME_PRODUCT