This library is designed to create and run state graphs. It supports hierarchical states and the parallel execution

Committer:
martin13
Date:
Tue Oct 03 08:36:40 2017 +0000
Revision:
1:0f11d9338d89
Parent:
0:f4fdca2c4c67
added empty readme

Who changed what in which revision?

UserRevisionLine numberNew contents of line
martin13 0:f4fdca2c4c67 1 ////////////////////////////////////////////////////////////////////////////////
martin13 0:f4fdca2c4c67 2 // Copyright Rottor SAS 2017
martin13 0:f4fdca2c4c67 3 // All rigths reserved.
martin13 0:f4fdca2c4c67 4 //
martin13 0:f4fdca2c4c67 5 // File Name : UserData.h
martin13 0:f4fdca2c4c67 6 // Authors : Martin Matignon
martin13 0:f4fdca2c4c67 7 //
martin13 0:f4fdca2c4c67 8 // If you find any bug or if you have any question please contact
martin13 0:f4fdca2c4c67 9 // Martin Matignon <martin.matignon@rottor.fr>
martin13 0:f4fdca2c4c67 10 // Nicolas Forestier <nicolas.forestier@rottor.fr>
martin13 0:f4fdca2c4c67 11 //
martin13 0:f4fdca2c4c67 12 ////////////////////////////////////////////////////////////////////////////////
martin13 0:f4fdca2c4c67 13
martin13 0:f4fdca2c4c67 14 #ifndef __SM_USER_DATA_H__
martin13 0:f4fdca2c4c67 15 #define __SM_USER_DATA_H__
martin13 0:f4fdca2c4c67 16
martin13 0:f4fdca2c4c67 17 #include "mbed.h"
martin13 0:f4fdca2c4c67 18
martin13 0:f4fdca2c4c67 19 #include "MetaData.h"
martin13 0:f4fdca2c4c67 20
martin13 0:f4fdca2c4c67 21 class UserData{
martin13 0:f4fdca2c4c67 22
martin13 0:f4fdca2c4c67 23 public:
martin13 0:f4fdca2c4c67 24
martin13 0:f4fdca2c4c67 25 struct UserDataItem_t{
martin13 0:f4fdca2c4c67 26
martin13 0:f4fdca2c4c67 27 const char *key;
martin13 0:f4fdca2c4c67 28 void *data;
martin13 0:f4fdca2c4c67 29 UserDataItem_t *next;
martin13 0:f4fdca2c4c67 30
martin13 0:f4fdca2c4c67 31 UserDataItem_t(const char* _key, void* _data);
martin13 0:f4fdca2c4c67 32 };
martin13 0:f4fdca2c4c67 33
martin13 0:f4fdca2c4c67 34 UserData();
martin13 0:f4fdca2c4c67 35
martin13 0:f4fdca2c4c67 36 /** Registe template data
martin13 0:f4fdca2c4c67 37 *
martin13 0:f4fdca2c4c67 38 * @param const char* The data key
martin13 0:f4fdca2c4c67 39 * @param T The pointer data
martin13 0:f4fdca2c4c67 40 */
martin13 0:f4fdca2c4c67 41 template<typename T>
martin13 0:f4fdca2c4c67 42 inline void put(const char* key, T *data){
martin13 0:f4fdca2c4c67 43 UserDataItem_t *newUserData = new UserDataItem_t(key, static_cast<void*>(data));
martin13 0:f4fdca2c4c67 44 this->put(newUserData);
martin13 0:f4fdca2c4c67 45 }
martin13 0:f4fdca2c4c67 46
martin13 0:f4fdca2c4c67 47 /** Provide template data by key
martin13 0:f4fdca2c4c67 48 *
martin13 0:f4fdca2c4c67 49 * @param const char* The data key
martin13 0:f4fdca2c4c67 50 * @return T The pointer data
martin13 0:f4fdca2c4c67 51 */
martin13 0:f4fdca2c4c67 52 template<typename T>
martin13 0:f4fdca2c4c67 53 inline T get(const char* key){
martin13 0:f4fdca2c4c67 54
martin13 0:f4fdca2c4c67 55 UserDataItem_t *tmp = m_userDataList;
martin13 0:f4fdca2c4c67 56
martin13 0:f4fdca2c4c67 57 while(tmp != NULL)
martin13 0:f4fdca2c4c67 58 {
martin13 0:f4fdca2c4c67 59 if (strcmp(tmp->key, key) == 0){
martin13 0:f4fdca2c4c67 60 return (T)(tmp->data);
martin13 0:f4fdca2c4c67 61 }
martin13 0:f4fdca2c4c67 62 tmp = tmp->next;
martin13 0:f4fdca2c4c67 63 }
martin13 0:f4fdca2c4c67 64
martin13 0:f4fdca2c4c67 65 return NULL;
martin13 0:f4fdca2c4c67 66 }
martin13 0:f4fdca2c4c67 67
martin13 0:f4fdca2c4c67 68 private:
martin13 0:f4fdca2c4c67 69
martin13 0:f4fdca2c4c67 70 void put(UserDataItem_t *ud);
martin13 0:f4fdca2c4c67 71
martin13 0:f4fdca2c4c67 72 UserDataItem_t *m_userDataList;
martin13 0:f4fdca2c4c67 73 int m_nbUserData;
martin13 0:f4fdca2c4c67 74 };
martin13 0:f4fdca2c4c67 75
martin13 0:f4fdca2c4c67 76 #endif /* #ifndef __SM_USER_DATA_H__*/