mbed Connector Endpoint interface. This interface permits a mbed endpoint to easily setup MDS resources and emit those resources to an MDS server.

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Committer:
ansond
Date:
Tue Jan 27 22:23:51 2015 +0000
Revision:
0:b438482ebbfc
Child:
2:853f9ecc12df
initial check in

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:b438482ebbfc 1 /**
ansond 0:b438482ebbfc 2 * @file InstancePointerTable.h
ansond 0:b438482ebbfc 3 * @brief instance pointer table header
ansond 0:b438482ebbfc 4 * @author Doug Anson/Chris Paola
ansond 0:b438482ebbfc 5 * @version 1.0
ansond 0:b438482ebbfc 6 * @see
ansond 0:b438482ebbfc 7 *
ansond 0:b438482ebbfc 8 * Copyright (c) 2014
ansond 0:b438482ebbfc 9 *
ansond 0:b438482ebbfc 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 0:b438482ebbfc 11 * you may not use this file except in compliance with the License.
ansond 0:b438482ebbfc 12 * You may obtain a copy of the License at
ansond 0:b438482ebbfc 13 *
ansond 0:b438482ebbfc 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 0:b438482ebbfc 15 *
ansond 0:b438482ebbfc 16 * Unless required by applicable law or agreed to in writing, software
ansond 0:b438482ebbfc 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 0:b438482ebbfc 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 0:b438482ebbfc 19 * See the License for the specific language governing permissions and
ansond 0:b438482ebbfc 20 * limitations under the License.
ansond 0:b438482ebbfc 21 */
ansond 0:b438482ebbfc 22
ansond 0:b438482ebbfc 23 #ifndef __INSTANCE_POINTER_TABLE_H__
ansond 0:b438482ebbfc 24 #define __INSTANCE_POINTER_TABLE_H__
ansond 0:b438482ebbfc 25
ansond 0:b438482ebbfc 26 // Logger support
ansond 0:b438482ebbfc 27 #include "Logger.h"
ansond 0:b438482ebbfc 28
ansond 0:b438482ebbfc 29 // string support
ansond 0:b438482ebbfc 30 #include <string>
ansond 0:b438482ebbfc 31
ansond 0:b438482ebbfc 32 // Configuration
ansond 0:b438482ebbfc 33 #include "mbedConnectorInterface.h"
ansond 0:b438482ebbfc 34
ansond 0:b438482ebbfc 35 // our table row structure
ansond 0:b438482ebbfc 36 typedef struct {
ansond 0:b438482ebbfc 37 string key;
ansond 0:b438482ebbfc 38 void *instance;
ansond 0:b438482ebbfc 39 } InstancePointerTableRow;
ansond 0:b438482ebbfc 40
ansond 0:b438482ebbfc 41 class InstancePointerTable {
ansond 0:b438482ebbfc 42 public:
ansond 0:b438482ebbfc 43 /**
ansond 0:b438482ebbfc 44 Default constructor
ansond 0:b438482ebbfc 45 @param logger input the logger instance
ansond 0:b438482ebbfc 46 */
ansond 0:b438482ebbfc 47 InstancePointerTable(const Logger *logger = NULL);
ansond 0:b438482ebbfc 48
ansond 0:b438482ebbfc 49 /**
ansond 0:b438482ebbfc 50 Destructor
ansond 0:b438482ebbfc 51 */
ansond 0:b438482ebbfc 52 virtual ~InstancePointerTable();
ansond 0:b438482ebbfc 53
ansond 0:b438482ebbfc 54 /**
ansond 0:b438482ebbfc 55 Add pointer to the instance table
ansond 0:b438482ebbfc 56 @param key input the key for the new pointer
ansond 0:b438482ebbfc 57 @param instance input the instance pointer to save
ansond 0:b438482ebbfc 58 */
ansond 0:b438482ebbfc 59 void add(string key,void *instance);
ansond 0:b438482ebbfc 60
ansond 0:b438482ebbfc 61 /**
ansond 0:b438482ebbfc 62 Get a instance pointer index by the name of the key
ansond 0:b438482ebbfc 63 @param key input the key to use for the lookup
ansond 0:b438482ebbfc 64 @returns the instance pointer if found or NULL if not found
ansond 0:b438482ebbfc 65 */
ansond 0:b438482ebbfc 66 void *get(string key);
ansond 0:b438482ebbfc 67
ansond 0:b438482ebbfc 68 /**
ansond 0:b438482ebbfc 69 Set the Logger instance
ansond 0:b438482ebbfc 70 @param logger input the logger instance
ansond 0:b438482ebbfc 71 */
ansond 0:b438482ebbfc 72 void setLogger(const Logger *logger);
ansond 0:b438482ebbfc 73
ansond 0:b438482ebbfc 74 private:
ansond 0:b438482ebbfc 75 Logger *m_logger;
ansond 0:b438482ebbfc 76 InstancePointerTableRow m_instance_pointer_table[IPT_MAX_ENTRIES];
ansond 0:b438482ebbfc 77
ansond 0:b438482ebbfc 78 // initialize our table
ansond 0:b438482ebbfc 79 void init();
ansond 0:b438482ebbfc 80
ansond 0:b438482ebbfc 81 // get the next empty slot
ansond 0:b438482ebbfc 82 int nextEmptySlot();
ansond 0:b438482ebbfc 83
ansond 0:b438482ebbfc 84 // index from key
ansond 0:b438482ebbfc 85 int indexFromKey(string key);
ansond 0:b438482ebbfc 86
ansond 0:b438482ebbfc 87 // get our logger
ansond 0:b438482ebbfc 88 Logger *logger();
ansond 0:b438482ebbfc 89 };
ansond 0:b438482ebbfc 90
ansond 0:b438482ebbfc 91 #endif // __INSTANCE_POINTER_TABLE_H__