00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _IPADDRESS_H_
00034 #define _IPADDRESS_H_
00035
00036
00037
00038
00039 #include <list>
00040
00041
00042 #include "osberror.h"
00043 #include "resource.h"
00044 #include "resourceitem.h"
00045
00046
00047
00048 namespace OSB_DB {
00049 class Session;
00050 class Ip4AddressGw;
00051 class IpGroupGw;
00052 }
00053
00054
00055
00056 namespace OSB_LIB {
00057 class IpGroup;
00058
00059
00060
00061
00062
00063
00064
00065
00066
00073 class Ip4Address : public Resource {
00075 friend class OSB_DB::Ip4AddressGw;
00077 friend class IpGroup;
00078 private:
00080 static const Type typeId_ = rtIp4Address;
00081
00082 public:
00084 Ip4Address(const Oid& id = Oid());
00085
00093 Ip4Address(
00094 const Number& rn,
00095 const Id<Network>& nw
00096 );
00097
00099
00100
00101 Type typeId() const;
00103 const std::string& des() const;
00113 bool canUpd() const;
00115 bool canSetGroup() const;
00117
00119 void setDes(const std::string& des);
00120
00127 bool isAvailable() const;
00128
00130
00131
00132 bool read(const OSB_DB::Session& session);
00133
00135 bool insert(const OSB_DB::Session& session);
00136
00138 void updData(const OSB_DB::Session& session);
00139
00141 bool remove(const OSB_DB::Session& session);
00143
00144 private:
00155 void verify() const;
00156
00157 private:
00159 std::string des_;
00160 };
00161
00162
00163
00168 struct AssignableIp4 {
00170 Id<Ip4Address> ip4Id_;
00172 Id2<NetworkElement> neId_;
00174 bool in_;
00176 bool out_;
00177
00179 Id<Resource> resourceId() const
00180 {
00181 return Id<Resource>(ip4Id_.id());
00182 }
00184 Id<Network> networkId() const
00185 {
00186 return Id<Network>(neId_.id1_);
00187 }
00188 };
00189
00191 typedef std::list<AssignableIp4> AssignableIp4s;
00192
00193
00194
00201 class IpGroup : public Resource {
00203 friend class OSB_DB::IpGroupGw;
00204 private:
00206 static const Type typeId_ = rtIpGroup;
00207
00208 public:
00210
00211
00214 enum Direction {
00215 dirUnknown = '?',
00216 dirIn = 'i',
00217 dirOut = 'o'
00218 };
00226 static char toChar(Direction dir);
00234 static Direction direction(char c);
00236
00238 struct AssignedIp4 {
00240 Ip4Address ip4_;
00242 Direction dir_;
00244 DateTime from_;
00246 DateTime to_;
00247 };
00248
00250 typedef std::list<AssignedIp4> AssignedIp4s;
00251
00253 IpGroup(const Oid& id = Oid());
00254
00262 IpGroup(
00263 const Number& rn,
00264 const Id<Network>& nw
00265 );
00266
00268
00269
00270 Type typeId() const;
00272 const std::string& des() const;
00274 const AssignedIp4s& assignedIp4s() const;
00276 const AssignedIp4s curAssignedIp4s() const;
00278
00295 bool addIp4(
00296 const OSB_DB::Session& session,
00297 const Date& start,
00298 Ip4Address& ip4,
00299 Direction dir
00300 );
00301
00318 bool delIp4(
00319 const OSB_DB::Session& session,
00320 Ip4Address& ip4,
00321 Direction dir
00322 );
00323
00325
00326
00327 void setDes(const std::string& des);
00328
00329 private:
00338 bool assign(
00339 const AssignedIp4& assignedIp4
00340 );
00341
00353 bool deassign(
00354 const Ip4Address& ip4,
00355 Direction dir
00356 );
00358
00359 public:
00361
00362 bool read(const OSB_DB::Session& session);
00363 bool insert(const OSB_DB::Session& session);
00364 void updData(const OSB_DB::Session& session);
00365 bool remove(const OSB_DB::Session& session);
00367
00373 void sortIp4sByPriority();
00374
00381 void sortIp4sByResNum(bool desc = false);
00382
00383 private:
00385 std::string des_;
00387 AssignedIp4s assignedIp4s_;
00388
00389 private:
00401 bool changeIp4Status(
00402 const OSB_DB::Session& session,
00403 Ip4Address& ip4
00404 ) const;
00405 };
00406
00407
00408
00412 class PersIpGroup : public PersResource {
00413 public:
00415 static const Type type_;
00416
00417
00418 typedef std::auto_ptr<PersIpGroup> AutoPtr;
00419
00420 public:
00422 PersIpGroup(const Oid& oid = Oid());
00423
00425 PersIpGroup(const PersIpGroup& rhs);
00426
00428 PersIpGroup& operator=(const PersIpGroup& rhs);
00429
00431 ~PersIpGroup();
00432
00433 public:
00434
00435 Type type() const;
00436
00437 AutoPtr clone() const;
00438
00439 public:
00446 bool canConfig() const;
00447
00449 void assign(const IpGroup& ipg);
00450
00451
00452 const Resource* resource() const;
00453
00455 const Resource* oldResource() const;
00456
00457 private:
00458
00459 PersProductItem* clone_() const;
00460
00461
00462 Resource* resource();
00463
00464 Resource* oldResource();
00465
00466
00467 Resource* createResource(
00468 const Resource::Oid& resourceId
00469 );
00470
00478
00479 bool readSpecific(
00480 const OSB_DB::Session& session
00481 );
00482
00484 bool insSpecific(
00485 const OSB_DB::Session& session
00486 );
00487
00489 bool updSpecific(
00490 const OSB_DB::Session& session
00491 );
00492
00494 bool delSpecific(
00495 const OSB_DB::Session& session
00496 );
00498
00499 private:
00501 IpGroup* pIpGroup_;
00503 IpGroup* pOldIpGroup_;
00504 };
00505
00506
00507
00511 class IpGroupItem : public ResourceItem {
00512 public:
00514 static const Type type_;
00515
00516
00517 typedef std::auto_ptr<IpGroupItem> AutoPtr;
00518
00526 IpGroupItem(
00527 const Oid& oid,
00528 const std::string& name = "",
00529 const std::string& des = ""
00530 );
00531
00532 public:
00533
00534 Type type() const;
00535
00536 AutoPtr clone() const;
00537
00544 ProductItem::CfgType canConfigure() const;
00545
00552 ProductItem::DefPersType canDefPers() const;
00553
00560 CfgPersType canPersonalize() const;
00561
00563 const PersProductItem* defPersItem() const;
00564
00571 std::auto_ptr<PersProductItem> crePersProductItem() const;
00572
00573 private:
00574
00575 ProductItem* clone_() const;
00576
00583
00584 bool readSpecific(
00585 const OSB_DB::Session& session
00586 );
00588 bool insSpecific(
00589 const OSB_DB::Session& session
00590 );
00592 bool updSpecific(
00593 const OSB_DB::Session& session
00594 );
00596 bool delSpecific(
00597 const OSB_DB::Session& session
00598 );
00600 };
00601
00602
00603
00604
00605 }
00606 #endif // #ifndef _IPADDRESS_H_