• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

DataPool.h

Go to the documentation of this file.
00001 //C-  -*- C++ -*-
00002 //C- -------------------------------------------------------------------
00003 //C- DjVuLibre-3.5
00004 //C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
00005 //C- Copyright (c) 2001  AT&T
00006 //C-
00007 //C- This software is subject to, and may be distributed under, the
00008 //C- GNU General Public License, Version 2. The license should have
00009 //C- accompanied the software or you may obtain a copy of the license
00010 //C- from the Free Software Foundation at http://www.fsf.org .
00011 //C-
00012 //C- This program is distributed in the hope that it will be useful,
00013 //C- but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //C- GNU General Public License for more details.
00016 //C- 
00017 //C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library
00018 //C- distributed by Lizardtech Software.  On July 19th 2002, Lizardtech 
00019 //C- Software authorized us to replace the original DjVu(r) Reference 
00020 //C- Library notice by the following text (see doc/lizard2002.djvu):
00021 //C-
00022 //C-  ------------------------------------------------------------------
00023 //C- | DjVu (r) Reference Library (v. 3.5)
00024 //C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
00025 //C- | The DjVu Reference Library is protected by U.S. Pat. No.
00026 //C- | 6,058,214 and patents pending.
00027 //C- |
00028 //C- | This software is subject to, and may be distributed under, the
00029 //C- | GNU General Public License, Version 2. The license should have
00030 //C- | accompanied the software or you may obtain a copy of the license
00031 //C- | from the Free Software Foundation at http://www.fsf.org .
00032 //C- |
00033 //C- | The computer code originally released by LizardTech under this
00034 //C- | license and unmodified by other parties is deemed "the LIZARDTECH
00035 //C- | ORIGINAL CODE."  Subject to any third party intellectual property
00036 //C- | claims, LizardTech grants recipient a worldwide, royalty-free, 
00037 //C- | non-exclusive license to make, use, sell, or otherwise dispose of 
00038 //C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 
00039 //C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 
00040 //C- | General Public License.   This grant only confers the right to 
00041 //C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 
00042 //C- | the extent such infringement is reasonably necessary to enable 
00043 //C- | recipient to make, have made, practice, sell, or otherwise dispose 
00044 //C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 
00045 //C- | any greater extent that may be necessary to utilize further 
00046 //C- | modifications or combinations.
00047 //C- |
00048 //C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
00049 //C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
00050 //C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
00051 //C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00052 //C- +------------------------------------------------------------------
00053 // 
00054 // $Id: DataPool.h,v 1.10 2003/11/07 22:08:20 leonb Exp $
00055 // $Name: release_3_5_15 $
00056 
00057 #ifndef _DATAPOOL_H
00058 #define _DATAPOOL_H
00059 #ifdef HAVE_CONFIG_H
00060 #include "config.h"
00061 #endif
00062 #if NEED_GNUG_PRAGMAS
00063 # pragma interface
00064 #endif
00065 
00066 
00067 #include "GThreads.h"
00068 #include "GString.h"
00069 #include "GURL.h"
00070 
00071 #ifdef HAVE_NAMESPACES
00072 namespace DJVU {
00073 # ifdef NOT_DEFINED // Just to fool emacs c++ mode
00074 }
00075 #endif
00076 #endif
00077 
00078 class ByteStream;
00079 
00103 
00225 class DataPool : public GPEnabled
00226 {
00227 public: // Classes used internally by DataPool
00228     // These are declared public to support buggy C++ compilers.
00229    class Incrementor;
00230    class Reader;
00231    class Trigger;
00232    class OpenFiles;
00233    class OpenFiles_File;
00234    class BlockList;
00235    class Counter;
00236 protected:
00237    DataPool(void);
00238 
00239 public:
00246    static GP<DataPool> create(void);
00247 
00253    static GP<DataPool> create(const GP<ByteStream> & str);
00254 
00266    static GP<DataPool> create(const GP<DataPool> & master_pool, int start=0, int length=-1);
00267 
00278    static GP<DataPool> create(const GURL &url, int start=0, int length=-1);
00279 
00280    virtual ~DataPool();
00281 
00290    void     connect(const GP<DataPool> & master_pool, int start=0, int length=-1);
00299    void     connect(const GURL &url, int start=0, int length=-1);
00301 
00312    void     stop(bool only_blocked=false);
00313 
00341    void     add_data(const void * buffer, int size);
00342 
00358    void     add_data(const void * buffer, int offset, int size);
00359 
00370    void     set_eof(void);
00372 
00423    int      get_data(void * buffer, int offset, int size);
00424 
00429    GP<ByteStream>   get_stream(void);
00431 
00436    bool     is_connected(void) const;
00437    
00445    bool     has_data(int start, int length);
00446 
00447       /* Returns #TRUE# if no more data is planned to be added.
00448 
00449      {\bf Note:} This function always returns #TRUE# when the #DataPool#
00450      has been initialized with a file name. */
00451    bool     is_eof(void) const {return eof_flag;}
00452 
00469    int      get_length(void) const;
00476    int      get_size(void) const {return get_size(0, -1);}
00478 
00510    void     add_trigger(int start, int length,
00511 //              void (* callback)(GP<GPEnabled> &), GP<GPEnabled> cl_data);
00512                 void (* callback)(void *), void * cl_data);
00513 
00521 //   void       add_trigger(int thresh, void (* callback)(GP<GPEnabled> &), GP<GPEnabled> cl_data);
00522    void     add_trigger(int thresh, void (* callback)(void *), void * cl_data);
00523 
00527    void     del_trigger(void (* callback)(void *), void *  cl_data);
00528 //   void       del_trigger(void (* callback)(GP<GPEnabled> &), GP<GPEnabled>  cl_data);
00530 
00540    void     load_file(void);
00546    static void  load_file(const GURL &url);
00547 
00549    static void  close_all(void);
00550 
00551       // Internal. Used by 'OpenFiles'
00552    void     clear_stream(const bool release = true);
00553 
00556    bool simple_compare(DataPool &pool) const;
00557 private:
00558    bool     eof_flag;
00559    bool     stop_flag;
00560    bool     stop_blocked_flag;
00561 
00562    Counter  *active_readers;
00563    
00564       // Source or storage of data
00565    GP<DataPool>     pool;
00566    GURL     furl;
00567    GP<OpenFiles_File>   fstream;
00568    GCriticalSection class_stream_lock;
00569    GP<ByteStream>   data;
00570    GCriticalSection data_lock;
00571    BlockList        *block_list;
00572    int          add_at;
00573    int          start, length;
00574 
00575       // List of readers waiting for data
00576    GPList<Reader>   readers_list;
00577    GCriticalSection readers_lock;
00578 
00579       // Triggers
00580    GPList<Trigger>  triggers_list;      // List of passed or our triggers
00581    GCriticalSection triggers_lock;      // Lock for the list above
00582    GCriticalSection trigger_lock;       // Lock for static_trigger_cb()
00583 
00584    void     init(void);
00585    void     wait_for_data(const GP<Reader> & reader);
00586    void     wake_up_all_readers(void);
00587    void     check_triggers(void);
00588    int      get_data(void * buffer, int offset, int size, int level);
00589    int      get_size(int start, int length) const;
00590    void     restart_readers(void);
00591 
00592 //   static void    static_trigger_cb(GP<GPEnabled> &);
00593    static void  static_trigger_cb(void *);
00594    void     trigger_cb(void);
00595    void     analyze_iff(void);
00596    void     added_data(const int offset, const int size);
00597 public:
00598   static const char *Stop;
00599   friend class FCPools;
00600 };
00601 
00602 inline bool 
00603 DataPool::simple_compare(DataPool &pool) const
00604 {
00605   // return true if these pools are identical.  False means they may or may
00606   // not be identical.
00607   return (this == &pool)
00608     ||(furl.is_valid()&&!furl.is_empty()&&pool.furl.is_valid()&&(furl == pool.furl))
00609     ||(data && (data == pool.data));
00610 }
00611 
00612 inline bool
00613 DataPool::is_connected(void) const
00614 {
00615    return furl.is_local_file_url() || pool!=0;
00616 }
00617 
00619 
00620 
00621 #ifdef HAVE_NAMESPACES
00622 }
00623 # ifndef NOT_USING_DJVU_NAMESPACE
00624 using namespace DJVU;
00625 # endif
00626 #endif
00627 #endif

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal