00001
00002
00003
00004
00005 #ifndef ACE_RMCAST_PROTOCOL_H
00006 #define ACE_RMCAST_PROTOCOL_H
00007
00008 #include "ace/Auto_Ptr.h"
00009 #include "ace/Bound_Ptr.h"
00010
00011 #include "ace/Vector_T.h"
00012 #include "ace/Hash_Map_Manager.h"
00013
00014 #include "ace/CDR_Stream.h"
00015 #include "ace/CDR_Size.h"
00016
00017 #include "ace/INET_Addr.h"
00018 #include "ace/Null_Mutex.h"
00019
00020 #include "ace/OS_NS_string.h"
00021 #include "ace/OS_NS_stdlib.h"
00022
00023 #include "Bits.h"
00024
00025
00026
00027
00028
00029 namespace ACE_RMCast
00030 {
00031
00032
00033 typedef ACE_CDR::UShort u16;
00034 typedef ACE_CDR::ULong u32;
00035 typedef ACE_CDR::ULongLong u64;
00036
00037
00038
00039
00040 unsigned short const max_service_size = 60;
00041
00042
00043
00044
00045
00046 typedef ACE_INET_Addr Address;
00047
00048 struct AddressHasher
00049 {
00050 unsigned long
00051 operator() (Address const& a) const
00052 {
00053 unsigned long port (a.get_port_number ());
00054 unsigned long ip (a.get_ip_address ());
00055
00056 port <<= sizeof (unsigned long) - sizeof (unsigned short);
00057
00058 return port ^ ip;
00059 }
00060 };
00061
00062
00063
00064
00065 typedef ACE_OutputCDR ostream;
00066 typedef ACE_SizeCDR sstream;
00067 typedef ACE_InputCDR istream;
00068
00069 struct Profile;
00070
00071 typedef
00072 ACE_Strong_Bound_Ptr<Profile, Mutex>
00073 Profile_ptr;
00074
00075 struct Profile
00076 {
00077 public:
00078 class Header
00079 {
00080 public:
00081 Header (u16 id, u16 size)
00082 : id_ (id), size_ (size)
00083 {
00084 }
00085
00086 Header (istream& is)
00087 {
00088 (void) (is >> id_ >> size_);
00089 }
00090
00091 public:
00092 u16
00093 id () const
00094 {
00095 return id_;
00096 }
00097
00098 u16
00099 size () const
00100 {
00101 return size_;
00102 }
00103
00104 protected:
00105 void
00106 size (u16 s)
00107 {
00108 size_ = s;
00109 }
00110
00111 friend struct Profile;
00112
00113 private:
00114 u16 id_;
00115 u16 size_;
00116 };
00117
00118 public:
00119 virtual
00120 ~Profile ()
00121 {
00122 }
00123
00124 Profile_ptr
00125 clone ()
00126 {
00127 Profile_ptr p (clone_ ());
00128 return p;
00129 }
00130
00131 protected:
00132 Profile (u16 id)
00133 : header_ (id, 0)
00134 {
00135 }
00136
00137 Profile (Header const& h)
00138 : header_ (h)
00139 {
00140 }
00141
00142 virtual Profile_ptr
00143 clone_ () = 0;
00144
00145 private:
00146 Profile&
00147 operator= (Profile const&);
00148
00149 public:
00150 u16
00151 id () const
00152 {
00153 return header_.id ();
00154 }
00155
00156 u16
00157 size () const
00158 {
00159 return header_.size ();
00160 }
00161
00162 protected:
00163 void
00164 size (u16 s)
00165 {
00166 header_.size (s);
00167 }
00168
00169 u16
00170 calculate_size ()
00171 {
00172 sstream ss;
00173
00174 serialize_body (ss);
00175
00176 return static_cast<u16> (ss.total_length ());
00177 }
00178
00179 public:
00180 virtual void
00181 serialize_body (ostream&) const = 0;
00182
00183 virtual void
00184 serialize_body (sstream&) const = 0;
00185
00186 friend
00187 ostream&
00188 operator<< (ostream& os, Profile const& p);
00189
00190 friend
00191 sstream&
00192 operator<< (sstream& ss, Profile const& p);
00193
00194 private:
00195 Header header_;
00196 };
00197
00198 inline
00199 ostream&
00200 operator<< (ostream& os, Profile::Header const& hdr)
00201 {
00202 os << hdr.id ();
00203 os << hdr.size ();
00204
00205 return os;
00206 }
00207
00208 inline
00209 sstream&
00210 operator<< (sstream& ss, Profile::Header const& hdr)
00211 {
00212 ss << hdr.id ();
00213 ss << hdr.size ();
00214
00215 return ss;
00216 }
00217
00218 inline
00219 ostream&
00220 operator<< (ostream& os, Profile const& p)
00221 {
00222 os << p.header_;
00223 p.serialize_body (os);
00224
00225 return os;
00226 }
00227
00228 inline
00229 sstream&
00230 operator<< (sstream& ss, Profile const& p)
00231 {
00232 ss << p.header_;
00233 p.serialize_body (ss);
00234
00235 return ss;
00236 }
00237
00238
00239
00240
00241
00242 class Message;
00243
00244 typedef
00245 ACE_Strong_Bound_Ptr<Message, Mutex>
00246 Message_ptr;
00247
00248 class Message
00249 {
00250 typedef
00251 ACE_Hash_Map_Manager<u16, Profile_ptr, ACE_Null_Mutex>
00252 Profiles;
00253
00254 public:
00255 Message ()
00256 : profiles_ (4)
00257 {
00258 }
00259
00260 Message_ptr
00261 clone ()
00262 {
00263 Message_ptr cloned (new Message (*this));
00264 return cloned;
00265 }
00266
00267 protected:
00268 Message (Message const& m)
00269 : profiles_ (4)
00270 {
00271 for (Profiles::const_iterator i (m.profiles_); !i.done (); i.advance ())
00272 {
00273
00274
00275
00276 profiles_.bind ((*i).ext_id_, (*i).int_id_);
00277 }
00278 }
00279
00280 private:
00281 Message&
00282 operator= (Message const&);
00283
00284 public:
00285 bool
00286 add (Profile_ptr p)
00287 {
00288 u16 id (p->id ());
00289
00290 if (profiles_.find (id) == 0)
00291 {
00292 return false;
00293 }
00294
00295 profiles_.bind (id, p);
00296
00297 return true;
00298 }
00299
00300 void
00301 replace (Profile_ptr p)
00302 {
00303 profiles_.rebind (p->id (), p);
00304 }
00305
00306 void
00307 remove (u16 id)
00308 {
00309 profiles_.unbind (id);
00310 }
00311
00312 Profile const*
00313 find (u16 id) const
00314 {
00315 Profiles::ENTRY* e = 0;
00316
00317 if (profiles_.find (id, e) == -1) return 0;
00318
00319 return e->int_id_.get ();
00320 }
00321
00322 typedef
00323 Profiles::const_iterator
00324 ProfileIterator;
00325
00326 ProfileIterator
00327 begin () const
00328 {
00329 return ProfileIterator (profiles_);
00330 }
00331
00332 public:
00333 size_t
00334 size () const
00335 {
00336 sstream ss;
00337
00338 u32 s (0);
00339
00340 ss << s;
00341
00342 for (Profiles::const_iterator i (profiles_); !i.done (); i.advance ())
00343 {
00344 ss << *((*i).int_id_);
00345 }
00346
00347 return ss.total_length ();
00348 }
00349
00350 friend
00351 ostream&
00352 operator<< (ostream& os, Message const& m)
00353 {
00354 u32 s (m.size ());
00355
00356 os << s;
00357
00358 for (Profiles::const_iterator i (m.profiles_); !i.done (); i.advance ())
00359 {
00360 os << *((*i).int_id_);
00361 }
00362
00363 return os;
00364 }
00365
00366 private:
00367 Profiles profiles_;
00368 };
00369
00370 typedef ACE_Vector<Message_ptr, ACE_VECTOR_DEFAULT_SIZE> Messages;
00371
00372
00373
00374
00375 struct From;
00376
00377 typedef
00378 ACE_Strong_Bound_Ptr<From, Mutex>
00379 From_ptr;
00380
00381 struct From : Profile
00382 {
00383 static u16 const id;
00384
00385 public:
00386 From (Header const& h, istream& is)
00387 : Profile (h)
00388 {
00389 u32 addr;
00390 u16 port;
00391
00392 is >> addr;
00393 is >> port;
00394
00395 address_ = Address (port, addr);
00396 }
00397
00398 From (Address const& addr)
00399 : Profile (id), address_ (addr)
00400 {
00401 size (calculate_size ());
00402 }
00403
00404 From_ptr
00405 clone ()
00406 {
00407 return From_ptr (clone_ ());
00408 }
00409
00410 protected:
00411 virtual Profile_ptr
00412 clone_ ()
00413 {
00414 Profile_ptr p (new From (*this));
00415 return p;
00416 }
00417
00418 From (From const& from)
00419 : Profile (from),
00420 address_ (from.address_)
00421 {
00422 }
00423
00424 public:
00425 Address const&
00426 address () const
00427 {
00428 return address_;
00429 }
00430
00431 public:
00432 virtual void
00433 serialize_body (ostream& os) const
00434 {
00435 u32 addr (address_.get_ip_address ());
00436 u16 port (address_.get_port_number ());
00437
00438 os << addr;
00439 os << port;
00440 }
00441
00442 virtual void
00443 serialize_body (sstream& ss) const
00444 {
00445 u32 addr (0);
00446 u16 port (0);
00447
00448 ss << addr;
00449 ss << port;
00450 }
00451
00452 private:
00453 Address address_;
00454 };
00455
00456
00457
00458
00459
00460 struct To;
00461
00462 typedef
00463 ACE_Strong_Bound_Ptr<To, Mutex>
00464 To_ptr;
00465
00466 struct To : Profile
00467 {
00468 static u16 const id;
00469
00470 public:
00471 To (Header const& h, istream& is)
00472 : Profile (h)
00473 {
00474 u32 addr;
00475 u16 port;
00476
00477 is >> addr;
00478 is >> port;
00479
00480 address_ = Address (port, addr);
00481 }
00482
00483 To (Address const& addr)
00484 : Profile (id), address_ (addr)
00485 {
00486 size (calculate_size ());
00487 }
00488
00489 To_ptr
00490 clone ()
00491 {
00492 return To_ptr (clone_ ());
00493 }
00494
00495 protected:
00496 virtual Profile_ptr
00497 clone_ ()
00498 {
00499 Profile_ptr p (new To (*this));
00500 return p;
00501 }
00502
00503 To (To const& to)
00504 : Profile (to),
00505 address_ (to.address_)
00506 {
00507 }
00508
00509 public:
00510 Address const&
00511 address () const
00512 {
00513 return address_;
00514 }
00515
00516 public:
00517 virtual void
00518 serialize_body (ostream& os) const
00519 {
00520 u32 addr (address_.get_ip_address ());
00521 u16 port (address_.get_port_number ());
00522
00523 os << addr;
00524 os << port;
00525 }
00526
00527 virtual void
00528 serialize_body (sstream& ss) const
00529 {
00530 u32 addr (0);
00531 u16 port (0);
00532
00533 ss << addr;
00534 ss << port;
00535 }
00536
00537 private:
00538 Address address_;
00539 };
00540
00541
00542
00543
00544
00545 struct Data;
00546
00547 typedef
00548 ACE_Strong_Bound_Ptr<Data, Mutex>
00549 Data_ptr;
00550
00551 struct Data : Profile
00552 {
00553 static u16 const id;
00554
00555 public:
00556 virtual
00557 ~Data ()
00558 {
00559 if (buf_)
00560 operator delete (buf_);
00561 }
00562
00563 Data (Header const& h, istream& is)
00564 : Profile (h),
00565 buf_ (0),
00566 size_ (h.size ()),
00567 capacity_ (size_)
00568 {
00569 if (size_)
00570 {
00571 buf_ = reinterpret_cast<char*> (operator new (capacity_));
00572 is.read_char_array (buf_, size_);
00573 }
00574 }
00575
00576 Data (void const* buf, size_t s, size_t capacity = 0)
00577 : Profile (id),
00578 buf_ (0),
00579 size_ (s),
00580 capacity_ (capacity < size_ ? size_ : capacity)
00581 {
00582 if (size_)
00583 {
00584 buf_ = reinterpret_cast<char*> (operator new (capacity_));
00585 ACE_OS::memcpy (buf_, buf, size_);
00586 }
00587
00588 Profile::size (calculate_size ());
00589 }
00590
00591 Data_ptr
00592 clone ()
00593 {
00594 return Data_ptr (clone_ ());
00595 }
00596
00597 protected:
00598 virtual Profile_ptr
00599 clone_ ()
00600 {
00601 Profile_ptr p (new Data (*this));
00602 return p;
00603 }
00604
00605 Data (Data const& d)
00606 : Profile (d),
00607 buf_ (0),
00608 size_ (d.size_),
00609 capacity_ (d.capacity_)
00610 {
00611 if (size_)
00612 {
00613 buf_ = reinterpret_cast<char*> (operator new (capacity_));
00614 ACE_OS::memcpy (buf_, d.buf_, size_);
00615 }
00616
00617 Profile::size (calculate_size ());
00618 }
00619
00620 public:
00621 char const*
00622 buf () const
00623 {
00624 return buf_;
00625 }
00626
00627 char*
00628 buf ()
00629 {
00630 return buf_;
00631 }
00632
00633 size_t
00634 size () const
00635 {
00636 return size_;
00637 }
00638
00639 void
00640 size (size_t s)
00641 {
00642 if (s > capacity_)
00643 ACE_OS::abort ();
00644
00645 size_ = s;
00646
00647 Profile::size (calculate_size ());
00648 }
00649
00650 size_t
00651 capacity () const
00652 {
00653 return capacity_;
00654 }
00655
00656 public:
00657 virtual void
00658 serialize_body (ostream& os) const
00659 {
00660 os.write_char_array (buf_, size_);
00661 }
00662
00663 virtual void
00664 serialize_body (sstream& ss) const
00665 {
00666 ss.write_char_array (buf_, size_);
00667 }
00668
00669 private:
00670 char* buf_;
00671 size_t size_;
00672 size_t capacity_;
00673 };
00674
00675
00676
00677
00678
00679 struct SN;
00680
00681 typedef
00682 ACE_Strong_Bound_Ptr<SN, Mutex>
00683 SN_ptr;
00684
00685 struct SN : Profile
00686 {
00687 static u16 const id;
00688
00689 public:
00690 SN (Header const& h, istream& is)
00691 : Profile (h)
00692 {
00693 is >> n_;
00694 }
00695
00696 SN (u64 n)
00697 : Profile (id), n_ (n)
00698 {
00699 size (calculate_size ());
00700 }
00701
00702 SN_ptr
00703 clone ()
00704 {
00705 return SN_ptr (clone_ ());
00706 }
00707
00708 protected:
00709 virtual Profile_ptr
00710 clone_ ()
00711 {
00712 Profile_ptr p (new SN (*this));
00713 return p;
00714 }
00715
00716 SN (SN const& sn)
00717 : Profile (sn),
00718 n_ (sn.n_)
00719 {
00720 }
00721
00722 public:
00723 u64
00724 num () const
00725 {
00726 return n_;
00727 }
00728
00729 public:
00730 virtual void
00731 serialize_body (ostream& os) const
00732 {
00733 os << n_;
00734 }
00735
00736 virtual void
00737 serialize_body (sstream& ss) const
00738 {
00739 ss << n_;
00740 }
00741
00742 private:
00743 u64 n_;
00744 };
00745
00746
00747
00748
00749
00750 class NAK;
00751
00752 typedef
00753 ACE_Strong_Bound_Ptr<NAK, Mutex>
00754 NAK_ptr;
00755
00756 class NAK : public Profile
00757 {
00758 public:
00759
00760 static u16 const id;
00761
00762 typedef ACE_Vector<u64, ACE_VECTOR_DEFAULT_SIZE> SerialNumbers;
00763 typedef SerialNumbers::Iterator iterator;
00764
00765 NAK (Header const& h, istream& is)
00766 : Profile (h)
00767 {
00768 u64 sn (0);
00769 u32 addr (0);
00770 u16 port (0);
00771
00772 sstream ss;
00773
00774 ss << sn;
00775 size_t sn_size (ss.total_length ());
00776
00777 ss.reset ();
00778
00779 ss << addr;
00780 ss << port;
00781
00782 size_t addr_size (ss.total_length ());
00783
00784
00785 is >> addr;
00786 is >> port;
00787
00788
00789
00790 for (unsigned long i (0); i < ((h.size () - addr_size) / sn_size); ++i)
00791 {
00792 is >> sn;
00793 sns_.push_back (sn);
00794 }
00795
00796
00797 address_ = Address (port, addr);
00798 }
00799
00800 NAK (Address const& src)
00801 : Profile (id), address_ (src)
00802 {
00803 size (calculate_size ());
00804 }
00805
00806 NAK_ptr
00807 clone ()
00808 {
00809 return NAK_ptr (clone_ ());
00810 }
00811
00812 protected:
00813 virtual Profile_ptr
00814 clone_ ()
00815 {
00816 Profile_ptr p (new NAK (*this));
00817 return p;
00818 }
00819
00820 NAK (NAK const& nak)
00821 : Profile (nak),
00822 address_ (nak.address_),
00823 sns_ (nak.sns_)
00824 {
00825 }
00826
00827 public:
00828 void
00829 add (u64 sn)
00830 {
00831 sns_.push_back (sn);
00832 size (calculate_size ());
00833 }
00834
00835 public:
00836 Address const&
00837 address () const
00838 {
00839 return address_;
00840 }
00841
00842
00843 iterator
00844 begin ()
00845 {
00846 return iterator (sns_);
00847 }
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857 size_t
00858 count () const
00859 {
00860 return sns_.size ();
00861 }
00862
00863 public:
00864
00865
00866
00867 static u32
00868 max_count (u32 max_size)
00869 {
00870 u32 n (0);
00871
00872 sstream ss;
00873
00874 Profile::Header hdr (0, 0);
00875 ss << hdr;
00876
00877 u32 addr (0);
00878 u16 port (0);
00879 ss << addr;
00880 ss << port;
00881
00882 while (true)
00883 {
00884 u64 sn (0);
00885 ss << sn;
00886
00887 if (ss.total_length () <= max_size)
00888 ++n;
00889
00890 if (ss.total_length () >= max_size)
00891 break;
00892 }
00893
00894 return n;
00895 }
00896
00897 public:
00898 virtual void
00899 serialize_body (ostream& os) const
00900 {
00901 NAK& this_ = const_cast<NAK&> (*this);
00902
00903 u32 addr (address_.get_ip_address ());
00904 u16 port (address_.get_port_number ());
00905
00906 os << addr;
00907 os << port;
00908
00909
00910
00911 for (iterator i (this_.begin ()); !i.done (); i.advance ())
00912 {
00913 u64* psn = 0;
00914 i.next (psn);
00915 os << *psn;
00916 }
00917 }
00918
00919 virtual void
00920 serialize_body (sstream& ss) const
00921 {
00922 NAK& this_ = const_cast<NAK&> (*this);
00923
00924 u32 addr (0);
00925 u16 port (0);
00926
00927 ss << addr;
00928 ss << port;
00929
00930
00931
00932 for (iterator i (this_.begin ()); !i.done (); i.advance ())
00933 {
00934 u64 sn (0);
00935 ss << sn;
00936 }
00937 }
00938
00939 private:
00940 Address address_;
00941 SerialNumbers sns_;
00942 };
00943
00944
00945
00946
00947 struct NRTM;
00948
00949 typedef
00950 ACE_Strong_Bound_Ptr<NRTM, Mutex>
00951 NRTM_ptr;
00952
00953 struct NRTM : Profile
00954 {
00955 static u16 const id;
00956
00957 public:
00958 NRTM (Header const& h, istream& is)
00959 : Profile (h), map_ (10)
00960 {
00961 u32 addr (0);
00962 u16 port (0);
00963 u64 sn (0);
00964
00965 sstream ss;
00966
00967 ss << sn;
00968 ss << addr;
00969 ss << port;
00970
00971 size_t block_size (ss.total_length ());
00972
00973
00974
00975
00976 for (size_t i (0); i < (h.size () / block_size); ++i)
00977 {
00978 is >> sn;
00979 is >> addr;
00980 is >> port;
00981
00982 map_.bind (Address (port, addr), sn);
00983 }
00984 }
00985
00986 NRTM ()
00987 : Profile (id), map_ (10)
00988 {
00989 size (calculate_size ());
00990 }
00991
00992 NRTM_ptr
00993 clone ()
00994 {
00995 return NRTM_ptr (clone_ ());
00996 }
00997
00998 protected:
00999 virtual Profile_ptr
01000 clone_ ()
01001 {
01002 Profile_ptr p (new NRTM (*this));
01003 return p;
01004 }
01005
01006 NRTM (NRTM const& nrtm)
01007 : Profile (nrtm)
01008 {
01009 for (Map::const_iterator i (nrtm.map_); !i.done (); i.advance ())
01010 {
01011 map_.bind ((*i).ext_id_, (*i).int_id_);
01012 }
01013 }
01014
01015 public:
01016 void
01017 insert (Address const& addr, u64 sn)
01018 {
01019 map_.bind (addr, sn);
01020
01021 size (calculate_size ());
01022 }
01023
01024 u64
01025 find (Address const& addr) const
01026 {
01027 u64 sn;
01028
01029 if (map_.find (addr, sn) == -1) return 0;
01030
01031 return sn;
01032 }
01033
01034 bool
01035 empty () const
01036 {
01037 return map_.current_size () == 0;
01038 }
01039
01040 public:
01041
01042
01043
01044 static u32
01045 max_count (u32 max_size)
01046 {
01047 u32 n (0);
01048
01049 sstream ss;
01050
01051 Profile::Header hdr (0, 0);
01052 ss << hdr;
01053
01054 while (true)
01055 {
01056 u32 addr (0);
01057 u16 port (0);
01058 u64 sn (0);
01059
01060 ss << sn;
01061 ss << addr;
01062 ss << port;
01063
01064 if (ss.total_length () <= max_size)
01065 ++n;
01066
01067 if (ss.total_length () >= max_size)
01068 break;
01069 }
01070
01071 return n;
01072 }
01073
01074 public:
01075 virtual void
01076 serialize_body (ostream& os) const
01077 {
01078 for (Map::const_iterator i (map_), e (map_, 1); i != e; ++i)
01079 {
01080 u32 addr ((*i).ext_id_.get_ip_address ());
01081 u16 port ((*i).ext_id_.get_port_number ());
01082 u64 sn ((*i).int_id_);
01083
01084 os << sn;
01085 os << addr;
01086 os << port;
01087
01088 }
01089 }
01090
01091 virtual void
01092 serialize_body (sstream& ss) const
01093 {
01094 for (Map::const_iterator i (map_), e (map_, 1); i != e; ++i)
01095 {
01096 u32 addr (0);
01097 u16 port (0);
01098 u64 sn (0);
01099
01100 ss << sn;
01101 ss << addr;
01102 ss << port;
01103 }
01104 }
01105
01106 private:
01107 typedef
01108 ACE_Hash_Map_Manager_Ex<Address,
01109 u64,
01110 AddressHasher,
01111 ACE_Equal_To<Address>,
01112 ACE_Null_Mutex>
01113 Map;
01114
01115 Map map_;
01116 };
01117
01118
01119
01120
01121
01122 struct NoData;
01123
01124 typedef
01125 ACE_Strong_Bound_Ptr<NoData, Mutex>
01126 NoData_ptr;
01127
01128 struct NoData : Profile
01129 {
01130 static u16 const id;
01131
01132 public:
01133 NoData (Header const& h, istream&)
01134 : Profile (h)
01135 {
01136 }
01137
01138 NoData ()
01139 : Profile (id)
01140 {
01141 Profile::size (0);
01142 }
01143
01144 NoData_ptr
01145 clone ()
01146 {
01147 return NoData_ptr (clone_ ());
01148 }
01149
01150 protected:
01151 virtual Profile_ptr
01152 clone_ ()
01153 {
01154 Profile_ptr p (new NoData (*this));
01155 return p;
01156 }
01157
01158 NoData (NoData const& no_data)
01159 : Profile (no_data)
01160 {
01161 }
01162
01163 public:
01164 virtual void
01165 serialize_body (ostream&) const
01166 {
01167 }
01168
01169 virtual void
01170 serialize_body (sstream&) const
01171 {
01172 }
01173 };
01174
01175
01176
01177
01178
01179 struct Part;
01180
01181 typedef
01182 ACE_Strong_Bound_Ptr<Part, Mutex>
01183 Part_ptr;
01184
01185 struct Part : Profile
01186 {
01187 static u16 const id;
01188
01189 public:
01190 Part (Header const& h, istream& is)
01191 : Profile (h)
01192 {
01193 is >> num_;
01194 is >> of_;
01195 is >> total_size_;
01196 }
01197
01198 Part (u32 num, u32 of, u64 total_size)
01199 : Profile (id),
01200 num_ (num),
01201 of_ (of),
01202 total_size_ (total_size)
01203 {
01204 size (calculate_size ());
01205 }
01206
01207 Part_ptr
01208 clone ()
01209 {
01210 return Part_ptr (clone_ ());
01211 }
01212
01213 protected:
01214 virtual Profile_ptr
01215 clone_ ()
01216 {
01217 Profile_ptr p (new Part (*this));
01218 return p;
01219 }
01220
01221 Part (Part const& part)
01222 : Profile (part),
01223 num_ (part.num_),
01224 of_ (part.of_),
01225 total_size_ (part.total_size_)
01226 {
01227 }
01228
01229 public:
01230 u32
01231 num () const
01232 {
01233 return num_;
01234 }
01235
01236 u32
01237 of () const
01238 {
01239 return of_;
01240 }
01241
01242 u64
01243 total_size () const
01244 {
01245 return total_size_;
01246 }
01247
01248 public:
01249 virtual void
01250 serialize_body (ostream& os) const
01251 {
01252 os << num_;
01253 os << of_;
01254 os << total_size_;
01255 }
01256
01257 virtual void
01258 serialize_body (sstream& ss) const
01259 {
01260 ss << num_;
01261 ss << of_;
01262 ss << total_size_;
01263 }
01264
01265
01266 private:
01267 u32 num_;
01268 u32 of_;
01269 u64 total_size_;
01270 };
01271
01272 }
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285 #endif // ACE_RMCAST_PROTOCOL_H