00001 #ifndef LIST_SYNCHRONIZER_IMPLEMENTATION_FILE 00002 #define LIST_SYNCHRONIZER_IMPLEMENTATION_FILE 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : list_synchronizer * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 2002-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "list_manager.h" 00019 #include "list_synchronizer.h" 00020 00021 #include <basis/string_array.h> 00022 #include <textual/string_manipulation.h> 00023 00024 const int MAX_PER_ENT = 10 * MEGABYTE; 00025 // our arbitrary limit for how much we allow the entity data bin to store. 00026 00027 list_synchronizer::list_synchronizer() 00028 : octopus(string_manipulation::make_random_name(), MAX_PER_ENT) 00029 { 00030 } 00031 00032 list_synchronizer::~list_synchronizer() 00033 { 00034 } 00035 00036 outcome list_synchronizer::add_list(list_manager *to_add) 00037 { return add_tentacle(to_add); } 00038 00039 outcome list_synchronizer::zap_list(const string_array &list_name) 00040 { return zap_tentacle(list_name); } 00041 00042 bool list_synchronizer::update(const string_array &object_id) 00043 { 00044 lock_tentacles(); 00045 bool to_return = false; 00046 for (int i = 0; i < locked_tentacle_count(); i++) { 00047 list_manager *t = dynamic_cast<list_manager *>(locked_get_tentacle(i)); 00048 if (!t) continue; 00049 if (t->list_name().prefix_compare(object_id)) { 00050 // this is the right one to ask about the object. 00051 to_return = t->update(object_id); 00052 break; 00053 } 00054 } 00055 unlock_tentacles(); 00056 return to_return; 00057 } 00058 00059 void list_synchronizer::clean(int older_than) 00060 { 00061 lock_tentacles(); 00062 for (int i = 0; i < locked_tentacle_count(); i++) { 00063 list_manager *t = dynamic_cast<list_manager *>(locked_get_tentacle(i)); 00064 if (t) t->clean(older_than); 00065 } 00066 unlock_tentacles(); 00067 } 00068 00069 00070 #endif //LIST_SYNCHRONIZER_IMPLEMENTATION_FILE 00071
1.5.1