Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbedConnectorInterface by
InstancePointerTable.h
00001 /** 00002 * @file InstancePointerTable.h 00003 * @brief instance pointer table header 00004 * @author Doug Anson/Chris Paola 00005 * @version 1.0 00006 * @see 00007 * 00008 * Copyright (c) 2014 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); 00011 * you may not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, 00018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 */ 00022 00023 #ifndef __INSTANCE_POINTER_TABLE_H__ 00024 #define __INSTANCE_POINTER_TABLE_H__ 00025 00026 // Logger support 00027 #include "Logger.h" 00028 00029 // string support 00030 #include <string> 00031 00032 // Configuration 00033 #include "mbedConnectorInterface.h" 00034 00035 // our table row structure 00036 typedef struct { 00037 string key; 00038 void *instance; 00039 } InstancePointerTableRow; 00040 00041 /** InstancePointerTable class 00042 */ 00043 class InstancePointerTable 00044 { 00045 public: 00046 /** 00047 Default constructor 00048 @param logger input the logger instance 00049 */ 00050 InstancePointerTable(const Logger *logger = NULL); 00051 00052 /** 00053 Destructor 00054 */ 00055 virtual ~InstancePointerTable(); 00056 00057 /** 00058 Add pointer to the instance table 00059 @param key input the key for the new pointer 00060 @param instance input the instance pointer to save 00061 */ 00062 void add(string key,void *instance); 00063 00064 /** 00065 Get a instance pointer index by the name of the key 00066 @param key input the key to use for the lookup 00067 @returns the instance pointer if found or NULL if not found 00068 */ 00069 void *get(string key); 00070 00071 /** 00072 Set the Logger instance 00073 @param logger input the logger instance 00074 */ 00075 void setLogger(const Logger *logger); 00076 00077 private: 00078 Logger *m_logger; 00079 InstancePointerTableRow m_instance_pointer_table[IPT_MAX_ENTRIES]; 00080 00081 // initialize our table 00082 void init(); 00083 00084 // get the next empty slot 00085 int nextEmptySlot(); 00086 00087 // index from key 00088 int indexFromKey(string key); 00089 00090 // get our logger 00091 Logger *logger(); 00092 }; 00093 00094 #endif // __INSTANCE_POINTER_TABLE_H__
Generated on Wed Jul 13 2022 02:58:57 by
1.7.2
