opennurbs_compress.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #if !defined(OPENNURBS_COMPRESS_INC_)
00018 #define OPENNURBS_COMPRESS_INC_
00019 
00020 typedef bool (*ON_StreamCallbackFunction)( void* context, ON__UINT32 size, const void* buffer );
00021 
00022 class ON_CLASS ON_CompressStream
00023 {
00024 public:
00025   ON_CompressStream();
00026   virtual ~ON_CompressStream();
00027 
00028   /*
00029   Description:
00030     ON_CompressStream delivers the compressed stream by calling
00031     a compressed stream output handler function.  There are two
00032     options for specifying the compressed stream output handler
00033     function.
00034       1. Overriding the virtual Out() function.
00035       2. Providing a callback function.
00036     SetCallback() is used to specify a callback function to handle
00037     the compressed stream and to specify a context pointer to be 
00038     passed to either option of the handler.
00039   Parameters:
00040     callback_function - [in]
00041       Function to call with sections of the compressed stream.
00042       If callback_function is null, then the virtual Out() 
00043       function will be called. When callback_function 
00044       is specified, it must return true if the compression 
00045       calculation should continue and false to cancel the 
00046       compression calculation.
00047     callback_context - [in]
00048       This value is passed as the first argument when calling 
00049       callback_function or the virutal Out() function.
00050   Returns:
00051     True if successful.
00052   Remarks:
00053     Once compression has started, it would be unusual to
00054     intentionally change the compressed stream output handler,
00055     but you can do this if you need to.    
00056   */
00057   bool SetCallback( 
00058     ON_StreamCallbackFunction callback_function,
00059     void* callback_context
00060     );
00061 
00062   /*
00063   Returns:
00064     Current value of the callback function for handling
00065     the compressed stream.  If the callback function is
00066     null, the the virtual Out() function is used to
00067     handle
00068   */
00069   ON_StreamCallbackFunction CallbackFunction() const;
00070 
00071   /*
00072   Returns:
00073     Current value of the context pointer passed as the first
00074     argument to the compressed stream output handler function.
00075   */
00076   void* CallbackContext() const;
00077   
00078   /*
00079   Description:
00080     Call Begin() one time to initialize the compression
00081     calculation.  Then call In() one or more times 
00082     to submit the uncompressed stream to the compression calculation.  
00083     When you reach the end of the uncompressed stream, call 
00084     End().
00085   Returns:
00086     true if successful, false if an error occured.
00087   */
00088   bool Begin();
00089 
00090   /*
00091   Description:
00092     Call In() one or more times to compress a stream of uncompressed
00093     bytes.  After the last call to In(), call End().  Calling In()
00094     may generate zero or more calls to the output stream handler.
00095   Parameters:
00096     in_buffer_size - [in]
00097       number of bytes in in_buffer
00098     in_buffer - [in]
00099   Returns:
00100     true if successful, false if an error occured.
00101   */
00102   bool In( 
00103     ON__UINT64 in_buffer_size, 
00104     const void* in_buffer 
00105     );
00106 
00107   /*
00108   Description:
00109     If an explicit compressed stream output handler is not specified
00110     ( CallbackFunction() returns null ), then the virtual Out() 
00111     function is called to handle the compressed output stream.
00112     As the input stream is compressed, one or more calls to Out()
00113     will occur.
00114   Returns:
00115     True to continue compressing and false to cancel the compression
00116     calculation.
00117   Remarks:
00118     In general, it is probably going to be easier to test and debug
00119     your code if you ignore the callback_context parameter and add 
00120     a member variable to your derived class to make additional
00121     information accessable to your Out function.
00122   */
00123   virtual bool Out( 
00124     void* callback_context, 
00125     ON__UINT32 out_buffer_size, 
00126     const void* out_buffer 
00127     );
00128 
00129   /*
00130   Description:
00131     After the last call to In(), call End().  
00132     Calling End() may generate zero or more 
00133     calls to the output stream handler.
00134   Returns:
00135     true if successful, false if an error occured.
00136   */
00137   bool End();
00138 
00139   /*
00140   Returns:
00141     Then the returned value is the total number bytes in the input
00142     stream. The size is updated every time In() is called before 
00143     any calls are made to the output stream handler.  If the 
00144     calculation is finished ( End() has been called ), then the
00145     returned value is the total number of bytes in the entire 
00146     input stream.
00147   */
00148   ON__UINT64 InSize() const;
00149 
00150   /*
00151   Returns:
00152     Then the returned value is the total number bytes in the output
00153     stream. The size is incremented immediately after each call to
00154     the output stream handler.  If the compression calculation is 
00155     finished ( End() has been called ), then the returned value is
00156     the total number of bytes in the entire output stream.
00157   */
00158   ON__UINT64 OutSize() const;
00159 
00160   /*
00161   Returns:
00162     Then the returned value is the 32-bit crc of the input stream.
00163     The crc is updated every time In() is called before any calls
00164     are made to the output stream handler.  If the compression 
00165     calculation is finished ( End() has been called ), then the
00166     returned value is the 32-bit crc of the entire input stream.
00167   */
00168   ON__UINT32 InCRC() const;
00169 
00170   /*
00171   Returns:
00172     Then the returned value is the 32bit crc of the output stream.
00173     The crc is updated immediately after each call to the output
00174     stream handler.  If the calculation is finished ( End() has 
00175     been called ), then the returned value is the 32-bit crc of
00176     the entire output stream.
00177   */
00178   ON__UINT32 OutCRC() const;
00179 
00180 private:
00181   ON_StreamCallbackFunction m_out_callback_function;
00182   void* m_out_callback_context;
00183   ON__UINT64 m_in_size;
00184   ON__UINT64 m_out_size;
00185   ON__UINT32 m_in_crc;
00186   ON__UINT32 m_out_crc;
00187   void* m_implementation;
00188   void* m_reserved;
00189 
00190   void ErrorHandler();
00191 
00192 private:
00193   // prohibit use - no implementation
00194   ON_CompressStream(const ON_CompressStream&);
00195   ON_CompressStream& operator=(const ON_CompressStream&);
00196 };
00197 
00198 
00199 class ON_CLASS ON_UncompressStream
00200 {
00201 public:
00202   ON_UncompressStream();
00203   virtual ~ON_UncompressStream();
00204 
00205   /*
00206   Description:
00207     ON_UncompressStream delivers the uncompressed stream by calling
00208     an uncompressed stream output handler function.  There are two
00209     options for specifying the uncompressed stream output handler
00210     function.
00211       1. Overriding the virtual Out() function.
00212       2. Providing a callback function.
00213     SetCallback() is used to specify a callback function to handle
00214     the uncompressed stream and to specify a context pointer to be 
00215     passed to either option of the handler.
00216   Parameters:
00217     callback_function - [in]
00218       Function to call with sections of the uncompressed stream.
00219       If callback_function is null, then the virtual Out() 
00220       function will be called. When callback_function 
00221       is specified, it must return true if the uncompression 
00222       calculation should continue and false to cancel the 
00223       uncompression calculation.
00224     callback_context - [in]
00225       This value is passed as the first argument when calling 
00226       callback_function or the virutal Out() function.
00227   Returns:
00228     True if successful.
00229   Remarks:
00230     Once uncompression has started, it would be unusual to
00231     intentionally change the uncompressed stream output handler,
00232     but you can do this if you need to.    
00233   */
00234   bool SetCallback( 
00235     ON_StreamCallbackFunction callback_function,
00236     void* callback_context
00237     );
00238 
00239   /*
00240   Returns:
00241     Current value of the callback function for handling
00242     the uncompressed stream.  If the callback function is
00243     null, the the virtual UncompressedStreamOut() function
00244     is used.
00245   */
00246   ON_StreamCallbackFunction CallbackFunction() const;
00247 
00248   /*
00249   Returns:
00250     Current value of the context pointer passed as the first
00251     argument to the uncompressed stream output handler function.
00252   */
00253   void* CallbackContext() const;
00254   
00255   /*
00256   Description:
00257     Call BeginUnompressStream() one time to initialize the compression
00258     calculation.  Then call In() one or more times 
00259     to submit the compressed stream to the uncompression calculation.  
00260     When you reach the end of the compressed stream, call 
00261     End().
00262   Returns:
00263     true if successful, false if an error occured.
00264   */
00265   bool Begin();
00266 
00267   /*
00268   Description:
00269     Call In() one or more times to uncompress a stream of compressed
00270     bytes.  After the last call to In(), call End(). Calling End()
00271     may generate zero or more calls to the output stream handler.
00272   Parameters:
00273     in_buffer_size - [in]
00274       number of bytes in in_buffer
00275     in_buffer - [in]
00276   Returns:
00277     true if successful, false if an error occured.
00278   */
00279   bool In(
00280     ON__UINT64 in_buffer_size,
00281     const void* in_buffer
00282     );
00283 
00284   /*
00285   Description:
00286     If an explicit uncompressed stream handler is not specified
00287     ( CallbackFunction() returns null ), then the virtual Out() 
00288     function is called to handle the uncompressed output stream.
00289     As the input stream is uncompressed, one or more calls to Out()
00290     will occur.
00291   Returns:
00292     True to continue uncompressing and false to cancel the 
00293     uncompression calculation.
00294   Remarks:
00295     In general, it is probably going to be easier to test and debug
00296     your code if you ignore the callback_context parameter and add 
00297     a member variable to your derived class to make additional
00298     information accessable to your Out function.
00299   */
00300   virtual bool Out( 
00301     void* callback_context, 
00302     ON__UINT32 out_buffer_size, 
00303     const void* out_buffer 
00304     );
00305 
00306   /*
00307   Description:
00308     After the last call to In(), call End().  
00309     Calling End() may generate zero or more 
00310     calls to the output stream handler.
00311   Returns:
00312     true if successful, false if an error occured.
00313   */
00314   bool End();
00315 
00316   /*
00317   Returns:
00318     Then the returned value is the total number bytes in the input
00319     stream. The size is updated every time In() is called before 
00320     any calls are made to the output stream handler.  If the 
00321     calculation is finished ( End() has been called ), then the
00322     returned value is the total number of bytes in the entire 
00323     input stream.
00324   */
00325   ON__UINT64 InSize() const;
00326 
00327   /*
00328   Returns:
00329     Then the returned value is the total number bytes in the output
00330     stream. The size is incremented immediately after each call to
00331     the output stream handler.  If the compression calculation is 
00332     finished ( End() has been called ), then the returned value is
00333     the total number of bytes in the entire output stream.
00334   */
00335   ON__UINT64 OutSize() const;
00336 
00337   /*
00338   Returns:
00339     Then the returned value is the 32-bit crc of the input stream.
00340     The crc is updated every time In() is called before any calls
00341     are made to the output stream handler.  If the compression 
00342     calculation is finished ( End() has been called ), then the
00343     returned value is the 32-bit crc of the entire input stream.
00344   */
00345   ON__UINT32 InCRC() const;
00346 
00347   /*
00348   Returns:
00349     Then the returned value is the 32bit crc of the output stream.
00350     The crc is updated immediately after each call to the output
00351     stream handler.  If the calculation is finished ( End() has 
00352     been called ), then the returned value is the 32-bit crc of
00353     the entire output stream.
00354   */
00355   ON__UINT32 OutCRC() const;
00356 
00357 private:
00358   ON_StreamCallbackFunction m_out_callback_function;
00359   void* m_out_callback_context;
00360   ON__UINT64 m_in_size;
00361   ON__UINT64 m_out_size;
00362   ON__UINT32 m_in_crc;
00363   ON__UINT32 m_out_crc;
00364   void* m_implementation;
00365   void* m_reserved;
00366 
00367   void ErrorHandler();
00368 
00369 private:
00370   // prohibit use - no implementation
00371   ON_UncompressStream(const ON_UncompressStream&);
00372   ON_UncompressStream& operator=(const ON_UncompressStream&);
00373 };
00374 
00375 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:00