mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / server-tools / instance-manager / instance_map.h
blobeff5e3dd041d930bf4dde066297969a7160aab9e
1 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_MAP_H
2 #define INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_MAP_H
3 /* Copyright (c) 2004-2006 MySQL AB
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
18 #include <my_global.h>
19 #include <my_sys.h>
20 #include <m_string.h>
21 #include <hash.h>
23 #if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
24 #pragma interface
25 #endif
27 class Guardian;
28 class Instance;
29 class Named_value_arr;
30 class Thread_registry;
32 extern int load_all_groups(char ***groups, const char *filename);
33 extern void free_groups(char **groups);
35 extern int create_instance_in_file(const LEX_STRING *instance_name,
36 const Named_value_arr *options);
39 /**
40 Instance_map - stores all existing instances
43 class Instance_map
45 public:
46 /**
47 Instance_map iterator
50 class Iterator
52 private:
53 uint current_instance;
54 Instance_map *instance_map;
55 public:
56 Iterator(Instance_map *instance_map_arg) :
57 current_instance(0), instance_map(instance_map_arg)
60 void go_to_first();
61 Instance *next();
64 public:
65 Instance *find(const LEX_STRING *name);
67 bool is_there_active_instance();
69 void lock();
70 void unlock();
72 bool init();
73 bool reset();
75 int load();
77 int process_one_option(const LEX_STRING *group, const char *option);
79 int add_instance(Instance *instance);
81 int remove_instance(Instance *instance);
83 int create_instance(const LEX_STRING *instance_name,
84 const Named_value_arr *options);
86 public:
87 Instance_map();
88 ~Instance_map();
90 private:
91 bool complete_initialization();
93 private:
94 enum { START_HASH_SIZE = 16 };
95 pthread_mutex_t LOCK_instance_map;
96 HASH hash;
98 private:
99 friend class Iterator;
102 #endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_INSTANCE_MAP_H */