debian/tmp/usr/include/conexus-0.5/conexus/data.h

00001 /***************************************************************************
00002 *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003 *   rvinyard@cs.nmsu.edu                                                  *
00004 *                                                                         *
00005 *   This program is free software; you can redistribute it and/or modify  *
00006 *   it under the terms of the GNU Lesser General Public License as        *
00007 *   published by the Free Software Foundation version 2.1.                *
00008 *                                                                         *
00009 *   This program is distributed in the hope that it will be useful,       *
00010 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012 *   GNU General Public License for more details.                          *
00013 *                                                                         *
00014 *   You should have received a copy of the GNU Lesser General Public      *
00015 *   License along with this library; if not, write to the                 *
00016 *   Free Software Foundation, Inc.,                                       *
00017 *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018 ***************************************************************************/
00019 #ifndef CONEXUSDATA_H
00020 #define CONEXUSDATA_H
00021 
00022 #include <string>
00023 
00024 #include <sigc++/sigc++.h>
00025 
00026 #include <conexus/pointer.h>
00027 
00028 #include <glibmm/timeval.h>
00029 
00030 namespace Conexus
00031 {
00032 
00037   typedef uint8_t Octet;
00038 
00039   typedef enum DataMode {
00040     COPY,
00041     MANAGED,
00042     UNMANAGED,
00043   } DataMode;
00044 
00051   struct Data
00052   {
00053     protected:
00054 
00056       Data( size_t s = 0 ) throw (std::bad_alloc);
00057 
00059       Data( const void* d, size_t s, DataMode mode=COPY ) throw (std::bad_alloc);
00060 
00061     public:
00062     
00064       typedef ConexusPointer<Data> pointer;
00065       
00066       typedef ConexusPointer<const Data> const_pointer;
00067 
00069       static pointer create( size_t s = 0 ) throw (std::bad_alloc);
00070 
00072       static pointer create( const void* d, size_t s, DataMode mode=COPY ) throw (std::bad_alloc);
00073 
00075       virtual ~Data();
00076 
00078       Octet* data();
00079 
00081       const Octet* data() const;
00082 
00084       virtual void set_data( const void* newdata, size_t newsize, DataMode mode=COPY ) throw (std::bad_alloc);
00085 
00087       virtual size_t size() const;
00088 
00098       virtual bool resize( size_t s ) throw (std::bad_alloc);
00099 
00105       Data::pointer clone() const;
00106 
00108       operator Octet*();
00109 
00111       operator const Octet*() const;
00112 
00114       operator void*();
00115 
00117       operator const void*() const;
00118 
00120       std::string hex_string( std::string separator = std::string() ) const;
00121 
00123       virtual void clear();
00124 
00126       sigc::signal<void,size_t> signal_size_changed();
00127     
00129       sigc::signal<void,Octet*> signal_data_buffer_changed();
00130 
00132       Glib::TimeVal& time();
00133 
00134     protected:
00135 
00136       sigc::signal<void,size_t> m_signal_size_changed;
00137     
00138       sigc::signal<void,Octet*> m_signal_data_buffer_changed;
00139     
00140     private:
00141       
00143       Octet* m_data_buffer;
00144 
00146       size_t m_size;
00147 
00149       bool m_manage_data;
00150 
00152       Glib::TimeVal m_time;
00153       
00154   };
00155 
00156 
00157 }
00158 
00159 #endif

Generated on Tue Mar 13 19:54:43 2007 by  doxygen 1.5.1