From f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 03:49:53 +0000 Subject: Ok, no code is left in src, it's all in src/old. We'll gradually move code back into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier. --- src/sptr.h | 99 -------------------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 src/sptr.h (limited to 'src/sptr.h') diff --git a/src/sptr.h b/src/sptr.h deleted file mode 100644 index deae94d..0000000 --- a/src/sptr.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef SPTR_H -#define SPTR_H - -#include -#include - -template -class SPtr -{ -public: - SPtr() : - pRefCnt( NULL ), - pData( NULL ) - { - } - - ~SPtr() - { - decCount(); - } - - SPtr( const SPtr &src ) : - pRefCnt( src.pRefCnt ), - pData( src.pData ) - { - if( pRefCnt ) - (*pRefCnt) += 1; - } - - SPtr( T *pSrc ) : - pRefCnt( NULL ), - pData( pSrc ) - { - pRefCnt = new int32_t; - (*pRefCnt) = 1; - } - - int32_t count() - { - return *pRefCnt; - } - - T *operator->() const - { - return pData; - } - - T *operator*() const - { - return pData; - } - - SPtr operator=( const SPtr &src ) - { - decCount(); - pRefCnt = src.pRefCnt; - pData = src.pData; - (*pRefCnt) += 1; - - return *this; - } - - bool operator==( const SPtr &src ) - { - return pData == src.pData; - } - - operator bool() - { - return pRefCnt != NULL; - } - - bool isSet() - { - return pRefCnt != NULL; - } - -private: - void decCount() - { - if( pRefCnt ) - { - (*pRefCnt) -= 1; - //printf("Decrementing ref-count to %d\n", *pRefCnt ); - if( (*pRefCnt) == 0 ) - { - delete pRefCnt; - delete pData; - pRefCnt = NULL; - pData = NULL; - } - } - } - - int32_t *pRefCnt; - T *pData; -}; - -#endif -- cgit v1.2.3 From dda94f3b53e02e117e6eb5758afa1410e1664c9f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 15 May 2007 05:25:19 +0000 Subject: SPtr is now Bu::ified, and the List class now acts the way we think const lists should act, you can't change anything in there. I'm still debating changing the const_iterator to a constIterator, or something else that's more Bu::worthy. Heh, the namespaces are funny...ok...I'm really tired. --- src/list.h | 214 ++++++++++++++++++++++++++++++++++++++++++++++++----- src/old/sptr.cpp | 1 - src/old/sptr.h | 99 ------------------------- src/serversocket.h | 10 ++- src/sptr.cpp | 1 + src/sptr.h | 147 ++++++++++++++++++++++++++++++++++++ src/tests/list.cpp | 31 ++++++++ 7 files changed, 382 insertions(+), 121 deletions(-) delete mode 100644 src/old/sptr.cpp delete mode 100644 src/old/sptr.h create mode 100644 src/sptr.cpp create mode 100644 src/sptr.h (limited to 'src/sptr.h') diff --git a/src/list.h b/src/list.h index ec63496..4d16872 100644 --- a/src/list.h +++ b/src/list.h @@ -13,6 +13,15 @@ namespace Bu ListLink *pNext; ListLink *pPrev; }; + + /** + * Linked list template container. This class is similar to the stl list + * class except for a few minor changes. First, it doesn't mimic a stack or + * queue, use the Stack or Queue clasess for that. Second, when const, all + * members are only accessable const. Third, erasing a location does not + * invalidate the iterator, it simply points to the next valid location, or + * end() if there are no more. + */ template, typename linkalloc=std::allocator > > class List { @@ -23,15 +32,59 @@ namespace Bu public: List() : pFirst( NULL ), - pLast( NULL ) + pLast( NULL ), + nSize( 0 ) + { + } + + List( const MyType &src ) : + pFirst( NULL ), + pLast( NULL ), + nSize( 0 ) + { + for( Link *pCur = src.pFirst; pCur; pCur = pCur->pNext ) + { + append( *pCur->pValue ); + } + } + + ~List() + { + clear(); + } + + MyType &operator=( const MyType &src ) { + clear(); + for( Link *pCur = src.pFirst; pCur; pCur = pCur->pNext ) + { + append( *pCur->pValue ); + } + } + + void clear() + { + Link *pCur = pFirst; + for(;;) + { + if( pCur == NULL ) break; + va.destroy( pCur->pValue ); + va.deallocate( pCur->pValue, sizeof( value ) ); + Link *pTmp = pCur->pNext; + la.destroy( pCur ); + la.deallocate( pCur, sizeof( Link ) ); + pCur = pTmp; + } + pFirst = pLast = NULL; + nSize = 0; } - void append( value v ) + void append( const value &v ) { Link *pNew = la.allocate( sizeof( Link ) ); pNew->pValue = va.allocate( sizeof( value ) ); va.construct( pNew->pValue, v ); + nSize++; if( pFirst == NULL ) { // Empty list @@ -47,11 +100,12 @@ namespace Bu } } - void prepend( value v ) + void prepend( const value &v ) { Link *pNew = la.allocate( sizeof( Link ) ); pNew->pValue = va.allocate( sizeof( value ) ); va.construct( pNew->pValue, v ); + nSize++; if( pFirst == NULL ) { // Empty list @@ -83,22 +137,22 @@ namespace Bu } public: - bool operator==( const iterator &oth ) + bool operator==( const iterator &oth ) const { return ( pLink == oth.pLink ); } - bool operator==( const Link *pOth ) + bool operator==( const Link *pOth ) const { return ( pLink == pOth ); } - bool operator!=( const iterator &oth ) + bool operator!=( const iterator &oth ) const { return ( pLink != oth.pLink ); } - bool operator!=( const Link *pOth ) + bool operator!=( const Link *pOth ) const { return ( pLink != pOth ); } @@ -110,40 +164,128 @@ namespace Bu value *operator->() { - return pLink->pValue(); + return pLink->pValue; } - iterator operator++() + iterator &operator++() { if( pLink != NULL ) pLink = pLink->pNext; return *this; } - iterator operator--() + iterator &operator--() { if( pLink != NULL ) pLink = pLink->pPrev; return *this; } - iterator operator++( int ) + iterator &operator++( int ) { if( pLink != NULL ) pLink = pLink->pNext; return *this; } - iterator operator--( int ) + iterator &operator--( int ) { if( pLink != NULL ) pLink = pLink->pPrev; return *this; } - iterator operator=( const iterator &oth ) + iterator &operator=( const iterator &oth ) { pLink = oth.pLink; + return *this; + } + }; + + typedef struct const_iterator + { + friend class List; + private: + Link *pLink; + const_iterator() : + pLink( NULL ) + { + } + + const_iterator( Link *pLink ) : + pLink( pLink ) + { + } + + public: + bool operator==( const const_iterator &oth ) const + { + return ( pLink == oth.pLink ); + } + + bool operator==( const Link *pOth ) const + { + return ( pLink == pOth ); + } + + bool operator!=( const const_iterator &oth ) const + { + return ( pLink != oth.pLink ); + } + + bool operator!=( const Link *pOth ) const + { + return ( pLink != pOth ); + } + + const value &operator*() + { + return *(pLink->pValue); + } + + const value *operator->() + { + return pLink->pValue; + } + + const_iterator &operator++() + { + if( pLink != NULL ) + pLink = pLink->pNext; + return *this; + } + + const_iterator &operator--() + { + if( pLink != NULL ) + pLink = pLink->pPrev; + return *this; + } + + const_iterator &operator++( int ) + { + if( pLink != NULL ) + pLink = pLink->pNext; + return *this; + } + + const_iterator &operator--( int ) + { + if( pLink != NULL ) + pLink = pLink->pPrev; + return *this; + } + + const_iterator &operator=( const iterator &oth ) + { + pLink = oth.pLink; + return *this; + } + + const_iterator &operator=( const const_iterator &oth ) + { + pLink = oth.pLink; + return *this; } }; @@ -152,17 +294,50 @@ namespace Bu return iterator( pFirst ); } - const Link *end() + const const_iterator begin() const + { + return const_iterator( pFirst ); + } + + const Link *end() const { return NULL; } - int getSize() + void erase( iterator &i ) + { + Link *pCur = i.pLink; + Link *pPrev = pCur->pPrev; + if( pPrev == NULL ) + { + va.destroy( pCur->pValue ); + va.deallocate( pCur->pValue, sizeof( value ) ); + pFirst = pCur->pNext; + la.destroy( pCur ); + la.deallocate( pCur, sizeof( Link ) ); + if( pFirst == NULL ) + pLast = NULL; + nSize--; + i.pLink = pFirst; + } + else + { + va.destroy( pCur->pValue ); + va.deallocate( pCur->pValue, sizeof( value ) ); + Link *pTmp = pCur->pNext; + la.destroy( pCur ); + la.deallocate( pCur, sizeof( Link ) ); + pPrev->pNext = pTmp; + if( pTmp != NULL ) + pTmp->pPrev = pPrev; + nSize--; + i.pLink = pTmp; + } + } + + int getSize() const { - int j = 0; - for( Link *pCur = pFirst; pCur; pCur = pCur->pNext ) - j++; - return j; + return nSize; } private: @@ -170,6 +345,7 @@ namespace Bu Link *pLast; linkalloc la; valuealloc va; + int nSize; }; } diff --git a/src/old/sptr.cpp b/src/old/sptr.cpp deleted file mode 100644 index 7f5e894..0000000 --- a/src/old/sptr.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "sptr.h" diff --git a/src/old/sptr.h b/src/old/sptr.h deleted file mode 100644 index deae94d..0000000 --- a/src/old/sptr.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef SPTR_H -#define SPTR_H - -#include -#include - -template -class SPtr -{ -public: - SPtr() : - pRefCnt( NULL ), - pData( NULL ) - { - } - - ~SPtr() - { - decCount(); - } - - SPtr( const SPtr &src ) : - pRefCnt( src.pRefCnt ), - pData( src.pData ) - { - if( pRefCnt ) - (*pRefCnt) += 1; - } - - SPtr( T *pSrc ) : - pRefCnt( NULL ), - pData( pSrc ) - { - pRefCnt = new int32_t; - (*pRefCnt) = 1; - } - - int32_t count() - { - return *pRefCnt; - } - - T *operator->() const - { - return pData; - } - - T *operator*() const - { - return pData; - } - - SPtr operator=( const SPtr &src ) - { - decCount(); - pRefCnt = src.pRefCnt; - pData = src.pData; - (*pRefCnt) += 1; - - return *this; - } - - bool operator==( const SPtr &src ) - { - return pData == src.pData; - } - - operator bool() - { - return pRefCnt != NULL; - } - - bool isSet() - { - return pRefCnt != NULL; - } - -private: - void decCount() - { - if( pRefCnt ) - { - (*pRefCnt) -= 1; - //printf("Decrementing ref-count to %d\n", *pRefCnt ); - if( (*pRefCnt) == 0 ) - { - delete pRefCnt; - delete pData; - pRefCnt = NULL; - pData = NULL; - } - } - } - - int32_t *pRefCnt; - T *pData; -}; - -#endif diff --git a/src/serversocket.h b/src/serversocket.h index 9a26e2d..f146d91 100644 --- a/src/serversocket.h +++ b/src/serversocket.h @@ -2,13 +2,19 @@ #define SERVER_SOCKET_H #include -#include "fstring.h" -#include "socket.h" +#include "bu/fstring.h" namespace Bu { /** + * A single tcp/ip server socket. When created the server socket will bind + * to the specified interface and port, and immediately begin listening for + * connections. When connections come in they are pooled by the networking + * drivers in the kernel until they are accepted, this means that failure + * to keep space in the connection pool will result in connection refusals. * + * Although the accept function returns an integral file descriptor, it is + * designed to be used with the Socket class. */ class ServerSocket { diff --git a/src/sptr.cpp b/src/sptr.cpp new file mode 100644 index 0000000..8ea7f8f --- /dev/null +++ b/src/sptr.cpp @@ -0,0 +1 @@ +#include "bu/sptr.h" diff --git a/src/sptr.h b/src/sptr.h new file mode 100644 index 0000000..faa8524 --- /dev/null +++ b/src/sptr.h @@ -0,0 +1,147 @@ +#ifndef SPTR_H +#define SPTR_H + +#include +#include + +namespace Bu +{ + template class SPtr; + template< typename Tb, typename Ta > SPtr SPtrCast( SPtr src ); + + template + class SPtr + { + template + friend SPtr SPtrCast( SPtr pt ); + public: + SPtr() : + pRefCnt( NULL ), + pData( NULL ) + { + } + + ~SPtr() + { + decCount(); + } + + SPtr( const SPtr &src ) : + pRefCnt( src.pRefCnt ), + pData( src.pData ) + { + if( pRefCnt ) + (*pRefCnt) += 1; + } + + SPtr( T *pSrc ) : + pRefCnt( NULL ), + pData( pSrc ) + { + if( pData ) + { + pRefCnt = new int32_t; + (*pRefCnt) = 1; + } + } + + int32_t count() const + { + return *pRefCnt; + } + + const T *operator->() const + { + return pData; + } + + const T &operator*() const + { + return *pData; + } + + T *operator->() + { + return pData; + } + + T &operator*() + { + return *pData; + } + + SPtr operator=( const SPtr &src ) + { + decCount(); + pRefCnt = src.pRefCnt; + pData = src.pData; + if( pRefCnt ) + (*pRefCnt) += 1; + + return *this; + } + + const SPtr operator=( const SPtr &src ) const + { + decCount(); + pRefCnt = src.pRefCnt; + pData = src.pData; + if( pRefCnt ) + (*pRefCnt) += 1; + + return *this; + } + + bool operator==( const SPtr &src ) const + { + return pData == src.pData; + } + + bool operator==( const T *src ) const + { + return pData == src; + } + + operator bool() const + { + return pRefCnt != NULL; + } + + bool isSet() const + { + return pRefCnt != NULL; + } + + private: + void decCount() const + { + if( pRefCnt ) + { + (*pRefCnt) -= 1; + //printf("Decrementing ref-count to %d\n", *pRefCnt ); + if( (*pRefCnt) == 0 ) + { + delete pRefCnt; + delete pData; + pRefCnt = NULL; + pData = NULL; + } + } + } + + mutable int32_t *pRefCnt; + mutable T *pData; + }; + + template< typename Tb, typename Ta > SPtr SPtrCast( SPtr src ) + { + SPtr ret; + ret.pRefCnt = src.pRefCnt; + ret.pData = dynamic_cast(src.pData); + if( ret.pRefCnt ) + (*(ret.pRefCnt)) += 1; + return ret; + } +} + +#endif diff --git a/src/tests/list.cpp b/src/tests/list.cpp index 34ab656..12807a5 100644 --- a/src/tests/list.cpp +++ b/src/tests/list.cpp @@ -1,4 +1,10 @@ #include "bu/list.h" +#include + +typedef struct Bob +{ + int nID; +} Bob; int main() { @@ -16,7 +22,32 @@ int main() { printf("%d ", *i ); } + printf("\n"); + for( Bu::List::iterator i = l.begin(); i != l.end(); i++ ) + { + l.erase( i ); + if( i != l.end() ) + printf("%d ", *i ); + } + + printf("\n\n"); + Bu::List lb; + for( int j = 0; j < 10; j++ ) + { + Bob b; + b.nID = j; + lb.append( b ); + } + + const Bu::List rb = lb; + + for( Bu::List::const_iterator i = rb.begin(); i != rb.end(); i++ ) + { + //i->nID += 2; + //(*i).nID = 4; + printf("%d ", i->nID ); + } printf("\n\n"); } -- cgit v1.2.3 From 6f94639a3f5e20e1c635b2d8676086464d7cba2e Mon Sep 17 00:00:00 2001 From: David Date: Mon, 18 Jun 2007 20:45:45 +0000 Subject: david - did more documenting --- src/file.h | 18 ++++++++++++ src/list.h | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/sptr.h | 45 +++++++++++++++++++++++++++++ src/stream.h | 58 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 213 insertions(+) (limited to 'src/sptr.h') diff --git a/src/file.h b/src/file.h index fe8dbda..1a4421b 100644 --- a/src/file.h +++ b/src/file.h @@ -39,6 +39,14 @@ namespace Bu virtual bool isBlocking(); virtual void setBlocking( bool bBlocking=true ); + /** + * Create a temp file and return its handle + *@param sName (Bu::FString) Give in the form: "/tmp/tmpfileXXXXXXXX" + * It will alter your (sName) setting the 'X's to random + * characters. + *@param sFlags (const char *) Standard file flags 'rb'... etc.. + *@returns (Bu::File) A file object representing your temp file. + */ inline static Bu::File tempFile( Bu::FString &sName, const char *sFlags ) { int afh_d = mkstemp( sName.getStr() ); @@ -46,7 +54,17 @@ namespace Bu return Bu::File( afh_d, sFlags ); } + /** + * Set the size of the file to (nSize). You can either grow or shrink + * the file. + *@param nSize (long) The new size of the file. + */ void truncate( long nSize ); + + /** + * Change the file access permissions. + *@param t (mode_t) The new file access permissions. + */ void chmod( mode_t t ); private: diff --git a/src/list.h b/src/list.h index 9d1f904..314459e 100644 --- a/src/list.h +++ b/src/list.h @@ -115,6 +115,10 @@ namespace Bu } } + /** + * Prepend a value to the list. + *@param v (const value_type &) The value to prepend. + */ void prepend( const value &v ) { Link *pNew = la.allocate( 1 ); @@ -136,6 +140,9 @@ namespace Bu } } + /** + * An iterator to iterate through your list. + */ typedef struct iterator { friend class List; @@ -152,36 +159,67 @@ namespace Bu } public: + /** + * Equals comparison operator. + *@param oth (const iterator &) The iterator to compare to. + *@returns (bool) Are they equal? + */ bool operator==( const iterator &oth ) const { return ( pLink == oth.pLink ); } + /** + * Equals comparison operator. + *@param pOth (const Link *) The link to compare to. + *@returns (bool) Are they equal? + */ bool operator==( const Link *pOth ) const { return ( pLink == pOth ); } + /** + * Not equals comparison operator. + *@param oth (const iterator &) The iterator to compare to. + *@returns (bool) Are they not equal? + */ bool operator!=( const iterator &oth ) const { return ( pLink != oth.pLink ); } + /** + * Not equals comparison operator. + *@param pOth (const Link *) The link to compare to. + *@returns (bool) Are they not equal? + */ bool operator!=( const Link *pOth ) const { return ( pLink != pOth ); } + /** + * Dereference operator. + *@returns (value_type &) The value. + */ value &operator*() { return *(pLink->pValue); } + /** + * Pointer access operator. + *@returns (value_type *) A pointer to the value. + */ value *operator->() { return pLink->pValue; } + /** + * Increment operator. + */ iterator &operator++() { if( pLink != NULL ) @@ -189,6 +227,9 @@ namespace Bu return *this; } + /** + * Decrement operator. + */ iterator &operator--() { if( pLink != NULL ) @@ -196,6 +237,9 @@ namespace Bu return *this; } + /** + * Increment operator. + */ iterator &operator++( int ) { if( pLink != NULL ) @@ -203,6 +247,9 @@ namespace Bu return *this; } + /** + * Decrement operator. + */ iterator &operator--( int ) { if( pLink != NULL ) @@ -210,6 +257,11 @@ namespace Bu return *this; } + /** + * Assignment operator. + *@param oth (const iterator &) The other iterator to set this + * one to. + */ iterator &operator=( const iterator &oth ) { pLink = oth.pLink; @@ -217,6 +269,9 @@ namespace Bu } }; + /** + *@see iterator + */ typedef struct const_iterator { friend class List; @@ -309,21 +364,38 @@ namespace Bu } }; + /** + * Get an iterator pointing to the first item in the list. + *@returns (iterator) + */ iterator begin() { return iterator( pFirst ); } + /** + * Get a const iterator pointing to the first item in the list. + *@returns (const const_iterator) + */ const const_iterator begin() const { return const_iterator( pFirst ); } + /** + * Get an iterator pointing to a place just past the last item in + * the list. + *@returns (const Link *) + */ const Link *end() const { return NULL; } + /** + * Erase an item from the list. + *@param i (iterator) The item to erase. + */ void erase( iterator &i ) { Link *pCur = i.pLink; @@ -355,26 +427,46 @@ namespace Bu } } + /** + * Get the current size of the list. + *@returns (int) The current size of the list. + */ int getSize() const { return nSize; } + /** + * Get the first item in the list. + *@returns (value_type &) The first item in the list. + */ value &first() { return *pFirst->pValue; } + /** + * Get the first item in the list. + *@returns (const value_type &) The first item in the list. + */ const value &first() const { return *pFirst->pValue; } + /** + * Get the last item in the list. + *@returns (value_type &) The last item in the list. + */ value &last() { return *pLast->pValue; } + /** + * Get the last item in the list. + *@returns (const value_type &) The last item in the list. + */ const value &last() const { return *pLast->pValue; diff --git a/src/sptr.h b/src/sptr.h index faa8524..4baa697 100644 --- a/src/sptr.h +++ b/src/sptr.h @@ -45,31 +45,55 @@ namespace Bu } } + /** + * Get the number of references to this pointer. + *@returns (int32_t) The number of references to this pointer. + */ int32_t count() const { return *pRefCnt; } + /** + * Pointer access operator. + *@returns (const T *) + */ const T *operator->() const { return pData; } + /** + * Dereference operator. + *@returns (const T &) The value at the end of the pointer. + */ const T &operator*() const { return *pData; } + /** + * Pointer access operator. + *@returns (T *) + */ T *operator->() { return pData; } + /** + * Dereference operator. + *@returns (T &) The value at the end of the pointer. + */ T &operator*() { return *pData; } + /** + * Assignment operator. + *@param src (const SPtr &) + */ SPtr operator=( const SPtr &src ) { decCount(); @@ -81,6 +105,10 @@ namespace Bu return *this; } + /** + * Assignment operator. + *@param src (const SPtr &) + */ const SPtr operator=( const SPtr &src ) const { decCount(); @@ -92,21 +120,38 @@ namespace Bu return *this; } + /** + * Equals comparison operator. + *@param src (const SPtr &) The SPtr to compare to. + *@returns (bool) Are the equal? + */ bool operator==( const SPtr &src ) const { return pData == src.pData; } + /** + * Equals comparison operator. + *@param src (const T *) The pointer to compare to. + *@returns (bool) Are the equal? + */ bool operator==( const T *src ) const { return pData == src; } + /** + * Boolean cast operator. Do we have a pointer? + */ operator bool() const { return pRefCnt != NULL; } + /** + * Do we have a pointer? + *@returns (bool) Do we have a pointer? + */ bool isSet() const { return pRefCnt != NULL; diff --git a/src/stream.h b/src/stream.h index ba070d3..056de0c 100644 --- a/src/stream.h +++ b/src/stream.h @@ -22,17 +22,66 @@ namespace Bu Stream(); virtual ~Stream(); + /** + * Close the stream. + */ virtual void close() = 0; + + /** + * Read data from the stream into a buffer. + *@param pBuf (void *) Buffer which will be filled. + *@param nBytes (size_t) Max data to read. + *@returns (size_t) Amount of data read. + */ virtual size_t read( void *pBuf, size_t nBytes ) = 0; + + /** + * Write data to the stream. + *@param pBuf (const void *) The data to be written. + *@param nBytes (size_t) Amount of data to write from pBuf. + *@returns (size_t) Amount of data actually written. + */ virtual size_t write( const void *pBuf, size_t nBytes ) = 0; + /** + * Get the current position in the stream. + *@returns (long) The current position in the stream. + */ virtual long tell() = 0; + + /** + * Seek to a position in the stream relative to the current position. + *@param offset (long) Offset from current position to seek to. + */ virtual void seek( long offset ) = 0; + + /** + * Set position in the stream relative to the start of the stream. + *@param pos (long) The position. + */ virtual void setPos( long pos ) = 0; + + /** + * Set position in the stream relative to the end of the stream. + *@param pos (long) The position. + */ virtual void setPosEnd( long pos ) = 0; + + /** + * Are we at the end of the stream? + *@returns (bool) Are we at the end of the stream? + */ virtual bool isEOS() = 0; + + /** + * Is the stream open? + *@returns (bool) Is the stream open? + */ virtual bool isOpen() = 0; + /** + * Flush any data still held in buffers. + */ virtual void flush() = 0; /** @@ -71,7 +120,16 @@ namespace Bu */ virtual bool isSeekable() = 0; + /** + * Are we currently set to block mode? + *@returns (bool) + */ virtual bool isBlocking() = 0; + + /** + * Set stream to blocking or non-blocking mode. + *@param bBlocking (bool) Whether we should block or not. + */ virtual void setBlocking( bool bBlocking=true ) = 0; public: // Filters -- cgit v1.2.3 From 932677862376e9642a496a15b7f09f1106f495a5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 28 Jun 2007 20:49:39 +0000 Subject: Many minor changes, hopefully the header fixes will keep future header macro conflicts from happening. And, from now on, other projects should do -Ilibbu++ not -Ilibbu++/src so we can get ready for an installed version of libbu++. --- bu | 1 + src/archival.h | 4 ++-- src/archive.h | 4 ++-- src/atom.h | 4 ++-- src/bzip2.h | 4 ++-- src/client.h | 4 ++-- src/exceptionbase.h | 4 ++-- src/exceptions.h | 4 ++-- src/file.h | 4 ++-- src/filter.h | 4 ++-- src/fstring.h | 4 ++-- src/hash.h | 4 ++-- src/ito.h | 4 ++-- src/itoatom.h | 4 ++-- src/itocondition.h | 4 ++-- src/itomutex.h | 4 ++-- src/itoqueue.h | 4 ++-- src/linkmessage.h | 4 ++-- src/list.h | 4 ++-- src/membuf.h | 4 ++-- src/paramproc.h | 4 ++-- src/plugger.h | 4 ++-- src/programchain.h | 4 ++-- src/programlink.h | 4 ++-- src/protocol.h | 4 ++-- src/ringbuffer.h | 4 ++-- src/server.h | 4 ++-- src/serversocket.h | 4 ++-- src/singleton.h | 4 ++-- src/socket.h | 4 ++-- src/sptr.h | 4 ++-- src/stream.h | 4 ++-- src/unitsuite.h | 4 ++-- 33 files changed, 65 insertions(+), 64 deletions(-) create mode 120000 bu (limited to 'src/sptr.h') diff --git a/bu b/bu new file mode 120000 index 0000000..02b8847 --- /dev/null +++ b/bu @@ -0,0 +1 @@ +src/bu/ \ No newline at end of file diff --git a/src/archival.h b/src/archival.h index e2c803c..8be3308 100644 --- a/src/archival.h +++ b/src/archival.h @@ -1,5 +1,5 @@ -#ifndef ARCHIVAL_H -#define ARCHIVAL_H +#ifndef BU_ARCHIVAL_H +#define BU_ARCHIVAL_H namespace Bu { diff --git a/src/archive.h b/src/archive.h index 05c6f57..6c0c1df 100644 --- a/src/archive.h +++ b/src/archive.h @@ -1,5 +1,5 @@ -#ifndef ARCHIVE_H -#define ARCHIVE_H +#ifndef BU_ARCHIVE_H +#define BU_ARCHIVE_H #include #include diff --git a/src/atom.h b/src/atom.h index a0469b6..fad47eb 100644 --- a/src/atom.h +++ b/src/atom.h @@ -1,5 +1,5 @@ -#ifndef ATOM_H -#define ATOM_H +#ifndef BU_ATOM_H +#define BU_ATOM_H #include #include diff --git a/src/bzip2.h b/src/bzip2.h index 25f10c5..0a111e8 100644 --- a/src/bzip2.h +++ b/src/bzip2.h @@ -1,5 +1,5 @@ -#ifndef B_ZIP2_H -#define B_ZIP2_H +#ifndef BU_BZIP2_H +#define BU_BZIP2_H #include #include diff --git a/src/client.h b/src/client.h index 02ba077..cee558d 100644 --- a/src/client.h +++ b/src/client.h @@ -1,5 +1,5 @@ -#ifndef CLIENT_H -#define CLIENT_H +#ifndef BU_CLIENT_H +#define BU_CLIENT_H #include diff --git a/src/exceptionbase.h b/src/exceptionbase.h index fd78089..24e4bbf 100644 --- a/src/exceptionbase.h +++ b/src/exceptionbase.h @@ -1,5 +1,5 @@ -#ifndef EXCEPTION_BASE_H -#define EXCEPTION_BASE_H +#ifndef BU_EXCEPTION_BASE_H +#define BU_EXCEPTION_BASE_H #include #include diff --git a/src/exceptions.h b/src/exceptions.h index d5a9d39..b824b91 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -1,5 +1,5 @@ -#ifndef EXCEPTIONS_H -#define EXCEPTIONS_H +#ifndef BU_EXCEPTIONS_H +#define BU_EXCEPTIONS_H #include "exceptionbase.h" #include diff --git a/src/file.h b/src/file.h index 0f638a7..d4e43eb 100644 --- a/src/file.h +++ b/src/file.h @@ -1,5 +1,5 @@ -#ifndef FILE_H -#define FILE_H +#ifndef BU_FILE_H +#define BU_FILE_H #include diff --git a/src/filter.h b/src/filter.h index 7bb04bc..bd557b2 100644 --- a/src/filter.h +++ b/src/filter.h @@ -1,5 +1,5 @@ -#ifndef FILTER_H -#define FILTER_H +#ifndef BU_FILTER_H +#define BU_FILTER_H #include diff --git a/src/fstring.h b/src/fstring.h index 7180f5f..bf6518b 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -1,5 +1,5 @@ -#ifndef F_STRING_H -#define F_STRING_H +#ifndef BU_F_STRING_H +#define BU_F_STRING_H #include #include diff --git a/src/hash.h b/src/hash.h index 6c4a443..0fa3af7 100644 --- a/src/hash.h +++ b/src/hash.h @@ -1,5 +1,5 @@ -#ifndef HASH_H -#define HASH_H +#ifndef BU_HASH_H +#define BU_HASH_H #include #include diff --git a/src/ito.h b/src/ito.h index 01253f5..c062052 100644 --- a/src/ito.h +++ b/src/ito.h @@ -1,5 +1,5 @@ -#ifndef ITO_H -#define ITO_H +#ifndef BU_ITO_H +#define BU_ITO_H #include diff --git a/src/itoatom.h b/src/itoatom.h index 96090f2..7fc9090 100644 --- a/src/itoatom.h +++ b/src/itoatom.h @@ -1,5 +1,5 @@ -#ifndef ITO_QUEUE_H -#define ITO_QUEUE_H +#ifndef BU_ITO_QUEUE_H +#define BU_ITO_QUEUE_H #include diff --git a/src/itocondition.h b/src/itocondition.h index 4771b22..1793f81 100644 --- a/src/itocondition.h +++ b/src/itocondition.h @@ -1,5 +1,5 @@ -#ifndef ITO_CONDITION_H -#define ITO_CONDITION_H +#ifndef BU_ITO_CONDITION_H +#define BU_ITO_CONDITION_H #include diff --git a/src/itomutex.h b/src/itomutex.h index 80956b8..9c9d205 100644 --- a/src/itomutex.h +++ b/src/itomutex.h @@ -1,5 +1,5 @@ -#ifndef ITO_MUTEX_H -#define ITO_MUTEX_H +#ifndef BU_ITO_MUTEX_H +#define BU_ITO_MUTEX_H #include diff --git a/src/itoqueue.h b/src/itoqueue.h index 322698d..75a2f27 100644 --- a/src/itoqueue.h +++ b/src/itoqueue.h @@ -1,5 +1,5 @@ -#ifndef ITO_QUEUE_H -#define ITO_QUEUE_H +#ifndef BU_ITO_QUEUE_H +#define BU_ITO_QUEUE_H #include diff --git a/src/linkmessage.h b/src/linkmessage.h index 64b8bc2..baa22a6 100644 --- a/src/linkmessage.h +++ b/src/linkmessage.h @@ -1,8 +1,8 @@ /**\file linkmessage.h */ -#ifndef LINKMESSAGE_H -#define LINKMESSAGE_H +#ifndef BU_LINKMESSAGE_H +#define BU_LINKMESSAGE_H namespace Bu { diff --git a/src/list.h b/src/list.h index 314459e..6235619 100644 --- a/src/list.h +++ b/src/list.h @@ -1,5 +1,5 @@ -#ifndef LIST_H -#define LIST_H +#ifndef BU_LIST_H +#define BU_LIST_H #include #include "bu/exceptionbase.h" diff --git a/src/membuf.h b/src/membuf.h index 877b35e..b82f943 100644 --- a/src/membuf.h +++ b/src/membuf.h @@ -1,5 +1,5 @@ -#ifndef MEM_BUF_H -#define MEM_BUF_H +#ifndef BU_MEM_BUF_H +#define BU_MEM_BUF_H #include diff --git a/src/paramproc.h b/src/paramproc.h index beee4a0..2bca588 100644 --- a/src/paramproc.h +++ b/src/paramproc.h @@ -1,5 +1,5 @@ -#ifndef PARAM_PROC_H -#define PARAM_PROC_H +#ifndef BU_PARAM_PROC_H +#define BU_PARAM_PROC_H #include #include diff --git a/src/plugger.h b/src/plugger.h index 4d2e7af..79a3271 100644 --- a/src/plugger.h +++ b/src/plugger.h @@ -1,5 +1,5 @@ -#ifndef PLUGGER_H -#define PLUGGER_H +#ifndef BU_PLUGGER_H +#define BU_PLUGGER_H #include "bu/hash.h" diff --git a/src/programchain.h b/src/programchain.h index e73d659..336a9f1 100644 --- a/src/programchain.h +++ b/src/programchain.h @@ -1,5 +1,5 @@ -#ifndef PROGRAMCHAIN_H -#define PROGRAMCHAIN_H +#ifndef BU_PROGRAMCHAIN_H +#define BU_PROGRAMCHAIN_H #include "bu/list.h" #include "bu/linkmessage.h" diff --git a/src/programlink.h b/src/programlink.h index 7c31a18..07d7489 100644 --- a/src/programlink.h +++ b/src/programlink.h @@ -1,5 +1,5 @@ -#ifndef PROGRAMLINK_H -#define PROGRAMLINK_H +#ifndef BU_PROGRAMLINK_H +#define BU_PROGRAMLINK_H #include "bu/linkmessage.h" #include "bu/programchain.h" diff --git a/src/protocol.h b/src/protocol.h index 3accd99..c7a9275 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -1,5 +1,5 @@ -#ifndef PROTOCOL_H -#define PROTOCOL_H +#ifndef BU_PROTOCOL_H +#define BU_PROTOCOL_H #include diff --git a/src/ringbuffer.h b/src/ringbuffer.h index 625f65b..be80e2f 100644 --- a/src/ringbuffer.h +++ b/src/ringbuffer.h @@ -1,5 +1,5 @@ -#ifndef RING_BUFFER_H -#define RING_BUFFER_H +#ifndef BU_RING_BUFFER_H +#define BU_RING_BUFFER_H #include #include "bu/exceptionbase.h" diff --git a/src/server.h b/src/server.h index 07eef95..302b6e3 100644 --- a/src/server.h +++ b/src/server.h @@ -1,5 +1,5 @@ -#ifndef SERVER_H -#define SERVER_H +#ifndef BU_SERVER_H +#define BU_SERVER_H #include diff --git a/src/serversocket.h b/src/serversocket.h index cb86078..b4ee247 100644 --- a/src/serversocket.h +++ b/src/serversocket.h @@ -1,5 +1,5 @@ -#ifndef SERVER_SOCKET_H -#define SERVER_SOCKET_H +#ifndef BU_SERVER_SOCKET_H +#define BU_SERVER_SOCKET_H #include #include "bu/fstring.h" diff --git a/src/singleton.h b/src/singleton.h index 4976a61..c43d71b 100644 --- a/src/singleton.h +++ b/src/singleton.h @@ -1,5 +1,5 @@ -#ifndef SINGLETON_H -#define SINGLETON_H +#ifndef BU_SINGLETON_H +#define BU_SINGLETON_H #include diff --git a/src/socket.h b/src/socket.h index c9dbd8d..0ccee3b 100644 --- a/src/socket.h +++ b/src/socket.h @@ -1,5 +1,5 @@ -#ifndef SOCKET_H -#define SOCKET_H +#ifndef BU_SOCKET_H +#define BU_SOCKET_H #include diff --git a/src/sptr.h b/src/sptr.h index 4baa697..75851a6 100644 --- a/src/sptr.h +++ b/src/sptr.h @@ -1,5 +1,5 @@ -#ifndef SPTR_H -#define SPTR_H +#ifndef BU_SPTR_H +#define BU_SPTR_H #include #include diff --git a/src/stream.h b/src/stream.h index 056de0c..1e236a6 100644 --- a/src/stream.h +++ b/src/stream.h @@ -1,5 +1,5 @@ -#ifndef STREAM_H -#define STREAM_H +#ifndef BU_STREAM_H +#define BU_STREAM_H #include #include diff --git a/src/unitsuite.h b/src/unitsuite.h index 6e9270a..578b4cc 100644 --- a/src/unitsuite.h +++ b/src/unitsuite.h @@ -1,5 +1,5 @@ -#ifndef UNIT_SUITE_H -#define UNIT_SUITE_H +#ifndef BU_UNIT_SUITE_H +#define BU_UNIT_SUITE_H #include #include -- cgit v1.2.3