00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028
00029 #ifndef LogicalToApplicationInterface
00030 #define LogicalToApplicationInterface
00031
00032 #ifdef __GNUG__
00033 #pragma interface
00034 #endif
00035
00036
00037 namespace Ogg
00038 {
00039 class Logical;
00040 class Packet;
00041 }
00042
00043 #include <Ogg/Ogg.H>
00044 #include <Ogg/Transport.H>
00045 #include <Ogg/Exception.H>
00046
00047 namespace Ogg
00048 {
00050
00051
00058 class Packet
00059 {
00060 private:
00061 Packet(const Packet &);
00062
00063 Packet &
00064 operator =(const Packet &);
00065
00066 protected:
00067 Packet(){};
00068
00069 public:
00070 void
00071 data(void *
00072 ,size_t
00073 );
00074
00075 void *
00076 data();
00077
00078 size_t
00079 size();
00080
00081 PacketNo
00082 packetNo();
00083
00084 };
00085
00091 class Logical
00092 {
00093 private:
00094 void * impl_;
00095
00096 Logical(const Logical &);
00097
00098 Logical &
00099 operator =(const Logical &);
00100
00101 protected:
00103 Logical(
00104 bool dummy
00105 )
00106 : impl_(0)
00107 {}
00108
00109 public:
00110 void *
00111 impl()
00112 {
00113 return(impl_);
00114 }
00115
00116
00117
00119 class SerialNotPositive : public Exception
00120 {
00121 public:
00122 SerialNotPositive(
00123 const long serialNo
00124 ) throw()
00125 : Exception("Serial no. ")
00126 {
00127 *this << serialNo << "is not positive" << std::endl;
00128 }
00129
00130 SerialNotPositive(
00131 const SerialNotPositive & ex
00132 ) throw()
00133 : Exception(ex)
00134 {}
00135
00136 ~SerialNotPositive() throw()
00137 {}
00138 }
00139 ;
00140
00142 class WriterAlreadyExists : public Exception
00143 {
00144 public:
00145 WriterAlreadyExists(
00146 const long serialNo
00147 ) throw()
00148 : Exception("Writer for this Logical already exists,")
00149 {
00150 *this << " serial no. = " << serialNo << std::endl;
00151 }
00152
00153 WriterAlreadyExists(
00154 const WriterAlreadyExists & ex
00155 ) throw()
00156 : Exception(ex)
00157 {}
00158
00159 ~WriterAlreadyExists() throw()
00160 {}
00161 }
00162 ;
00163
00165 class NotForWriting : public Exception
00166 {
00167 public:
00168 NotForWriting(
00169 const long serialNo
00170 ) throw()
00171 : Exception("This Logical not for writing")
00172 {
00173 *this << " serial no. = " << serialNo << std::endl;
00174 }
00175
00176 NotForWriting(
00177 const NotForWriting & ex
00178 ) throw()
00179 : Exception(ex)
00180 {}
00181
00182 ~NotForWriting() throw()
00183 {}
00184 }
00185 ;
00186
00188 class ReaderAlreadyExists : public Exception
00189 {
00190 public:
00191 ReaderAlreadyExists(
00192 const long serialNo
00193 ) throw()
00194 : Exception("Reader for this Logical already exists,")
00195 {
00196 *this << " serial no. = " << serialNo << std::endl;
00197 }
00198
00199 ReaderAlreadyExists(
00200 const ReaderAlreadyExists & ex
00201 ) throw()
00202 : Exception(ex)
00203 {}
00204
00205 ~ReaderAlreadyExists() throw()
00206 {}
00207 }
00208 ;
00209
00211 class NotForReading : public Exception
00212 {
00213 public:
00214 NotForReading(
00215 const long serialNo
00216 ) throw()
00217 : Exception("This Logical not for reading,")
00218 {
00219 *this << " serial no. = " << serialNo << std::endl;
00220 }
00221
00222 NotForReading(
00223 const NotForReading & ex
00224 ) throw()
00225 : Exception(ex)
00226 {}
00227
00228 ~NotForReading() throw()
00229 {}
00230 }
00231 ;
00232
00234 class MuxTooLate : public Exception
00235 {
00236 public:
00237 MuxTooLate(
00238 const long serialNo
00239 ) throw()
00240 : Exception("This Logical stream comes in too late - synchronize better,")
00241 {
00242 *this << " serial no. = " << serialNo << std::endl;
00243 }
00244
00245 MuxTooLate(
00246 const MuxTooLate & ex
00247 ) throw()
00248 : Exception(ex)
00249 {}
00250
00251 ~MuxTooLate() throw()
00252 {}
00253 }
00254 ;
00255
00257 class SerialNoAlreadyUsed : public Exception
00258 {
00259 public:
00260 SerialNoAlreadyUsed(
00261 const long serialNo
00262 ) throw()
00263 : Exception("This serial no. has been taken already,")
00264 {
00265 *this << " serial no. = " << serialNo << std::endl;
00266 }
00267
00268 SerialNoAlreadyUsed(
00269 const SerialNoAlreadyUsed & ex
00270 ) throw()
00271 : Exception(ex)
00272 {}
00273
00274 ~SerialNoAlreadyUsed() throw()
00275 {}
00276 }
00277 ;
00278
00280 class StreamAlreadyClaimed : public Exception
00281 {
00282 public:
00283 StreamAlreadyClaimed(
00284 const long serialNo
00285 ) throw()
00286 : Exception("Stream already has been claimed,")
00287 {
00288 *this << " serial no. = " << serialNo << std::endl;
00289 }
00290
00291 StreamAlreadyClaimed(
00292 const StreamAlreadyClaimed & ex
00293 ) throw()
00294 : Exception(ex)
00295 {}
00296
00297 ~StreamAlreadyClaimed() throw()
00298 {}
00299 }
00300 ;
00301
00303 class NoSuchStream : public Exception
00304 {
00305 public:
00306 NoSuchStream(
00307 const long serialNo
00308 ) throw()
00309 : Exception("No stream found,")
00310 {
00311 *this << " serial no. = " << serialNo << std::endl;
00312 }
00313
00314 NoSuchStream(
00315 const NoSuchStream & ex
00316 ) throw()
00317 : Exception(ex)
00318 {}
00319
00320 ~NoSuchStream() throw()
00321 {}
00322 }
00323 ;
00324
00326 class FailedToSelectStream : public Exception
00327 {
00328 public:
00329 FailedToSelectStream(
00330 const long serialNo
00331 ) throw()
00332 : Exception("Failed to find a stream with ")
00333 {
00334 *this << " serial no. = " << serialNo << std::endl;
00335 }
00336
00337 FailedToSelectStream(
00338 const FailedToSelectStream & ex
00339 ) throw()
00340 : Exception(ex)
00341 {}
00342
00343 ~FailedToSelectStream() throw()
00344 {}
00345 }
00346 ;
00347
00349 class SeekInternalError : public Exception
00350 {
00351 public:
00352 SeekInternalError(
00353 const long serialNo
00354 ) throw()
00355 : Exception("Please let developers know this happened.")
00356 {
00357 *this << " serial no. = " << serialNo << std::endl;
00358 }
00359
00360 SeekInternalError(
00361 const SeekInternalError & ex
00362 ) throw()
00363 : Exception(ex)
00364 {}
00365
00366 ~SeekInternalError() throw()
00367 {}
00368 }
00369 ;
00370
00372 class PageReaderTooLate : public Exception
00373 {
00374 public:
00375 PageReaderTooLate(
00376 const long serialNo
00377 ) throw()
00378 : Exception("Request for PageReader must precede that for Reader.")
00379 {
00380 *this << " serial no. = " << serialNo << std::endl;
00381 }
00382
00383 PageReaderTooLate(
00384 const PageReaderTooLate & ex
00385 ) throw()
00386 : Exception(ex)
00387 {}
00388
00389 ~PageReaderTooLate() throw()
00390 {}
00391 }
00392 ;
00393
00395 class ReaderTooLate : public Exception
00396 {
00397 public:
00398 ReaderTooLate(
00399 const long serialNo
00400 ) throw()
00401 : Exception("Logical::reader() must precede PageReader::get()")
00402 {
00403 *this << " serial no. = " << serialNo << std::endl;
00404 }
00405
00406 ReaderTooLate(
00407 const ReaderTooLate & ex
00408 ) throw()
00409 : Exception(ex)
00410 {}
00411
00412 ~ReaderTooLate() throw()
00413 {}
00414 }
00415 ;
00416
00417
00418
00420 Logical(
00421 Transport & transport
00422 ,long serialNo
00423 );
00424
00426 Logical(
00427 Transport & transport
00428 );
00429
00431 Logical(
00432 long serialNo
00433 ,Transport& transport
00434 );
00435
00436
00440 virtual
00441 ~Logical();
00442
00449 virtual
00450 bool
00451 selectCallback(
00452 Packet & firstPacket
00453 )
00454 {
00455 return(true);
00456 }
00457
00463 long
00464 serialNo() const;
00465
00467 Transport &
00468 transport() const;
00469
00476 class Writer
00477 {
00478 private:
00479 Writer(const Writer &);
00480
00481 Writer &
00482 operator =(const Writer &);
00483
00484 protected:
00485 Writer(){};
00486
00487 public:
00495 ~Writer();
00496
00498 size_t
00499 dataSize() const;
00500
00505 void
00506 dataSize(size_t);
00507
00509 void
00510 flush();
00511
00516 void
00517 beginData();
00518
00523 void
00524 granulePosition(
00525 Position
00526 );
00527
00529 Position
00530 granulePosition() const;
00531
00533 size_t
00534 pageSize() const;
00535
00540 void
00541 pageSize(
00542 size_t
00543 );
00544
00546 Writer &
00547 operator ++();
00548
00550 Packet *
00551 operator->() const throw();
00552
00554 Packet *
00555 packet() const throw()
00556 {
00557 return(operator->());
00558 }
00559 };
00560
00567 class Reader
00568 {
00569 private:
00570 Reader(const Reader &);
00571
00572 Reader &
00573 operator =(const Reader &);
00574
00575 protected:
00576 Reader(){};
00577
00578 public:
00583 ~Reader();
00584
00586 Reader &
00587 operator ++();
00588
00593 Reader &
00594 operator +=(PacketNo packets);
00595
00600 Reader &
00601 operator =(Position position);
00602
00603 bool
00604 ending() const;
00605
00606 Error
00607 transportError()
00608 const;
00609
00610 Position
00611 granulePosition()
00612 const;
00613
00615 Packet *
00616 operator->() const throw();
00617
00619 Packet *
00620 packet() const throw()
00621 {
00622 return(operator->());
00623 }
00624 };
00625
00633 class PageWriter
00634 {
00635 private:
00636 PageWriter(const PageWriter &);
00637
00638 PageWriter &
00639 operator =(const PageWriter &);
00640
00641 protected:
00642 PageWriter(){};
00643
00644 public:
00652 ~PageWriter();
00653
00662 bool
00663 put(Page &);
00664
00667 void
00668 doPut(Page &);
00669
00670 };
00671
00681 class PageReader
00682 {
00683 private:
00684 PageReader(const PageReader &);
00685
00686 PageReader &
00687 operator =(const PageReader &);
00688
00689 protected:
00690 PageReader(){};
00691
00692 public:
00697 ~PageReader();
00698
00705 Page *
00706 get();
00707
00711 Page &
00712 doGet();
00713
00714 };
00715
00720 Writer &
00721 writer();
00722
00727 PageWriter &
00728 pageWriter();
00729
00730
00744 PageReader &
00745 pageReader();
00746
00751 Reader &
00752 reader();
00753
00754 };
00756 };
00757 #endif