Merge test folder of test branch
[iotivity.git] / test / src / iBtestapp / modules / sm / c_cpp / include / SMRemoteOperations.h
1 /******************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 #ifndef INCLUDE_SM_REMOTE_OPERATIONS
22 #define INCLUDE_SM_REMOTE_OPERATIONS
23
24 #include <iostream>
25 #include <string>
26 #include <map>
27 #include <utility>
28 #include <vector>
29 #include <mutex>
30
31 #include "RemoteScene.h"
32 #include "RemoteSceneAction.h"
33 #include "RemoteSceneCollection.h"
34 #include "RemoteSceneList.h"
35
36 #include "RCSDiscoveryManager.h"
37 #include "RCSRemoteResourceObject.h"
38 #include "RCSResourceAttributes.h"
39 #include "RCSResourceObject.h"
40 #include "RCSAddress.h"
41 #include "OCPlatform.h"
42 #include "SMLocalOperations.h"
43
44 #define MAX_SLEEP_TIME 5
45 #define CALLBACK_WAIT_MAX 10
46 #define CALLBACK_WAIT_DEFAULT 5
47 #define CALLBACK_WAIT_MIN 1
48 #define INT_ZERO 0
49 #define INT_ONE 1
50 #define INT_TWO 2
51 #define EMPTY_STRING ""
52 #define NULL_PTR nullptr
53
54 constexpr char SPEED_THIRTY[]
55 { "30" };
56
57 using namespace std;
58 using namespace OIC::Service;
59 using namespace OC;
60 namespace PH = std::placeholders;
61
62 class SMRemoteOperations
63 {
64 private:
65     static SMRemoteOperations* s_smRemoteOperationsInstance;
66     static std::mutex s_mutex;
67
68 public:
69     RCSRemoteResourceObject::Ptr m_pFoundSceneList;
70     RCSRemoteResourceObject::Ptr m_pFoundLightResource;
71     RCSRemoteResourceObject::Ptr m_pFoundFanResource;
72     std::unique_ptr< RCSDiscoveryManager::DiscoveryTask > m_discoveryTask;
73     const std::string m_relativetUri;
74     const std::vector< std::string > m_resourceTypes;
75     std::vector< RCSRemoteResourceObject::Ptr > m_foundResourceList;
76     std::shared_ptr< RemoteSceneList > m_pRemoteSceneList;
77     std::shared_ptr< RemoteSceneCollection > m_pRemoteSceneCollection;
78     RemoteScene::Ptr m_pRemoteScene;
79     RemoteSceneAction::Ptr m_pRemoteSceneAction;
80     std::shared_ptr< RCSRemoteResourceObject > m_pRemoteResource1;
81     std::shared_ptr< RCSRemoteResourceObject > m_pRemoteResource2;bool m_isCallback;bool m_isRemoteSceneCreated;
82
83     SMRemoteOperations();
84     static SMRemoteOperations* getInstance(void);
85     void discoverResource();
86     void onRemoteResourceDiscovered(std::shared_ptr< RCSRemoteResourceObject > foundResource);
87     void stopDiscovery();
88     std::shared_ptr< RemoteSceneList > createRemoteSceneListInstance();
89     void onRemoteSceneListCreated(RemoteSceneList::Ptr remoteSceneList, int eCode);
90     void onRemoteSceneCollectionCreated(RemoteSceneCollection::Ptr remoteSceneCol, int);
91     void onRemoteSceneCreated(RemoteScene::Ptr remoteScene, int);
92     void onRemoteSceneActionCreated(RemoteSceneAction::Ptr remoteSceneAction, int);
93     void onRemoteSceneExecuted(string, int);bool initializeRemote();
94     void executeCreatedLocalSceneFromRemoteEnd();
95     void createRemoteScene();
96     void executeRemoteScene();
97 };
98
99 #endif