00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _TCATLOCKMANAGER_H_
00031 #define _TCATLOCKMANAGER_H_
00032
00033
00034
00035
00036 #include <string>
00037
00038
00039 #include "mutex.h"
00040 #include "tariffcatalogue.h"
00041
00042
00043
00044 namespace OSB_LIB {
00045
00053 class TcatLockManager {
00055 class UnlockAll : public Guard::Cleanup {
00056 public:
00062 UnlockAll(std::list<RwMutex*> lMutex);
00063
00073 virtual int cleanup();
00074 private:
00080 std::list<RwMutex*> lMutex_;
00081 };
00082
00089 friend class TariffCatalogue;
00090
00108
00109 typedef Guard TcatGuard;
00111 TcatGuard tcatGuard();
00113
00114 public:
00116
00117
00118 typedef Guard TariffObjectsGuard;
00120 TariffObjectsGuard tariffObjectsGuard();
00122
00124
00125
00126 typedef ReadGuard<SpecialDate*> SpecialDateRg;
00128 typedef ReadGuard<SpecialDates*> SpecialDatesRg;
00130 typedef ReadGuard<DayClass*> DayClassRg;
00132 typedef ReadGuard<DayClasses*> DayClassesRg;
00134 typedef ReadGuard<TariffPeriod*> TariffPeriodRg;
00136 typedef ReadGuard<TariffPeriods*> TariffPeriodsRg;
00138 typedef ReadGuard<TpSystem*> TpSystemRg;
00140 typedef ReadGuard<TpSystems*> TpSystemsRg;
00142 typedef ReadGuard<TpsVersion*> TpsVersionRg;
00144 typedef ReadGuard<TpsVersions*> TpsVersionsRg;
00146
00148
00149
00150 typedef ReadGuard<ConnectionPt*> ConnectionPtRg;
00152 typedef ReadGuard<CpTree*> CpTreeRg;
00154 typedef ReadGuard<Cgi*> CgiRg;
00156 typedef ReadGuard<Cgis*> CgisRg;
00158 typedef ReadGuard<E164*> E164Rg;
00160 typedef ReadGuard<E164s*> E164sRg;
00162 typedef ReadGuard<E164Map*> E164MapRg;
00164 typedef ReadGuard<TariffClass*> TariffClassRg;
00166 typedef ReadGuard<TariffClasses*> TariffClassesRg;
00168 typedef ReadGuard<TariffZone*> TariffZoneRg;
00170 typedef ReadGuard<TariffZones*> TariffZonesRg;
00172 typedef ReadGuard<TcSystem*> TcSystemRg;
00174 typedef ReadGuard<TcSystems*> TcSystemsRg;
00176 typedef ReadGuard<TcsVersion*> TcsVersionRg;
00178 typedef ReadGuard<TcsVersions*> TcsVersionsRg;
00180 typedef ReadGuard<TzConfig*> TzConfigRg;
00182 typedef ReadGuard<TzConfigs*> TzConfigsRg;
00184
00186
00187
00188 typedef ReadGuard<ServiceElement*> ServiceElementRg;
00190 typedef ReadGuard<SeTree*> SeTreeRg;
00192 typedef ReadGuard<RatedService*> RatedServiceRg;
00194 typedef ReadGuard<RatedServices*> RatedServicesRg;
00196 typedef ReadGuard<ServiceClass*> ServiceClassRg;
00198 typedef ReadGuard<ServiceClasses*> ServiceClassesRg;
00200 typedef ReadGuard<ScSystem*> ScSystemRg;
00202 typedef ReadGuard<ScSystems*> ScSystemsRg;
00204 typedef ReadGuard<ScsVersion*> ScsVersionRg;
00206 typedef ReadGuard<ScsVersions*> ScsVersionsRg;
00208
00210
00211
00212 typedef ReadGuard<TariffSystem*> TariffSystemRg;
00214 typedef ReadGuard<TariffSystems*> TariffSystemsRg;
00216 typedef ReadGuard<TsVersion*> TsVersionRg;
00218 typedef ReadGuard<TsVersions*> TsVersionsRg;
00220
00222
00223
00224 typedef ReadGuard<Tariff*> TariffRg;
00226 typedef ReadGuard<Tariffs*> TariffsRg;
00228 typedef ReadGuard<TfVersion*> TfVersionRg;
00230 typedef ReadGuard<TfVersions*> TfVersionsRg;
00232
00234
00235
00236 typedef ReadGuard<RatingFn*> RatingFnRg;
00238 typedef ReadGuard<RatingFns*> RatingFnsRg;
00240
00248
00249 typedef WriteGuard<SpecialDate*> SpecialDateWg;
00251 typedef WriteGuard<SpecialDates*> SpecialDatesWg;
00253 typedef WriteGuard<DayClass*> DayClassWg;
00255 typedef WriteGuard<DayClasses*> DayClassesWg;
00257 typedef WriteGuard<TariffPeriod*> TariffPeriodWg;
00259 typedef WriteGuard<TariffPeriods*> TariffPeriodsWg;
00261 typedef WriteGuard<TpSystem*> TpSystemWg;
00263 typedef WriteGuard<TpSystems*> TpSystemsWg;
00265 typedef WriteGuard<TpsVersion*> TpsVersionWg;
00267 typedef WriteGuard<TpsVersions*> TpsVersionsWg;
00269
00277
00278 typedef WriteGuard<TariffSystem*> TariffSystemWg;
00280 typedef WriteGuard<TariffSystems*> TariffSystemsWg;
00282 typedef WriteGuard<TsVersion*> TsVersionWg;
00284 typedef WriteGuard<TsVersions*> TsVersionsWg;
00286
00294
00295 typedef WriteGuard<RatedService*> RatedServiceWg;
00297 typedef WriteGuard<RatedServices*> RatedServicesWg;
00299 typedef WriteGuard<ServiceClass*> ServiceClassWg;
00301 typedef WriteGuard<ServiceClasses*> ServiceClassesWg;
00303 typedef WriteGuard<ScSystem*> ScSystemWg;
00305 typedef WriteGuard<ScSystems*> ScSystemsWg;
00307 typedef WriteGuard<ScsVersion*> ScsVersionWg;
00309 typedef WriteGuard<ScsVersions*> ScsVersionsWg;
00311
00319
00320 typedef WriteGuard<ConnectionPt*> ConnectionPtWg;
00322 typedef WriteGuard<CpTree*> CpTreeWg;
00324 typedef WriteGuard<Cgi*> CgiWg;
00326 typedef WriteGuard<Cgis*> CgisWg;
00328 typedef WriteGuard<E164*> E164Wg;
00330 typedef WriteGuard<E164s*> E164sWg;
00332 typedef WriteGuard<E164Map*> E164MapWg;
00334 typedef WriteGuard<TariffClass*> TariffClassWg;
00336 typedef WriteGuard<TariffClasses*> TariffClassesWg;
00338 typedef WriteGuard<TariffZone*> TariffZoneWg;
00340 typedef WriteGuard<TariffZones*> TariffZonesWg;
00342 typedef WriteGuard<TcSystem*> TcSystemWg;
00344 typedef WriteGuard<TcSystems*> TcSystemsWg;
00346 typedef WriteGuard<TcsVersion*> TcsVersionWg;
00348 typedef WriteGuard<TcsVersions*> TcsVersionsWg;
00350 typedef WriteGuard<TzConfig*> TzConfigWg;
00352 typedef WriteGuard<TzConfigs*> TzConfigsWg;
00354
00362
00363 typedef WriteGuard<Tariff*> TariffWg;
00365 typedef WriteGuard<Tariffs*> TariffsWg;
00367 typedef WriteGuard<TfVersion*> TfVersionWg;
00369 typedef WriteGuard<TfVersions*> TfVersionsWg;
00371
00379
00380 typedef WriteGuard<RatingFn*> RatingFnWg;
00382 typedef WriteGuard<RatingFns*> RatingFnsWg;
00384
00390 TcatLockManager(
00391 TariffCatalogue& cat
00392 ) : cat_(cat),
00393 tsMutex_(RwMutex::prioRead),
00394 scMutex_(RwMutex::prioRead),
00395 tcMutex_(RwMutex::prioRead),
00396 tpMutex_(RwMutex::prioRead),
00397 tfMutex_(RwMutex::prioRead),
00398 tcatUnlock_(&tcatMutex_) {}
00399
00401 enum guardStatus {
00402 objectNotFound = 1
00403 };
00404
00405
00406
00407
00408
00410
00411
00412 SpecialDateRg readLock(const SpecialDate::Oid& id);
00413
00415 SpecialDatesRg readLockSds();
00416
00418 DayClassRg readLock(const DayClass::Oid& id);
00420 DayClassesRg readLockDcs();
00421
00423 TariffPeriodRg readLock(const TariffPeriod::Oid& id);
00425 TariffPeriodsRg readLockTps();
00426
00428 TpSystemRg readLock(const TpSystem::Oid& id);
00430 TpSystemsRg readLockTpss();
00431
00433 TpsVersionRg readLock(const TpsVersion::Oid& id);
00435 TpsVersionsRg readLockTpsVs();
00437
00438
00440
00441
00442 SpecialDateWg writeLock(const SpecialDate::Oid& id, bool noWait);
00443
00445 SpecialDatesWg writeLockSds(bool noWait);
00446
00448 DayClassWg writeLock(const DayClass::Oid& id, bool noWait);
00450 DayClassesWg writeLockDcs(bool noWait);
00451
00453 TariffPeriodWg writeLock(const TariffPeriod::Oid& id, bool noWait);
00455 TariffPeriodsWg writeLockTps(bool noWait);
00456
00458 TpSystemWg writeLock(const TpSystem::Oid& id, bool noWait);
00460 TpSystemsWg writeLockTpSystems(bool noWait);
00461
00463 TpsVersionWg writeLock(const TpsVersion::Oid& id, bool noWait);
00465 TpsVersionsWg writeLockTpsVs(bool noWait);
00467
00468
00469
00470
00471
00473
00474
00475 ConnectionPtRg readLock(const Id<ConnectionPt>& id);
00476
00478 CpTreeRg readLockCps();
00479
00481 CgiRg readLock(const Cgi::Oid& id);
00482
00484 CgisRg readLockCgis();
00485
00487 E164Rg readLock(const Id<E164>& id);
00488
00490 E164sRg readLockE164s();
00491
00493 E164MapRg readLockE164Map();
00494
00496 TariffClassRg readLock(const TariffClass::Oid& id);
00497
00499 TariffClassesRg readLockTcs();
00500
00502 TariffZoneRg readLock(const TariffZone::Oid& id);
00503
00505 TariffZonesRg readLockTzs();
00506
00508 TcSystemRg readLock(const TcSystem::Oid& id);
00509
00511 TcSystemsRg readLockTcses();
00512
00514 TcsVersionRg readLock(const TcsVersion::Oid& id);
00515
00517 TcsVersionsRg readLockTcsVs();
00518
00520 TzConfigRg readLock(const TzConfig::Oid& id);
00521
00523 TzConfigsRg readLockTzCfgs();
00525
00526
00527
00528
00529
00531
00532
00533 ServiceElementRg readLock(const ServiceElement::Oid& id);
00534
00536 SeTreeRg readLockSes();
00537
00539 RatedServiceRg readLock(const RatedService::Oid& id);
00540
00542 RatedServicesRg readLockRss();
00543
00545 ServiceClassRg readLock(const ServiceClass::Oid& id);
00546
00548 ServiceClassesRg readLockScs();
00549
00551 ScSystemRg readLock(const ScSystem::Oid& id);
00552
00554 ScSystemsRg readLockAllScs();
00555
00557 ScsVersionRg readLock(const ScsVersion::Oid& id);
00558
00560 ScsVersionsRg readLockScsVs();
00562
00563
00564
00565
00566
00568
00569
00570 TariffSystemRg readLock(const TariffSystem::Oid& id);
00571
00573 TariffSystemsRg readLockTss();
00574
00576 TsVersionRg readLock(const TsVersion::Oid& id);
00577
00579 TsVersionsRg readLockTsVs();
00581
00582
00583
00584
00585
00587
00588
00589 TariffRg readLock(const Tariff::Oid& id);
00590
00592 TariffsRg readLockTariffs();
00593
00595 TfVersionRg readLock(const TfVersion::Oid& id);
00596
00598 TfVersionsRg readLockTfVs();
00599
00601 RatingFnRg readLock(const RatingFn::Oid& id);
00602
00604 RatingFnsRg readLockRatingFns();
00606
00607
00608
00609
00611
00612
00613 ConnectionPtWg writeLock(const Id<ConnectionPt>& id, bool noWait);
00614
00616 CpTreeWg writeLockConnectionPts(bool noWait);
00617
00619 CgiWg writeLock(const Cgi::Oid& id, bool noWait);
00620
00622 CgisWg writeLockCgis(bool noWait);
00623
00625 E164Wg writeLock(const Id<E164>& id, bool noWait);
00626
00628 E164sWg writeLockE164s(bool noWait);
00629
00631 E164MapWg writeLockE164Map(bool noWait);
00632
00634 TariffClassWg writeLock(const TariffClass::Oid& id, bool noWait);
00635
00637 TariffClassesWg writeLockTcs(bool noWait);
00638
00640 TariffZoneWg writeLock(const TariffZone::Oid& id, bool noWait);
00641
00643 TariffZonesWg writeLockTzs(bool noWait);
00644
00646 TcSystemWg writeLock(const TcSystem::Oid& id, bool noWait);
00647
00649 TcSystemsWg writeLockTcses(bool noWait);
00650
00652 TcsVersionWg writeLock(const TcsVersion::Oid& id, bool noWait);
00653
00658 TcsVersionsWg writeLockTcsVs(bool noWait);
00659
00661 TzConfigWg writeLock(const TzConfig::Oid& id, bool noWait);
00662
00664 TzConfigsWg writeLockTzCfgs(bool noWait);
00666
00667
00668
00669
00670
00672
00673
00674 RatedServiceWg writeLock(const RatedService::Oid& id, bool noWait);
00675
00677 RatedServicesWg writeLockRss(bool noWait);
00678
00680 ServiceClassWg writeLock(const ServiceClass::Oid& id, bool noWait);
00681
00683 ServiceClassesWg writeLockScs(bool noWait);
00684
00686 ScSystemWg writeLock(const ScSystem::Oid& id, bool noWait);
00687
00689 ScSystemsWg writeLockAllScs(bool noWait);
00690
00692 ScsVersionWg writeLock(const ScsVersion::Oid& id, bool noWait);
00693
00695 ScsVersionsWg writeLockScsVs(bool noWait);
00697
00698
00699
00700
00701
00703
00704
00705 TariffSystemWg writeLock(const TariffSystem::Oid& id, bool noWait);
00706
00708 TariffSystemsWg writeLockTss(bool noWait);
00709
00711 TsVersionWg writeLock(const TsVersion::Oid& id, bool noWait);
00712
00714 TsVersionsWg writeLockTsVs(bool noWait);
00716
00717
00718
00719
00720
00722
00723
00724 TariffWg writeLock(const Tariff::Oid& id, bool noWait);
00725
00727 TariffsWg writeLockTariffs(bool noWait);
00728
00730 TfVersionWg writeLock(const TfVersion::Oid& id, bool noWait);
00731
00733 TfVersionsWg writeLockTfVs(bool noWait);
00734
00736 RatingFnWg writeLock(const RatingFn::Oid& id, bool noWait);
00737
00739 RatingFnsWg writeLockRatingFns(bool noWait);
00741 private:
00742 TariffCatalogue& cat_;
00743 RwMutex tsMutex_;
00744 RwMutex scMutex_;
00745 RwMutex tcMutex_;
00746 RwMutex tpMutex_;
00747 RwMutex tfMutex_;
00748 Mutex tcatMutex_;
00749 MutexUnlock tcatUnlock_;
00750 };
00751 }
00752 #endif // #ifndef _TCATLOCKMANAGER_H_