Remove unused pkg dependancy
[platform/upstream/iotivity.git] / resource / examples / winuiclient.h
1 /* ****************************************************************
2  *
3  * Copyright 2016 Intel Corporation All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  ******************************************************************/
18
19 #ifndef WINUICLIENT_H_
20 #define WINUICLIENT_H_
21
22 #include <memory>
23 #include <mutex>
24 #include <map>
25 #include "OCPlatform.h"
26 #include "OCApi.h"
27 #include "OCResource.h"
28
29 using namespace OC;
30 namespace WinUIClient{
31
32     class Media
33     {
34         public:
35
36             bool m_state;
37             int m_volume;
38             std::string m_name;
39
40             Media() : m_state(false), m_volume(0), m_name("")
41             {
42             }
43     };
44
45     class WinUIClientApp
46     {
47         public:
48             WinUIClientApp(OCPersistentStorage ps);
49             ~WinUIClientApp();
50
51             void Initialize();
52             void Run();
53             void FindResources();
54             void GetMediaRepresentation();
55             void PutMediaRepresentation();
56             void PostMediaRepresentation();
57             void BeginObserving();
58             void CancelObserving();
59
60             std::shared_ptr<OCResource> GetResource();
61             Media GetMedia(){return mymedia;}
62             void SetMedia(bool state, int volume){mymedia.m_state = state; mymedia.m_volume=volume;}
63             bool observing;
64
65         private:
66             void foundResource(std::shared_ptr<OCResource> resource);
67             void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode);
68             void onPut(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode);
69             void onPost(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode);
70             void onPost2(const HeaderOptions& /*headerOptions*/,const OCRepresentation& rep, const int eCode);
71             void onObserve(const HeaderOptions /*headerOptions*/, const OCRepresentation& rep, const int& eCode, const int& sequenceNumber);
72         private:
73             int observe_count();
74
75         private:
76             typedef std::map<OCResourceIdentifier, std::shared_ptr<OCResource>> DiscoveredResourceMap;
77
78             OCPersistentStorage persistentStorage;
79             Media mymedia;
80             DiscoveredResourceMap discoveredResources;
81             std::shared_ptr<OCResource> curResource;
82             ObserveType OBSERVE_TYPE_TO_USE;
83             std::mutex curResourceLock;
84     };
85
86 }
87
88 #endif
89