1 //******************************************************************
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
10 // ============================================================================
12 // ============================================================================
17 #include "ocinternalapi.h"
22 // ============================================================================
24 // ============================================================================
28 class OCModelImpl : public OCModel {
30 typedef std::shared_ptr<OCModelImpl> SharedPtr;
31 typedef std::weak_ptr<OCModelImpl> WeakPtr;
35 * Factory pattern to create a OCModel singleton
36 * @return Shared pointer to the OCModel
38 static SharedPtr createModel();
49 virtual ~OCModelImpl();
55 * IP Address of host device
57 * Port of host device*
59 * Host device is client, server, or client-server
62 * true - successfully started the OC Stack
63 * false - error starting the OC Stack
65 virtual bool start(const std::string ipAddr, int16_t port, OCStackMode mode);
68 * Get all services that have been discovered at time of call
70 * @param asyncReturnFunc - asynchronous callback function that is invoked
71 * by the OCModelImpl when service discovery
72 * is complete. The callback will include
73 * status and a list of all discovered services
75 virtual void discoverServices(OCDiscoverServicesFunction& asyncReturnFunc);
78 * Add a service to the OCModelImpl
80 * @param url - URL of the service
81 * @return Total number of services in the OCModelImpl
83 virtual uint16_t addService(const std::string url);
86 typedef std::list<std::string> ServiceList;
90 * Internal methods that invokes the client callback (if it was previously set via discoverServices)
91 * Called when a new service is discovered.
93 virtual void invokeDiscoverCallback();
96 * Asynchronous callback friend function invoked by the OC Stack upon service discovery
98 * @param result - OC stack result
99 * @param representation - handle to the representation of the resource
101 friend void asyncDoResourcesCallback(OCStackResult result, OCRepresentationHandle representation);
103 ServiceList serviceList;
104 mutex serviceListMutex;
105 OCDiscoverServicesFunction discoverCallback;
110 #endif /* OCMODELIMPL_H_ */