custom for >5 resources
Fork of mbedConnectorInterface by
Diff: api/InstancePointerTable.h
- Revision:
- 2:853f9ecc12df
- Parent:
- 0:b438482ebbfc
diff -r cabdd0350707 -r 853f9ecc12df api/InstancePointerTable.h --- a/api/InstancePointerTable.h Tue Jan 27 22:52:25 2015 +0000 +++ b/api/InstancePointerTable.h Tue Jan 27 23:41:34 2015 +0000 @@ -3,7 +3,7 @@ * @brief instance pointer table header * @author Doug Anson/Chris Paola * @version 1.0 - * @see + * @see * * Copyright (c) 2014 * @@ -19,73 +19,76 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - #ifndef __INSTANCE_POINTER_TABLE_H__ - #define __INSTANCE_POINTER_TABLE_H__ - - // Logger support - #include "Logger.h" - - // string support - #include <string> - - // Configuration - #include "mbedConnectorInterface.h" - - // our table row structure - typedef struct { - string key; - void *instance; - } InstancePointerTableRow; - - class InstancePointerTable { - public: - /** - Default constructor - @param logger input the logger instance - */ - InstancePointerTable(const Logger *logger = NULL); - - /** - Destructor - */ - virtual ~InstancePointerTable(); - - /** - Add pointer to the instance table - @param key input the key for the new pointer - @param instance input the instance pointer to save - */ - void add(string key,void *instance); - - /** - Get a instance pointer index by the name of the key - @param key input the key to use for the lookup - @returns the instance pointer if found or NULL if not found - */ - void *get(string key); - - /** - Set the Logger instance - @param logger input the logger instance - */ - void setLogger(const Logger *logger); - - private: - Logger *m_logger; - InstancePointerTableRow m_instance_pointer_table[IPT_MAX_ENTRIES]; - - // initialize our table - void init(); - - // get the next empty slot - int nextEmptySlot(); - - // index from key - int indexFromKey(string key); - - // get our logger - Logger *logger(); - }; - - #endif // __INSTANCE_POINTER_TABLE_H__ \ No newline at end of file + +#ifndef __INSTANCE_POINTER_TABLE_H__ +#define __INSTANCE_POINTER_TABLE_H__ + +// Logger support +#include "Logger.h" + +// string support +#include <string> + +// Configuration +#include "mbedConnectorInterface.h" + +// our table row structure +typedef struct { + string key; + void *instance; +} InstancePointerTableRow; + +/** InstancePointerTable class + */ +class InstancePointerTable +{ +public: + /** + Default constructor + @param logger input the logger instance + */ + InstancePointerTable(const Logger *logger = NULL); + + /** + Destructor + */ + virtual ~InstancePointerTable(); + + /** + Add pointer to the instance table + @param key input the key for the new pointer + @param instance input the instance pointer to save + */ + void add(string key,void *instance); + + /** + Get a instance pointer index by the name of the key + @param key input the key to use for the lookup + @returns the instance pointer if found or NULL if not found + */ + void *get(string key); + + /** + Set the Logger instance + @param logger input the logger instance + */ + void setLogger(const Logger *logger); + +private: + Logger *m_logger; + InstancePointerTableRow m_instance_pointer_table[IPT_MAX_ENTRIES]; + + // initialize our table + void init(); + + // get the next empty slot + int nextEmptySlot(); + + // index from key + int indexFromKey(string key); + + // get our logger + Logger *logger(); +}; + +#endif // __INSTANCE_POINTER_TABLE_H__