use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Wed Jun 15 20:51:13 2016 +0000
Revision:
45:db754b994deb
Parent:
27:b8aaf7dc7023
updates to instance number reporting

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 27:b8aaf7dc7023 1 /**
ansond 27:b8aaf7dc7023 2 * @file ObjectInstanceManager.h
ansond 27:b8aaf7dc7023 3 * @brief mbed CoAP Endpoint Device Management Object Instance Manager (header)
ansond 27:b8aaf7dc7023 4 * @author Doug Anson
ansond 27:b8aaf7dc7023 5 * @version 1.0
ansond 27:b8aaf7dc7023 6 * @see
ansond 27:b8aaf7dc7023 7 *
ansond 27:b8aaf7dc7023 8 * Copyright (c) 2016
ansond 27:b8aaf7dc7023 9 *
ansond 27:b8aaf7dc7023 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 27:b8aaf7dc7023 11 * you may not use this file except in compliance with the License.
ansond 27:b8aaf7dc7023 12 * You may obtain a copy of the License at
ansond 27:b8aaf7dc7023 13 *
ansond 27:b8aaf7dc7023 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 27:b8aaf7dc7023 15 *
ansond 27:b8aaf7dc7023 16 * Unless required by applicable law or agreed to in writing, software
ansond 27:b8aaf7dc7023 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 27:b8aaf7dc7023 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 27:b8aaf7dc7023 19 * See the License for the specific language governing permissions and
ansond 27:b8aaf7dc7023 20 * limitations under the License.
ansond 27:b8aaf7dc7023 21 */
ansond 27:b8aaf7dc7023 22
ansond 27:b8aaf7dc7023 23 #ifndef __OBJECT_INSTANCE_MANAGER_H__
ansond 27:b8aaf7dc7023 24 #define __OBJECT_INSTANCE_MANAGER_H__
ansond 27:b8aaf7dc7023 25
ansond 27:b8aaf7dc7023 26 // Logger
ansond 27:b8aaf7dc7023 27 #include "mbed-connector-interface/Logger.h"
ansond 27:b8aaf7dc7023 28
ansond 27:b8aaf7dc7023 29 // Named Pointer List
ansond 27:b8aaf7dc7023 30 #include "mbed-connector-interface/NamedPointer.h"
ansond 27:b8aaf7dc7023 31
ansond 27:b8aaf7dc7023 32 // Resources list
ansond 27:b8aaf7dc7023 33 #include <vector>
ansond 27:b8aaf7dc7023 34 typedef vector<NamedPointer> NamedPointerList;
ansond 27:b8aaf7dc7023 35
ansond 27:b8aaf7dc7023 36 class ObjectInstanceManager {
ansond 27:b8aaf7dc7023 37 public:
ansond 27:b8aaf7dc7023 38 /**
ansond 27:b8aaf7dc7023 39 Default constructor
ansond 27:b8aaf7dc7023 40 @param logger input logger instance
ansond 27:b8aaf7dc7023 41 @param ep input the Endpoint instance
ansond 27:b8aaf7dc7023 42 */
ansond 27:b8aaf7dc7023 43 ObjectInstanceManager(const Logger *logger,const void *ep);
ansond 27:b8aaf7dc7023 44
ansond 27:b8aaf7dc7023 45 /**
ansond 27:b8aaf7dc7023 46 Copy constructor
ansond 27:b8aaf7dc7023 47 @param resource input the ObjectInstanceManager that is to be deep copied
ansond 27:b8aaf7dc7023 48 */
ansond 27:b8aaf7dc7023 49 ObjectInstanceManager(const ObjectInstanceManager &manager);
ansond 27:b8aaf7dc7023 50
ansond 27:b8aaf7dc7023 51 /**
ansond 27:b8aaf7dc7023 52 Destructor
ansond 27:b8aaf7dc7023 53 */
ansond 27:b8aaf7dc7023 54 virtual ~ObjectInstanceManager();
ansond 27:b8aaf7dc7023 55
ansond 27:b8aaf7dc7023 56 /**
ansond 27:b8aaf7dc7023 57 Create DynamicResourceInstance
ansond 27:b8aaf7dc7023 58 @param objID input the Object ID to parent this new resource instance under
ansond 27:b8aaf7dc7023 59 @param resID input the Resource ID for this resource
ansond 27:b8aaf7dc7023 60 @param resName input the Resource Name
ansond 27:b8aaf7dc7023 61 @param resType input the type of Resource (cast from Resource::ResourceType)
ansond 27:b8aaf7dc7023 62 @param observable input whether this Resource is observable or not
ansond 27:b8aaf7dc7023 63 */
ansond 27:b8aaf7dc7023 64 void *createDynamicResourceInstance(char *objID,char *resID,char *resName,int resType,bool observable);
ansond 27:b8aaf7dc7023 65
ansond 27:b8aaf7dc7023 66 /**
ansond 27:b8aaf7dc7023 67 Create StaticResourceInstance
ansond 27:b8aaf7dc7023 68 @param objID input the Object ID to parent this new resource instance under
ansond 27:b8aaf7dc7023 69 @param resID input the Resource ID for this resource
ansond 27:b8aaf7dc7023 70 @param resName input the Resource Name
ansond 27:b8aaf7dc7023 71 @param resType input the type of Resource (cast from Resource::ResourceType)
ansond 27:b8aaf7dc7023 72 @param observable input whether this Resource is observable or not
ansond 27:b8aaf7dc7023 73 */
ansond 27:b8aaf7dc7023 74 void *createStaticResourceInstance(char *objID,char *resID,char *resName,int resType,void *data,int data_length);
ansond 27:b8aaf7dc7023 75
ansond 27:b8aaf7dc7023 76 /**
ansond 27:b8aaf7dc7023 77 Get our Object List
ansond 27:b8aaf7dc7023 78 */
ansond 27:b8aaf7dc7023 79 NamedPointerList getObjectList();
ansond 45:db754b994deb 80
ansond 45:db754b994deb 81 /**
ansond 45:db754b994deb 82 Get the instance number of the just-created ResourceInstance
ansond 45:db754b994deb 83 */
ansond 45:db754b994deb 84 int getLastCreatedInstanceNumber();
ansond 27:b8aaf7dc7023 85
ansond 27:b8aaf7dc7023 86 protected:
ansond 27:b8aaf7dc7023 87 Logger *m_logger;
ansond 27:b8aaf7dc7023 88 void *m_ep;
ansond 27:b8aaf7dc7023 89 NamedPointerList m_object_list;
ansond 45:db754b994deb 90 int m_instance_number;
ansond 27:b8aaf7dc7023 91
ansond 27:b8aaf7dc7023 92 private:
ansond 27:b8aaf7dc7023 93 // Generic Static and Dynamic Resource Instances/Objects
ansond 27:b8aaf7dc7023 94 void *getOrCreateInstance(char *objID,char *resID);
ansond 27:b8aaf7dc7023 95 NamedPointer *getOrCreateObject(char *objID);
ansond 27:b8aaf7dc7023 96
ansond 27:b8aaf7dc7023 97 // Underlying lookup support
ansond 27:b8aaf7dc7023 98 NamedPointer *getNamedPointer(const char *id,NamedPointerList *list);
ansond 27:b8aaf7dc7023 99
ansond 27:b8aaf7dc7023 100 // Logger
ansond 27:b8aaf7dc7023 101 Logger *logger();
ansond 27:b8aaf7dc7023 102 };
ansond 27:b8aaf7dc7023 103
ansond 27:b8aaf7dc7023 104 #endif // __OBJECT_INSTANCE_MANAGER_H__