00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _CPMAPPER_H_
00039 #define _CPMAPPER_H_
00040
00041
00042
00043
00044 #include <memory>
00045 #include <string>
00046 #include <vector>
00047 #include <list>
00048
00049
00050 #include "osbid.h"
00051 #include "osbtype.h"
00052 #include "chrono.h"
00053
00054
00055 namespace OSB_LIB {
00056 template<typename T> class Id;
00057 class Cdr;
00058 class UsedService;
00059 class TariffCatalogue;
00060 class ConnectionPt;
00061 }
00062
00063 namespace OSB_DB {
00064 class Session;
00065 }
00066
00067
00068
00069 namespace OSB_LIB {
00070
00071
00072
00073
00074
00075
00079 class CpMapper {
00080 public:
00082 typedef TypeId<CpMapper> Type;
00095 enum CpmType {
00096 cpmCgi = 1,
00097 cpmCalledParty = 2,
00098 cpmCallingParty = 3,
00099 cpmNetwork = 4,
00100 cpmNwElement = 5,
00101 cpmMsrn = 6,
00102 cpmServedParty = 7
00103
00104 };
00106 static const CpmType cpmMax_ = cpmServedParty;
00107
00114 typedef std::auto_ptr<CpMapper> AutoPtr;
00115
00116 public:
00118 virtual ~CpMapper() {}
00119
00125 AutoPtr clone() const;
00126
00138 virtual Id<ConnectionPt> map2Cp(Cdr& cdr) const = 0;
00139
00141 virtual Type type() const = 0;
00148 CpmType cpmType() const;
00149 public:
00151 static CpmType cpmType(const Type& type);
00152 private:
00158 virtual CpMapper* clone_() const = 0;
00159 };
00160
00161
00162
00169 class CpMapperList {
00170 public:
00172 struct Info {
00173 CpMapper::Type type_;
00174 std::string name_;
00175 std::string des_;
00176 };
00177
00179 typedef std::vector<Info> InfoList;
00181 typedef InfoList::const_iterator ConstIterator;
00182
00193 long read(const OSB_DB::Session& session);
00194
00196 ConstIterator begin() const { return infoList_.begin(); }
00198 ConstIterator end() const { return infoList_.end(); }
00200 const InfoList& infoList() const { return infoList_; }
00201
00210 const Info* findInfo(CpMapper::Type type) const;
00211
00219 const Info* findInfo(const std::string& name) const;
00220
00228 const Info& getInfo(CpMapper::Type type) const;
00229
00237 const Info& getInfo(const std::string& name) const;
00238
00239 private:
00240 InfoList infoList_;
00241
00243 Info* find(CpMapper::Type type);
00245 Info* find(const std::string& name);
00246 };
00247
00248
00249
00263 class CpMapperFactory {
00264 private:
00266 CpMapperFactory();
00268 ~CpMapperFactory();
00270 CpMapperFactory(const CpMapperFactory&);
00272 CpMapperFactory& operator=(CpMapperFactory&);
00273 public:
00293 static CpMapper::AutoPtr mkCpMapper(
00294 CpMapper::Type type
00295 );
00296 };
00297
00298
00299
00312 struct MappedCp {
00313 Id<ConnectionPt> cpId_;
00314 DateTime cpStart_;
00315 DateTime cpEnd_;
00316
00318 MappedCp();
00320 MappedCp(const ConnectionPt& cp);
00329
00330
00345 bool withinPeriod(const DateTime& ts) const;
00346 };
00347
00348
00349
00354 class MappedPartInfo {
00358 friend class MappedPartInfoList;
00359
00360 public:
00368 MappedPartInfo(
00369 const ConnectionPt& cp,
00370 const DateTime& startTs,
00371 const DateTime& endTs
00372 );
00373
00386 bool withinPeriod(const DateTime& ts) const;
00387
00389 void print(std::ostream& os, std::string spacer) const;
00390
00391 private:
00393 MappedCp mappedCp_;
00395 DateTime startTs_;
00397 DateTime endTs_;
00398 };
00399
00400
00401
00409 class MappedPartInfoList {
00410 public:
00412 typedef std::list<MappedPartInfo> MappedPartInfos;
00413
00415 std::list<MappedPartInfo> mappedInfo_;
00416
00425 void add(const MappedPartInfo& info);
00426
00437 void map2Cp(Id<ConnectionPt>& cpId, const DateTime& ts) const;
00438
00440 void print(std::ostream& os, std::string spacer) const;
00441 };
00442 }
00443 #endif // #ifndef _CPMAPPER_H_