student test for professor

Dependencies:   EthernetInterface mbed-rpc mbed-rtos mbed

Fork of HTTP-Server by Francois Berder

Committer:
feb11
Date:
Wed Jul 17 10:15:05 2013 +0000
Revision:
0:9e4bcb10b3e3
Initial import

Who changed what in which revision?

UserRevisionLine numberNew contents of line
feb11 0:9e4bcb10b3e3 1 #include "RPCObjectManager.h"
feb11 0:9e4bcb10b3e3 2 #include "mbed.h"
feb11 0:9e4bcb10b3e3 3
feb11 0:9e4bcb10b3e3 4 RPCObjectManager& RPCObjectManager::instance()
feb11 0:9e4bcb10b3e3 5 {
feb11 0:9e4bcb10b3e3 6 static RPCObjectManager om;
feb11 0:9e4bcb10b3e3 7 return om;
feb11 0:9e4bcb10b3e3 8 }
feb11 0:9e4bcb10b3e3 9
feb11 0:9e4bcb10b3e3 10 RPCObjectManager::RPCObjectManager():
feb11 0:9e4bcb10b3e3 11 objects()
feb11 0:9e4bcb10b3e3 12 {
feb11 0:9e4bcb10b3e3 13 }
feb11 0:9e4bcb10b3e3 14
feb11 0:9e4bcb10b3e3 15 RPCObjectManager::~RPCObjectManager()
feb11 0:9e4bcb10b3e3 16 {
feb11 0:9e4bcb10b3e3 17 for(std::list<char*>::iterator itor = objects.begin();
feb11 0:9e4bcb10b3e3 18 itor != objects.end();
feb11 0:9e4bcb10b3e3 19 ++itor)
feb11 0:9e4bcb10b3e3 20 delete *itor;
feb11 0:9e4bcb10b3e3 21 }
feb11 0:9e4bcb10b3e3 22
feb11 0:9e4bcb10b3e3 23 void RPCObjectManager::store_object(char *obj_name)
feb11 0:9e4bcb10b3e3 24 {
feb11 0:9e4bcb10b3e3 25 char *obj = new char[strlen(obj_name)+1];
feb11 0:9e4bcb10b3e3 26 strcpy(obj, obj_name);
feb11 0:9e4bcb10b3e3 27 obj[strlen(obj_name)] = '\0';
feb11 0:9e4bcb10b3e3 28 objects.push_back(obj);
feb11 0:9e4bcb10b3e3 29 }
feb11 0:9e4bcb10b3e3 30
feb11 0:9e4bcb10b3e3 31 void RPCObjectManager::remove_object(char *obj_name)
feb11 0:9e4bcb10b3e3 32 {
feb11 0:9e4bcb10b3e3 33 for(std::list<char*>::iterator itor = objects.begin();
feb11 0:9e4bcb10b3e3 34 itor != objects.end();
feb11 0:9e4bcb10b3e3 35 ++itor)
feb11 0:9e4bcb10b3e3 36 if(!strcmp(obj_name, *itor))
feb11 0:9e4bcb10b3e3 37 {
feb11 0:9e4bcb10b3e3 38 delete *itor;
feb11 0:9e4bcb10b3e3 39 objects.erase(itor);
feb11 0:9e4bcb10b3e3 40 break;
feb11 0:9e4bcb10b3e3 41 }
feb11 0:9e4bcb10b3e3 42 }
feb11 0:9e4bcb10b3e3 43
feb11 0:9e4bcb10b3e3 44 bool RPCObjectManager::lookup_object(char *obj_name)
feb11 0:9e4bcb10b3e3 45 {
feb11 0:9e4bcb10b3e3 46 for(std::list<char*>::iterator itor = objects.begin();
feb11 0:9e4bcb10b3e3 47 itor != objects.end();
feb11 0:9e4bcb10b3e3 48 ++itor)
feb11 0:9e4bcb10b3e3 49 if(!strcmp(obj_name, *itor))
feb11 0:9e4bcb10b3e3 50 return true;
feb11 0:9e4bcb10b3e3 51 return false;
feb11 0:9e4bcb10b3e3 52 }
feb11 0:9e4bcb10b3e3 53
feb11 0:9e4bcb10b3e3 54 bool RPCObjectManager::is_empty()
feb11 0:9e4bcb10b3e3 55 {
feb11 0:9e4bcb10b3e3 56 return objects.empty();
feb11 0:9e4bcb10b3e3 57 }
feb11 0:9e4bcb10b3e3 58
feb11 0:9e4bcb10b3e3 59 std::list<char*>::iterator RPCObjectManager::begin()
feb11 0:9e4bcb10b3e3 60 {
feb11 0:9e4bcb10b3e3 61 return objects.begin();
feb11 0:9e4bcb10b3e3 62 }
feb11 0:9e4bcb10b3e3 63
feb11 0:9e4bcb10b3e3 64 std::list<char*>::iterator RPCObjectManager::end()
feb11 0:9e4bcb10b3e3 65 {
feb11 0:9e4bcb10b3e3 66 return objects.end();
feb11 0:9e4bcb10b3e3 67 }
feb11 0:9e4bcb10b3e3 68