3535#include " ../common/gdsassert.h"
3636#include " ../common/dsc.h"
3737#include " ../jrd/btn.h"
38+ #include " ../jrd/vec.h"
3839#include " ../jrd/jrd_proto.h"
3940#include " ../jrd/val.h"
4041#include " ../jrd/irq.h"
@@ -90,6 +91,7 @@ class MonitoringData;
9091class GarbageCollector ;
9192class CryptoManager ;
9293class KeywordsMap ;
94+ class MetadataCache ;
9395
9496// allocator for keywords table
9597class KeywordsMapAllocator
@@ -99,118 +101,6 @@ class KeywordsMapAllocator
99101 static void destroy (KeywordsMap* inst);
100102};
101103
102- // general purpose vector
103- template <class T , BlockType TYPE = type_vec>
104- class vec_base : protected pool_alloc <TYPE>
105- {
106- public:
107- typedef typename Firebird::Array<T>::iterator iterator;
108- typedef typename Firebird::Array<T>::const_iterator const_iterator;
109-
110- /*
111- static vec_base* newVector(MemoryPool& p, int len)
112- {
113- return FB_NEW_POOL(p) vec_base<T, TYPE>(p, len);
114- }
115-
116- static vec_base* newVector(MemoryPool& p, const vec_base& base)
117- {
118- return FB_NEW_POOL(p) vec_base<T, TYPE>(p, base);
119- }
120- */
121-
122- FB_SIZE_T count () const { return v.getCount (); }
123- T& operator [](FB_SIZE_T index) { return v[index]; }
124- const T& operator [](FB_SIZE_T index) const { return v[index]; }
125-
126- iterator begin () { return v.begin (); }
127- iterator end () { return v.end (); }
128-
129- const_iterator begin () const { return v.begin (); }
130- const_iterator end () const { return v.end (); }
131-
132- void clear () { v.clear (); }
133-
134- T* memPtr () { return &v[0 ]; }
135-
136- void resize (FB_SIZE_T n, T val = T()) { v.resize (n, val); }
137-
138- void operator delete (void * mem) { MemoryPool::globalFree (mem); }
139-
140- protected:
141- vec_base (MemoryPool& p, int len)
142- : v(p, len)
143- {
144- v.resize (len);
145- }
146-
147- vec_base (MemoryPool& p, const vec_base& base)
148- : v(p)
149- {
150- v = base.v ;
151- }
152-
153- private:
154- Firebird::Array<T> v;
155- };
156-
157- template <typename T>
158- class vec : public vec_base <T, type_vec>
159- {
160- public:
161- static vec* newVector (MemoryPool& p, int len)
162- {
163- return FB_NEW_POOL (p) vec<T>(p, len);
164- }
165-
166- static vec* newVector (MemoryPool& p, const vec& base)
167- {
168- return FB_NEW_POOL (p) vec<T>(p, base);
169- }
170-
171- static vec* newVector (MemoryPool& p, vec* base, int len)
172- {
173- if (!base)
174- base = FB_NEW_POOL (p) vec<T>(p, len);
175- else if (len > (int ) base->count ())
176- base->resize (len);
177- return base;
178- }
179-
180- private:
181- vec (MemoryPool& p, int len) : vec_base<T, type_vec>(p, len) {}
182- vec (MemoryPool& p, const vec& base) : vec_base<T, type_vec>(p, base) {}
183- };
184-
185- class vcl : public vec_base <ULONG, type_vcl>
186- {
187- public:
188- static vcl* newVector (MemoryPool& p, int len)
189- {
190- return FB_NEW_POOL (p) vcl (p, len);
191- }
192-
193- static vcl* newVector (MemoryPool& p, const vcl& base)
194- {
195- return FB_NEW_POOL (p) vcl (p, base);
196- }
197-
198- static vcl* newVector (MemoryPool& p, vcl* base, int len)
199- {
200- if (!base)
201- base = FB_NEW_POOL (p) vcl (p, len);
202- else if (len > (int ) base->count ())
203- base->resize (len);
204- return base;
205- }
206-
207- private:
208- vcl (MemoryPool& p, int len) : vec_base<ULONG, type_vcl>(p, len) {}
209- vcl (MemoryPool& p, const vcl& base) : vec_base<ULONG, type_vcl>(p, base) {}
210- };
211-
212- typedef vec<TraNumber> TransactionsVector;
213-
214104
215105//
216106// bit values for dbb_flags
@@ -546,7 +436,7 @@ class Database : public pool_alloc<type_dbb>
546436 Dictionary dbb_dic; // metanames dictionary
547437 Firebird::InitInstance<KeywordsMap, KeywordsMapAllocator, Firebird::TraditionalDelete> dbb_keywords_map;
548438
549- MetadataCache dbb_mdc;
439+ MetadataCache* dbb_mdc;
550440 HazardDelayedDelete dbb_delayed_delete;
551441 Firebird::Mutex dbb_dd_mutex;
552442
@@ -588,41 +478,7 @@ class Database : public pool_alloc<type_dbb>
588478 }
589479
590480private:
591- Database (MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared)
592- : dbb_permanent(p),
593- dbb_page_manager (this , *p),
594- dbb_file_id(*p),
595- dbb_modules(*p),
596- dbb_extManager(nullptr ),
597- dbb_flags(shared ? DBB_shared : 0 ),
598- dbb_filename(*p),
599- dbb_database_name(*p),
600- #ifdef HAVE_ID_BY_NAME
601- dbb_id (*p),
602- #endif
603- dbb_owner (*p),
604- dbb_pools(*p, 4 ),
605- dbb_sort_buffers(*p),
606- dbb_gc_fini(*p, garbage_collector, THREAD_medium),
607- dbb_stats(*p),
608- dbb_lock_owner_id(getLockOwnerId()),
609- dbb_tip_cache(NULL ),
610- dbb_creation_date(Firebird::TimeZoneUtil::getCurrentGmtTimeStamp()),
611- dbb_external_file_directory_list(NULL ),
612- dbb_init_fini(FB_NEW_POOL(*getDefaultMemoryPool ()) ExistenceRefMutex()),
613- dbb_linger_seconds(0 ),
614- dbb_linger_end(0 ),
615- dbb_plugin_config(pConf),
616- dbb_repl_sequence(0 ),
617- dbb_replica_mode(REPLICA_NONE),
618- dbb_compatibility_index(~0U ),
619- dbb_dic(*p),
620- dbb_mdc(*p),
621- dbb_delayed_delete(*p, *p)
622- {
623- dbb_pools.add (p);
624- }
625-
481+ Database (MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared);
626482 ~Database ();
627483
628484public:
0 commit comments