Initial merge-commit of the OIC code. Should successfully do discovery for single...
[platform/upstream/iotivity.git] / csdk / ubstack / include / ocinternalapi.h
1 //******************************************************************
2 ///
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
5
6 #ifndef INTERNALUBAPI_H_
7 #define INTERNALUBAPI_H_
8
9 // ============================================================================
10 // Includes
11 // ============================================================================
12 #include <memory>
13 #include <functional>
14 #include <string>
15 #include <list>
16 #include <stdint.h>
17 #include "occore.h"
18
19 // ============================================================================
20 // Namespace
21 // ============================================================================
22 namespace oc {
23 namespace ub {
24
25
26 // ============================================================================
27 // Class
28 // ============================================================================
29 class OCDiscoverServicesResult {
30         // ============================================================
31         // Destructor
32         // ============================================================
33         public:
34                 virtual ~OCDiscoverServicesResult() {}
35
36         // ============================================================
37         // Public Method(s)
38         // ============================================================
39         public:
40                 virtual OCQueryResultType getResult() const = 0;
41                 virtual const std::list<std::string>& getServiceList() const = 0;
42 };
43
44 typedef std::function<void (const OCDiscoverServicesResult&)> OCDiscoverServicesFunction;
45
46 // ============================================================================
47 // Class
48 // ============================================================================
49 class OCModel : public std::enable_shared_from_this<OCModel> {
50         // ============================================================
51         // Type Definition(s)
52         // ============================================================
53         public:
54                 typedef std::shared_ptr<OCModel> SharedPtr;
55                 typedef std::weak_ptr<OCModel> WeakPtr;
56
57         // ============================================================
58         // Factory
59         // ============================================================
60         public:
61                 static SharedPtr createModel();
62
63         // ============================================================
64         // Destructor
65         // ============================================================
66         public:
67                 virtual ~OCModel() {}
68
69         // ============================================================
70         // Public Method(s)
71         // ============================================================
72         public:
73                 /**
74                  * Start the OC Stack.
75                  *
76                  * @param ipAddr
77                  *     IP Address of host device
78                  * @param port
79                  *     Port of host device
80                  * @param mode
81                  *     Host device is client, server, or client-server
82                  *
83                  * @return
84                  *     true  - successfully started the OC Stack
85                  *     false - error starting the OC Stack
86                  */
87                 virtual bool start(const std::string ipAddr, int16_t port, OCStackMode mode) = 0;
88
89                 /**
90                  * Get all services that have been discovered at time of call
91                  *
92                  * @param asyncReturnFunc - asynchronous callback function that is invoked
93                  *                          by the OCModel when service discovery
94                  *                          is complete.  The callback will include
95                  *                          status and a list of all discovered services
96                  */
97                 virtual void discoverServices(OCDiscoverServicesFunction& asyncReturnFunc) = 0;
98
99                 /**
100                  * Add a service to the OCModel
101                  *
102                  * @param url
103                  *     URL of the service
104                  *
105                  * @return
106                  *     Total number of services in the OCModel
107                  */
108                 virtual uint16_t addService(const std::string url) = 0;
109
110 };
111
112
113 }
114 }
115
116 #endif /* INTERNALUBAPI_H_ */