1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_GENERATOR_TABLE_DEFINITION_CACHE_H
22
#define DRIZZLED_GENERATOR_TABLE_DEFINITION_CACHE_H
24
#include <boost/bind.hpp>
25
#include <boost/thread/mutex.hpp>
26
#include "drizzled/definition/cache.h"
31
class TableDefinitionCache
33
drizzled::TableShare::vector local_vector;
34
drizzled::TableShare::vector::iterator iter;
38
TableDefinitionCache()
40
boost::mutex::scoped_lock scopedLock(definition::Cache::singleton().mutex());
42
local_vector.reserve(definition::Cache::singleton().size());
44
std::transform(definition::Cache::singleton().getCache().begin(),
45
definition::Cache::singleton().getCache().end(),
46
std::back_inserter(local_vector),
47
boost::bind(&definition::Cache::Map::value_type::second, _1) );
48
assert(local_vector.size() == definition::Cache::singleton().getCache().size());
50
iter= local_vector.begin();
53
~TableDefinitionCache()
57
operator drizzled::TableShare::shared_ptr()
59
while (iter != local_vector.end())
61
drizzled::TableShare::shared_ptr ret(*iter);
66
return drizzled::TableShare::shared_ptr();
70
} /* namespace generator */
71
} /* namespace drizzled */
73
#endif /* DRIZZLED_GENERATOR_TABLE_DEFINITION_CACHE_H */