This library is designed to create and run state graphs. It supports hierarchical states and parallel states execution.
StateMachineLib/source/UserData.cpp@0:f4fdca2c4c67, 2017-10-03 (annotated)
- Committer:
- martin13
- Date:
- Tue Oct 03 08:29:22 2017 +0000
- Revision:
- 0:f4fdca2c4c67
First version
Who changed what in which revision?
User | Revision | Line number | New 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.cpp |
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 | #include "UserData.h" |
martin13 | 0:f4fdca2c4c67 | 15 | |
martin13 | 0:f4fdca2c4c67 | 16 | UserData::UserDataItem_t::UserDataItem_t(const char* _key, void* _data){ |
martin13 | 0:f4fdca2c4c67 | 17 | key = _key; |
martin13 | 0:f4fdca2c4c67 | 18 | data = _data; |
martin13 | 0:f4fdca2c4c67 | 19 | next = NULL; |
martin13 | 0:f4fdca2c4c67 | 20 | } |
martin13 | 0:f4fdca2c4c67 | 21 | |
martin13 | 0:f4fdca2c4c67 | 22 | |
martin13 | 0:f4fdca2c4c67 | 23 | UserData::UserData(): |
martin13 | 0:f4fdca2c4c67 | 24 | m_userDataList(NULL), |
martin13 | 0:f4fdca2c4c67 | 25 | m_nbUserData(0) |
martin13 | 0:f4fdca2c4c67 | 26 | { |
martin13 | 0:f4fdca2c4c67 | 27 | /* Empty */ |
martin13 | 0:f4fdca2c4c67 | 28 | } |
martin13 | 0:f4fdca2c4c67 | 29 | |
martin13 | 0:f4fdca2c4c67 | 30 | void UserData::put(UserDataItem_t *ud){ |
martin13 | 0:f4fdca2c4c67 | 31 | |
martin13 | 0:f4fdca2c4c67 | 32 | if(m_userDataList == NULL){ |
martin13 | 0:f4fdca2c4c67 | 33 | |
martin13 | 0:f4fdca2c4c67 | 34 | m_userDataList = ud; |
martin13 | 0:f4fdca2c4c67 | 35 | |
martin13 | 0:f4fdca2c4c67 | 36 | } else { |
martin13 | 0:f4fdca2c4c67 | 37 | |
martin13 | 0:f4fdca2c4c67 | 38 | UserDataItem_t *temp = m_userDataList; |
martin13 | 0:f4fdca2c4c67 | 39 | |
martin13 | 0:f4fdca2c4c67 | 40 | while(temp->next != NULL) |
martin13 | 0:f4fdca2c4c67 | 41 | { |
martin13 | 0:f4fdca2c4c67 | 42 | temp = temp->next; |
martin13 | 0:f4fdca2c4c67 | 43 | } |
martin13 | 0:f4fdca2c4c67 | 44 | temp->next = ud; |
martin13 | 0:f4fdca2c4c67 | 45 | } |
martin13 | 0:f4fdca2c4c67 | 46 | |
martin13 | 0:f4fdca2c4c67 | 47 | m_nbUserData++; |
martin13 | 0:f4fdca2c4c67 | 48 | } |