1 /*****************************************************************************\
3 * Name : list_synchronizer *
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 2002-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
15 #include "list_manager.h"
16 #include "list_synchronizer.h"
18 #include <structures/string_array.h>
19 #include <textual/string_manipulation.h>
21 using namespace basis;
22 using namespace structures;
23 using namespace textual;
25 namespace synchronic {
27 const int MAX_PER_ENT = 10 * MEGABYTE;
28 // our arbitrary limit for how much we allow the entity data bin to store.
30 list_synchronizer::list_synchronizer()
31 : octopus(string_manipulation::make_random_name(), MAX_PER_ENT)
35 list_synchronizer::~list_synchronizer()
39 outcome list_synchronizer::add_list(list_manager *to_add)
40 { return add_tentacle(to_add); }
42 outcome list_synchronizer::zap_list(const string_array &list_name)
43 { return zap_tentacle(list_name); }
45 bool list_synchronizer::update(const string_array &object_id)
48 bool to_return = false;
49 for (int i = 0; i < locked_tentacle_count(); i++) {
50 list_manager *t = dynamic_cast<list_manager *>(locked_get_tentacle(i));
52 if (t->list_name().prefix_compare(object_id)) {
53 // this is the right one to ask about the object.
54 to_return = t->update(object_id);
62 void list_synchronizer::clean(int older_than)
65 for (int i = 0; i < locked_tentacle_count(); i++) {
66 list_manager *t = dynamic_cast<list_manager *>(locked_get_tentacle(i));
67 if (t) t->clean(older_than);