| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MultiStoreSvc.cpp
Go to the documentation of this file.
1 //====================================================================
2 // MultiStoreSvc.cpp
3 //--------------------------------------------------------------------
4 //
5 // Package : System ( The LHCb Offline System)
6 //
7 // Description: implementation of the Transient event data service.
8 //
9 // Author : M.Frank
10 // History :
11 // +---------+----------------------------------------------+---------
12 // | Date | Comment | Who
13 // +---------+----------------------------------------------+---------
14 // | 29/10/98| Initial version | MF
15 // +---------+----------------------------------------------+---------
16 //
17 //====================================================================
18 #define DATASVC_MULTISTORESVC_CPP
19
20 // Include files
21 #include "GaudiKernel/Service.h"
22 #include "GaudiKernel/SmartIF.h"
23 #include "GaudiKernel/TypeNameString.h"
24 #include "GaudiKernel/MsgStream.h"
25 #include "GaudiKernel/Tokenizer.h"
26 #include "GaudiKernel/DataObject.h"
27 #include "GaudiKernel/ISvcLocator.h"
28 #include "GaudiKernel/ISvcManager.h"
29 #include "GaudiKernel/IOpaqueAddress.h"
30 #include "GaudiKernel/IConversionSvc.h"
31 #include "GaudiKernel/IDataManagerSvc.h"
32 #include "GaudiKernel/IAddressCreator.h"
33 #include "GaudiKernel/IDataProviderSvc.h"
34 #include "GaudiKernel/IPartitionControl.h"
35
36 #include <map>
37
38 // Forward declarations
39 // This class
40 class MultiStoreSvc;
41
42 typedef const std::string CSTR;
43 typedef IDataStoreAgent AGENT;
44 typedef DataObject OBJECT;
45 typedef IOpaqueAddress ADDRESS;
46 typedef StatusCode STATUS;
47
48 namespace {
49
50 struct Partition {
51 IDataProviderSvc* dataProvider;
52 IDataManagerSvc* dataManager;
53 std::string name;
54 Partition() : dataProvider(0), dataManager(0)
55 {
56 }
57 Partition(const Partition& entry)
58 : dataProvider(entry.dataProvider),
59 dataManager(entry.dataManager),
60 name(entry.name)
61 {
62 }
63 Partition& operator=(const Partition& entry) {
64 dataProvider = entry.dataProvider;
65 dataManager = entry.dataManager;
66 name = entry.name;
67 return *this;
68 }
69 };
70 }
71
83 class MultiStoreSvc: public extends3<Service,
84 IDataProviderSvc,
85 IDataManagerSvc,
86 IPartitionControl>
87 {
88 protected:
89 typedef std::vector<std::string> PartitionDefs;
90 typedef std::map<std::string, Partition> Partitions;
92 CLID m_rootCLID;
94 std::string m_rootName;
96 std::string m_loader;
98 IConversionSvc* m_dataLoader;
100 IAddressCreator* m_addrCreator;
102 enum { no_type = 0, address_type = 1, object_type = 2};
103 struct tagROOT {
104 int type;
105 std::string path;
106 union {
107 ADDRESS* address;
108 OBJECT* object;
109 } root;
110 tagROOT() : type(no_type) { root.address = 0; }
111 } m_root;
113 Partition m_current;
115 Partitions m_partitions;
117 PartitionDefs m_partitionDefs;
119 std::string m_defaultPartition;
120
121 public:
123 virtual CLID rootCLID() const {
124 return (CLID)m_rootCLID;
125 }
127 std::string rootName() const {
128 return m_rootName;
129 }
130
131 // macro to help writing the function calls
132 #define _CALL(P,F,ARGS) \
133 P ? P->F ARGS : IDataProviderSvc::INVALID_ROOT
134
136 virtual STATUS registerAddress(CSTR& path, ADDRESS* pAddr) {
137 return _CALL(m_current.dataManager, registerAddress, (path, pAddr));
138 }
140 virtual STATUS registerAddress(OBJECT* parent, CSTR& path, ADDRESS* pAddr) {
141 return _CALL(m_current.dataManager, registerAddress, (parent, path, pAddr));
142 }
144 virtual STATUS registerAddress(IRegistry* parent, CSTR& path, ADDRESS* pAdd) {
145 return _CALL(m_current.dataManager, registerAddress, (parent, path, pAdd));
146 }
148 virtual STATUS unregisterAddress(CSTR& path) {
149 return _CALL(m_current.dataManager, unregisterAddress, (path));
150 }
152 virtual STATUS unregisterAddress(OBJECT* pParent, CSTR& path) {
153 return _CALL(m_current.dataManager, unregisterAddress, (pParent, path));
154 }
156 virtual STATUS unregisterAddress(IRegistry* pParent, CSTR& path) {
157 return _CALL(m_current.dataManager, unregisterAddress, (pParent, path));
158 }
160 virtual STATUS objectLeaves(const OBJECT* pObject, std::vector<IRegistry*>& leaves) {
161 return _CALL(m_current.dataManager, objectLeaves, (pObject, leaves));
162 }
164 virtual STATUS objectLeaves(const IRegistry* pObject, std::vector<IRegistry*>& leaves) {
165 return _CALL(m_current.dataManager, objectLeaves, (pObject, leaves));
166 }
168 virtual STATUS objectParent(const OBJECT* pObject, IRegistry*& refpParent) {
169 return _CALL(m_current.dataManager, objectParent, (pObject, refpParent));
170 }
172 virtual STATUS objectParent(const IRegistry* pObject, IRegistry*& refpParent) {
173 return _CALL(m_current.dataManager, objectParent, (pObject, refpParent));
174 }
176 virtual STATUS clearSubTree(CSTR& path) {
177 return _CALL(m_current.dataManager, clearSubTree, (path));
178 }
180 virtual STATUS clearSubTree(OBJECT* pObject) {
181 return _CALL(m_current.dataManager, clearSubTree, (pObject));
182 }
184 virtual STATUS clearStore() {
185 Partitions::iterator i;
186 for(i=m_partitions.begin(); i != m_partitions.end(); ++i) {
187 (*i).second.dataManager->clearStore().ignore();
188 }
189 if ( m_root.root.object ) {
190 switch ( m_root.type ) {
191 case address_type:
192 m_root.root.address->release();
193 break;
194 case object_type:
195 m_root.root.object->release();
196 break;
197 }
198 m_root.root.object = 0;
199 }
200 m_root.path = "";
201 m_root.type = no_type;
202 return STATUS::SUCCESS;
203 }
205 virtual STATUS traverseSubTree(CSTR& path, AGENT* pAgent) {
206 return _CALL(m_current.dataManager, traverseSubTree, (path, pAgent));
207 }
209 virtual STATUS traverseSubTree(OBJECT* pObject, AGENT* pAgent) {
210 return _CALL(m_current.dataManager, traverseSubTree, (pObject, pAgent));
211 }
213 virtual STATUS traverseTree( AGENT* pAgent ) {
214 return _CALL(m_current.dataManager, traverseTree, (pAgent));
215 }
218 virtual STATUS setRoot( CSTR& path, OBJECT* pObj) {
219 if ( m_root.root.object ) {
220 switch ( m_root.type ) {
221 case address_type:
222 m_root.root.address->release();
223 break;
224 case object_type:
225 m_root.root.object->release();
226 break;
227 }
228 }
229 m_root.path = path;
230 m_root.type = object_type;
231 m_root.root.object = pObj;
232 preparePartitions();
233 return activate(m_defaultPartition);
234 }
235
238 virtual STATUS setRoot (CSTR& path, ADDRESS* pAddr) {
239 if ( m_root.root.object ) {
240 switch ( m_root.type ) {
241 case address_type:
242 m_root.root.address->release();
243 break;
244 case object_type:
245 m_root.root.object->release();
246 break;
247 }
248 }
249 m_root.path = path;
250 m_root.type = address_type;
251 m_root.root.address = pAddr;
252 if ( m_root.root.address ) {
253 m_root.root.address->addRef();
254 preparePartitions();
255 return activate(m_defaultPartition);
256 }
257 return STATUS::FAILURE;
258 }
260 virtual STATUS setDataLoader(IConversionSvc* pDataLoader) {
261 Partitions::iterator i;
262 if ( 0 != pDataLoader ) pDataLoader->addRef();
263 if ( 0 != m_dataLoader ) m_dataLoader->release();
264 if ( 0 != pDataLoader ) {
265 pDataLoader->setDataProvider(this);
266 }
267 m_dataLoader = pDataLoader;
268 for(i=m_partitions.begin(); i != m_partitions.end(); ++i) {
269 (*i).second.dataManager->setDataLoader(m_dataLoader).ignore();
270 }
271 return SUCCESS;
272 }
274 virtual STATUS addPreLoadItem(const DataStoreItem& item) {
275 return _CALL(m_current.dataProvider, addPreLoadItem, (item));
276 }
278 virtual STATUS addPreLoadItem(CSTR& item) {
279 return _CALL(m_current.dataProvider, addPreLoadItem, (item));
280 }
282 virtual STATUS removePreLoadItem(const DataStoreItem& item) {
283 return _CALL(m_current.dataProvider, removePreLoadItem, (item));
284 }
286 virtual STATUS removePreLoadItem(CSTR& item) {
287 return _CALL(m_current.dataProvider, removePreLoadItem, (item));
288 }
290 virtual STATUS resetPreLoad() {
291 return _CALL(m_current.dataProvider, resetPreLoad, ());
292 }
294 virtual STATUS preLoad() {
295 return _CALL(m_current.dataProvider, preLoad, ());
296 }
298 virtual STATUS registerObject(CSTR& path, OBJECT* pObj) {
299 return registerObject(0, path, pObj);
300 }
302 virtual STATUS registerObject(CSTR& parent, CSTR& obj, OBJECT* pObj) {
303 return _CALL(m_current.dataProvider, registerObject, (parent, obj, pObj));
304 }
306 virtual STATUS registerObject(CSTR& parent, int item, OBJECT* pObj) {
307 return _CALL(m_current.dataProvider, registerObject, (parent, item, pObj));
308 }
310 virtual STATUS registerObject(OBJECT* parent, CSTR& obj, OBJECT* pObj) {
311 return _CALL(m_current.dataProvider, registerObject, (parent, obj, pObj));
312 }
314 virtual STATUS registerObject(OBJECT* parent, int obj, OBJECT* pObj) {
315 return _CALL(m_current.dataProvider, registerObject, (parent, obj, pObj));
316 }
318 virtual STATUS unregisterObject(CSTR& path) {
319 return _CALL(m_current.dataProvider, unregisterObject, (path));
320 }
322 virtual STATUS unregisterObject(CSTR& parent, CSTR& obj) {
323 return _CALL(m_current.dataProvider, unregisterObject, (parent, obj));
324 }
326 virtual STATUS unregisterObject(CSTR& parent, int obj) {
327 return _CALL(m_current.dataProvider, unregisterObject, (parent, obj));
328 }
330 virtual STATUS unregisterObject(OBJECT* pObj) {
331 return _CALL(m_current.dataProvider, unregisterObject, (pObj));
332 }
334 virtual STATUS unregisterObject(OBJECT* pObj, CSTR& path) {
335 return _CALL(m_current.dataProvider, unregisterObject, (pObj, path));
336 }
338 virtual STATUS unregisterObject(OBJECT* pObj, int item ) {
339 return _CALL(m_current.dataProvider, unregisterObject, (pObj, item));
340 }
342 virtual STATUS retrieveObject(IRegistry* parent, CSTR& path, OBJECT*& pObj ) {
343 return _CALL(m_current.dataProvider, retrieveObject, (parent, path, pObj));
344 }
346 virtual STATUS retrieveObject(CSTR& path, OBJECT*& pObj) {
347 return _CALL(m_current.dataProvider, retrieveObject, (path, pObj));
348 }
350 virtual STATUS retrieveObject(CSTR& parent, CSTR& path, OBJECT*& pObj ) {
351 return _CALL(m_current.dataProvider, retrieveObject, (parent, path, pObj));
352 }
354 virtual STATUS retrieveObject(CSTR& parent, int item, OBJECT*& pObj) {
355 return _CALL(m_current.dataProvider, retrieveObject, (parent, item, pObj));
356 }
358 virtual STATUS retrieveObject(OBJECT* parent, CSTR& path, OBJECT*& pObj ) {
359 return _CALL(m_current.dataProvider, retrieveObject, (parent, path, pObj));
360 }
362 virtual STATUS retrieveObject(OBJECT* parent, int item, OBJECT*& pObj ) {
363 return _CALL(m_current.dataProvider, retrieveObject, (parent, item, pObj));
364 }
366 virtual STATUS findObject(CSTR& path, OBJECT*& pObj) {
367 return _CALL(m_current.dataProvider, retrieveObject, (path, pObj));
368 }
370 virtual STATUS findObject(IRegistry* parent, CSTR& path, OBJECT*& pObj) {
371 return _CALL(m_current.dataProvider, retrieveObject, (parent, path, pObj));
372 }
374 virtual STATUS findObject(CSTR& parent, CSTR& path, OBJECT*& pObj) {
375 return _CALL(m_current.dataProvider, retrieveObject, (parent, path, pObj));
376 }
378 virtual STATUS findObject(CSTR& parent, int item, OBJECT*& pObject ) {
379 return _CALL(m_current.dataProvider, findObject, (parent, item, pObject));
380 }
382 virtual STATUS findObject(OBJECT* parent, CSTR& path, OBJECT*& pObject) {
383 return _CALL(m_current.dataProvider, findObject, (parent, path, pObject));
384 }
386 virtual STATUS findObject(OBJECT* parent, int item, OBJECT*& pObject) {
387 return _CALL(m_current.dataProvider, findObject, (parent, item, pObject));
388 }
390 virtual STATUS linkObject(IRegistry* from, CSTR& objPath, OBJECT* to) {
391 return _CALL(m_current.dataProvider, linkObject, (from, objPath, to));
392 }
394 virtual STATUS linkObject(CSTR& from, CSTR& objPath, OBJECT* to) {
395 return _CALL(m_current.dataProvider, linkObject, (from, objPath, to));
396 }
398 virtual STATUS linkObject(OBJECT* from, CSTR& objPath, OBJECT* to) {
399 return _CALL(m_current.dataProvider, linkObject, (from, objPath, to));
400 }
402 virtual STATUS linkObject(CSTR& fullPath, OBJECT* to) {
403 return _CALL(m_current.dataProvider, linkObject, (fullPath, to));
404 }
406 virtual STATUS unlinkObject(IRegistry* from, CSTR& objPath) {
407 return _CALL(m_current.dataProvider, unlinkObject, (from, objPath));
408 }
410 virtual STATUS unlinkObject(CSTR& from, CSTR& objPath) {
411 return _CALL(m_current.dataProvider, unlinkObject, (from, objPath));
412 }
414 virtual STATUS unlinkObject(OBJECT* from, CSTR& objPath) {
415 return _CALL(m_current.dataProvider, unlinkObject, (from, objPath));
416 }
418 virtual STATUS unlinkObject(CSTR& path) {
419 return _CALL(m_current.dataProvider, unlinkObject, (path));
420 }
422 virtual STATUS updateObject(IRegistry* pDirectory ) {
423 return _CALL(m_current.dataProvider, updateObject, (pDirectory));
424 }
426 virtual STATUS updateObject(CSTR& path) {
427 return _CALL(m_current.dataProvider, updateObject, (path));
428 }
430 virtual STATUS updateObject(OBJECT* pObj ) {
431 return _CALL(m_current.dataProvider, updateObject, (pObj));
432 }
434 virtual STATUS updateObject(CSTR& parent, CSTR& updatePath ) {
435 return _CALL(m_current.dataProvider, updateObject, (parent, updatePath));
436 }
438 virtual STATUS updateObject(OBJECT* parent, CSTR& updatePath) {
439 return _CALL(m_current.dataProvider, updateObject, (parent, updatePath));
440 }
441
443 virtual STATUS create(CSTR& nam, CSTR& typ) {
444 IInterface* pPartition = 0;
445 return create(nam, typ, pPartition);
446 }
447
449 virtual STATUS create(CSTR& nam, CSTR& typ, IInterface*& pPartition) {
450 STATUS sc = get(nam, pPartition);
451 if ( !sc.isSuccess() ) {
452 Gaudi::Utils::TypeNameString item(typ);
454 SmartIF<IService>& isvc = serviceLocator()->service(typ);
455 if (isvc.isValid()) {
456 SmartIF<IDataManagerSvc> dataMgr(isvc);
457 SmartIF<IDataProviderSvc> dataProv(isvc);
458 if ( dataMgr.isValid() && dataProv.isValid() ) {
459 Partition p;
460 p.name = nam;
461 p.dataManager = dataMgr;
462 p.dataProvider = dataProv;
463 p.dataManager->addRef();
464 p.dataProvider->addRef();
465 m_partitions.insert(std::make_pair(nam, p));
466 return STATUS::SUCCESS;
467 }
468 else {
469 // Error
470 return NO_INTERFACE;
471 }
472 }
473 else {
474 // Error
475 return NO_INTERFACE;
476 }
477 }
478 return PARTITION_EXISTS;
479 }
480
482 virtual STATUS drop(CSTR& nam) {
483 Partitions::iterator i = m_partitions.find(nam);
484 if ( i != m_partitions.end() ) {
485 if ( (*i).second.dataManager == m_current.dataManager ) {
486 m_current = Partition();
487 }
488 (*i).second.dataManager->clearStore().ignore();
489 (*i).second.dataProvider->release();
490 (*i).second.dataManager->release();
491 m_partitions.erase(i);
492 return STATUS::SUCCESS;
493 }
494 return PARTITION_NOT_PRESENT;
495 }
496
498 virtual STATUS drop(IInterface* pPartition) {
499 SmartIF<IDataProviderSvc> provider(pPartition);
500 if ( provider.isValid() ) {
501 Partitions::iterator i;
502 for(i=m_partitions.begin(); i != m_partitions.end(); ++i) {
503 if ( (*i).second.dataProvider == provider ) {
504 (*i).second.dataManager->clearStore().ignore();
505 (*i).second.dataProvider->release();
506 (*i).second.dataManager->release();
507 m_partitions.erase(i);
508 return STATUS::SUCCESS;
509 }
510 }
511 return PARTITION_NOT_PRESENT;
512 }
513 return NO_INTERFACE;
514 }
515
517 virtual STATUS activate(CSTR& nam) {
518 Partitions::const_iterator i = m_partitions.find(nam);
519 if ( i != m_partitions.end() ) {
520 m_current = (*i).second;
521 return STATUS::SUCCESS;
522 }
523 m_current = Partition();
524 return PARTITION_NOT_PRESENT;
525 }
526
528 virtual STATUS activate(IInterface* pPartition) {
529 SmartIF<IDataProviderSvc> provider(pPartition);
530 m_current = Partition();
531 if ( provider ) {
532 Partitions::iterator i;
533 for(i=m_partitions.begin(); i != m_partitions.end(); ++i) {
534 if ( (*i).second.dataProvider == provider ) {
535 m_current = (*i).second;
536 return STATUS::SUCCESS;
537 }
538 }
539 return PARTITION_NOT_PRESENT;
540 }
541 return NO_INTERFACE;
542 }
543
545 virtual STATUS get(CSTR& nam, IInterface*& pPartition) const {
546 Partitions::const_iterator i = m_partitions.find(nam);
547 if ( i != m_partitions.end() ) {
548 pPartition = (*i).second.dataProvider;
549 return STATUS::SUCCESS;
550 }
551 pPartition = 0;
552 return PARTITION_NOT_PRESENT;
553 }
554
556 virtual StatusCode activePartition(std::string& nam, IInterface*& pPartition) const {
557 if ( m_current.dataProvider ) {
558 nam = m_current.name;
559 pPartition = m_current.dataProvider;
560 return STATUS::SUCCESS;
561 }
562 nam = "";
563 pPartition = 0;
564 return NO_ACTIVE_PARTITION;
565 }
566
567 STATUS attachServices() {
568 MsgStream log(msgSvc(), name());
569 // Attach address creator facility
570 STATUS sc = service(m_loader, m_addrCreator, true);
571 if (!sc.isSuccess()) {
572 log << MSG::ERROR
573 << "Failed to retrieve data loader "
574 << "\"" << m_loader << "\"" << endmsg;
575 return sc;
576 }
577 IConversionSvc* dataLoader = 0;
578 // Attach data loader facility
579 sc = service(m_loader, dataLoader, true);
580 if (!sc.isSuccess()) {
581 log << MSG::ERROR << "Failed to retrieve data loader "
582 << "\"" << m_loader << "\"" << endmsg;
583 return sc;
584 }
585 sc = setDataLoader(dataLoader);
586 dataLoader->release();
587 if (!sc.isSuccess()) {
588 log << MSG::ERROR << "Failed to set data loader "
589 << "\"" << m_loader << "\"" << endmsg;
590 return sc;
591 }
592 return sc;
593 }
594
595 STATUS detachServices() {
596 if ( m_addrCreator ) m_addrCreator->release();
597 if ( m_dataLoader ) m_dataLoader->release();
598 m_addrCreator = 0;
599 m_dataLoader = 0;
600 return STATUS::SUCCESS;
601 }
602
604 virtual STATUS initialize() {
605 // Nothing to do: just call base class initialisation
606 STATUS sc = Service::initialize();
607 if ( !sc.isSuccess() ) {
608 return sc;
609 }
610 sc = makePartitions();
611 if (!sc.isSuccess()) {
612 MsgStream log(msgSvc(), name());
613 log << MSG::ERROR << "Failed to connect to all store partitions." << endmsg;
614 return sc;
615 }
616 return attachServices();
617 }
618
620 virtual STATUS reinitialize() {
621 STATUS sc = Service::reinitialize();
622 MsgStream log(msgSvc(), name());
623 if (!sc.isSuccess()) {
624 log << MSG::ERROR << "Enable to reinitialize base class"
625 << endmsg;
626 return sc;
627 }
628 detachServices();
629 sc = attachServices();
630 if ( !sc.isSuccess() ) {
631 log << MSG::ERROR << "Failed to attach necessary services." << endmsg;
632 return sc;
633 }
634 sc = makePartitions();
635 if (!sc.isSuccess()) {
636 log << MSG::ERROR << "Failed to connect to store partitions." << endmsg;
637 return sc;
638 }
639 // return
640 return STATUS::SUCCESS;
641 }
642
644 virtual STATUS finalize() {
645 setDataLoader(0).ignore();
646 clearStore().ignore();
647 clearPartitions().ignore();
648 m_current = Partition();
649 detachServices();
650 return Service::finalize();
651 }
652
653
654 //protected:
655
657 MultiStoreSvc( CSTR& name, ISvcLocator* svc )
658 : base_class(name,svc), m_rootCLID(110), m_rootName("/Event"),
659 m_dataLoader(0), m_addrCreator(0)
660 {
661 m_dataLoader = 0;
662 declareProperty("RootCLID", m_rootCLID);
663 declareProperty("RootName", m_rootName);
664 declareProperty("Partitions", m_partitionDefs);
665 declareProperty("DataLoader", m_loader="EventPersistencySvc");
666 declareProperty("DefaultPartition", m_defaultPartition="Default");
667 }
668
670 virtual ~MultiStoreSvc() {
671 setDataLoader(0).ignore();
672 resetPreLoad().ignore();
673 clearStore().ignore();
674 clearPartitions().ignore();
675 }
676
678 STATUS preparePartitions() {
679 STATUS iret = STATUS::SUCCESS;
680 for(Partitions::iterator i=m_partitions.begin(); i != m_partitions.end(); ++i) {
681 STATUS sc = STATUS::FAILURE;
682 switch ( m_root.type ) {
683 case address_type:
684 if ( m_root.root.address ) {
685 ADDRESS* pAdd = 0;
686 ADDRESS* p = m_root.root.address;
687 sc = m_addrCreator->createAddress(p->svcType(),
688 p->clID(),
689 p->par(),
690 p->ipar(),
691 pAdd);
692 if ( sc.isSuccess() ) {
693 sc = (*i).second.dataManager->setRoot(m_root.path, pAdd);
694 }
695 }
696 break;
697 case object_type:
698 if ( m_root.root.object ) {
699 if ( m_root.root.object->clID() == CLID_DataObject ) {
700 DataObject* pObj = new DataObject();
701 sc = (*i).second.dataManager->setRoot(m_root.path, pObj);
702 }
703 }
704 break;
705 default:
706 sc = STATUS::FAILURE;
707 break;
708 }
709 if ( !sc.isSuccess() ) {
710 iret = sc;
711 }
712 }
713 return iret;
714 }
715
717 STATUS clearPartitions() {
718 Partitions::iterator i;
719 for(i=m_partitions.begin(); i != m_partitions.end(); ++i) {
720 (*i).second.dataManager->clearStore().ignore();
721 (*i).second.dataProvider->release();
722 (*i).second.dataManager->release();
723 }
724 m_partitions.clear();
725 return STATUS::SUCCESS;
726 }
727
729 STATUS makePartitions() {
730 std::string typ, nam;
731 PartitionDefs::iterator j;
732 clearPartitions().ignore();
733 for(j=m_partitionDefs.begin(); j != m_partitionDefs.end(); ++j) {
734 Tokenizer tok(true);
735 Tokenizer::Items::iterator i;
736 tok.analyse(*j, " ", "", "", "=", "'", "'");
737 for(i = tok.items().begin(); i != tok.items().end(); i++ ) {
738 CSTR& t = (*i).tag();
739 CSTR& v = (*i).value();
740 switch( ::toupper(t[0]) ) {
741 case 'N':
742 nam = v;
743 break;
744 case 'T':
745 typ = v;
746 break;
747 }
748 }
749 STATUS sc = create(nam, typ);
750 if ( !sc.isSuccess() ) {
751 return sc;
752 }
753 else if ( !m_defaultPartition.length() ) {
754 m_defaultPartition = nam;
755 }
756 }
757 return STATUS::SUCCESS;
758 }
759 };
760
761 // Instantiation of a static factory class used by clients to create
762 // instances of this service
763 DECLARE_COMPONENT(MultiStoreSvc)