Webserver for peach-board
RPCObjectManager.cpp@1:f1f734dd23ee, 2015-03-12 (annotated)
- Committer:
- thudt90
- Date:
- Thu Mar 12 08:26:27 2015 +0000
- Revision:
- 1:f1f734dd23ee
- Parent:
- 0:6ec14f880a00
Just test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thudt90 | 0:6ec14f880a00 | 1 | #include "RPCObjectManager.h" |
thudt90 | 0:6ec14f880a00 | 2 | #include "mbed.h" |
thudt90 | 0:6ec14f880a00 | 3 | |
thudt90 | 0:6ec14f880a00 | 4 | RPCObjectManager& RPCObjectManager::instance() |
thudt90 | 0:6ec14f880a00 | 5 | { |
thudt90 | 0:6ec14f880a00 | 6 | static RPCObjectManager om; |
thudt90 | 0:6ec14f880a00 | 7 | return om; |
thudt90 | 0:6ec14f880a00 | 8 | } |
thudt90 | 0:6ec14f880a00 | 9 | |
thudt90 | 0:6ec14f880a00 | 10 | RPCObjectManager::RPCObjectManager(): |
thudt90 | 0:6ec14f880a00 | 11 | objects() |
thudt90 | 0:6ec14f880a00 | 12 | { |
thudt90 | 0:6ec14f880a00 | 13 | } |
thudt90 | 0:6ec14f880a00 | 14 | |
thudt90 | 0:6ec14f880a00 | 15 | RPCObjectManager::~RPCObjectManager() |
thudt90 | 0:6ec14f880a00 | 16 | { |
thudt90 | 0:6ec14f880a00 | 17 | for(std::list<char*>::iterator itor = objects.begin(); |
thudt90 | 0:6ec14f880a00 | 18 | itor != objects.end(); |
thudt90 | 0:6ec14f880a00 | 19 | ++itor) |
thudt90 | 0:6ec14f880a00 | 20 | delete *itor; |
thudt90 | 0:6ec14f880a00 | 21 | } |
thudt90 | 0:6ec14f880a00 | 22 | |
thudt90 | 0:6ec14f880a00 | 23 | void RPCObjectManager::store_object(char *obj_name) |
thudt90 | 0:6ec14f880a00 | 24 | { |
thudt90 | 0:6ec14f880a00 | 25 | char *obj = new char[strlen(obj_name)+1]; |
thudt90 | 0:6ec14f880a00 | 26 | strcpy(obj, obj_name); |
thudt90 | 0:6ec14f880a00 | 27 | obj[strlen(obj_name)] = '\0'; |
thudt90 | 0:6ec14f880a00 | 28 | objects.push_back(obj); |
thudt90 | 0:6ec14f880a00 | 29 | } |
thudt90 | 0:6ec14f880a00 | 30 | |
thudt90 | 0:6ec14f880a00 | 31 | void RPCObjectManager::remove_object(char *obj_name) |
thudt90 | 0:6ec14f880a00 | 32 | { |
thudt90 | 0:6ec14f880a00 | 33 | for(std::list<char*>::iterator itor = objects.begin(); |
thudt90 | 0:6ec14f880a00 | 34 | itor != objects.end(); |
thudt90 | 0:6ec14f880a00 | 35 | ++itor) |
thudt90 | 0:6ec14f880a00 | 36 | if(!strcmp(obj_name, *itor)) |
thudt90 | 0:6ec14f880a00 | 37 | { |
thudt90 | 0:6ec14f880a00 | 38 | delete *itor; |
thudt90 | 0:6ec14f880a00 | 39 | objects.erase(itor); |
thudt90 | 0:6ec14f880a00 | 40 | break; |
thudt90 | 0:6ec14f880a00 | 41 | } |
thudt90 | 0:6ec14f880a00 | 42 | } |
thudt90 | 0:6ec14f880a00 | 43 | |
thudt90 | 0:6ec14f880a00 | 44 | bool RPCObjectManager::lookup_object(char *obj_name) |
thudt90 | 0:6ec14f880a00 | 45 | { |
thudt90 | 0:6ec14f880a00 | 46 | for(std::list<char*>::iterator itor = objects.begin(); |
thudt90 | 0:6ec14f880a00 | 47 | itor != objects.end(); |
thudt90 | 0:6ec14f880a00 | 48 | ++itor) |
thudt90 | 0:6ec14f880a00 | 49 | if(!strcmp(obj_name, *itor)) |
thudt90 | 0:6ec14f880a00 | 50 | return true; |
thudt90 | 0:6ec14f880a00 | 51 | return false; |
thudt90 | 0:6ec14f880a00 | 52 | } |
thudt90 | 0:6ec14f880a00 | 53 | |
thudt90 | 0:6ec14f880a00 | 54 | bool RPCObjectManager::is_empty() |
thudt90 | 0:6ec14f880a00 | 55 | { |
thudt90 | 0:6ec14f880a00 | 56 | return objects.empty(); |
thudt90 | 0:6ec14f880a00 | 57 | } |
thudt90 | 0:6ec14f880a00 | 58 | |
thudt90 | 0:6ec14f880a00 | 59 | std::list<char*>::iterator RPCObjectManager::begin() |
thudt90 | 0:6ec14f880a00 | 60 | { |
thudt90 | 0:6ec14f880a00 | 61 | return objects.begin(); |
thudt90 | 0:6ec14f880a00 | 62 | } |
thudt90 | 0:6ec14f880a00 | 63 | |
thudt90 | 0:6ec14f880a00 | 64 | std::list<char*>::iterator RPCObjectManager::end() |
thudt90 | 0:6ec14f880a00 | 65 | { |
thudt90 | 0:6ec14f880a00 | 66 | return objects.end(); |
thudt90 | 0:6ec14f880a00 | 67 | } |
thudt90 | 0:6ec14f880a00 | 68 |