You can subscribe to this list here.
2004 |
Jan
|
Feb
(48) |
Mar
(80) |
Apr
(9) |
May
(2) |
Jun
(91) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Dejan L. <dlo...@us...> - 2004-06-14 11:35:07
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17157 Modified Files: CMakeLists.txt Log Message: added queue Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/CMakeLists.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** CMakeLists.txt 13 Jun 2004 14:17:40 -0000 1.17 --- CMakeLists.txt 14 Jun 2004 11:34:58 -0000 1.18 *************** *** 41,45 **** error.cpp String.cpp Array.cpp rchar.cpp Vector.cpp Variant.cpp ! PriorityQueue.cpp Buffer.cpp ) --- 41,45 ---- error.cpp String.cpp Array.cpp rchar.cpp Vector.cpp Variant.cpp ! PriorityQueue.cpp Buffer.cpp Queue.cpp ) |
From: Dejan L. <dlo...@us...> - 2004-06-14 11:00:36
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25005 Modified Files: Queue.h Log Message: Added GetMaxSize and SetMaxSize Index: Queue.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Queue.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Queue.h 13 Jun 2004 13:20:49 -0000 1.1 --- Queue.h 14 Jun 2004 11:00:26 -0000 1.2 *************** *** 69,73 **** * @param sort is order ascendencig or descendencing */ ! Queue(): _count(0), _head(0), _tail(0), _free_func(0), _mutex(0) { } // --------- DESTRUCTORS ----------------------------------- --- 69,73 ---- * @param sort is order ascendencig or descendencing */ ! Queue(): _count(0), _max_size(0), _head(0), _tail(0), _free_func(0), _mutex(0) { } // --------- DESTRUCTORS ----------------------------------- *************** *** 82,86 **** * Returns number of items in the list. */ ! int GetCount() const { return this->_count; } /** --- 82,86 ---- * Returns number of items in the list. */ ! int GetCount() const { return _count; } /** *************** *** 88,92 **** * @return QueueNode pointer to first node in Queue. */ ! QueueNode* GetFirst() const { return this->_head; } /** --- 88,92 ---- * @return QueueNode pointer to first node in Queue. */ ! QueueNode* GetFirst() const { return _head; } /** *************** *** 100,103 **** --- 100,109 ---- Mutex* GetMutex() { return _mutex; } + + /** + * GetMaxSize, Maximum size of Queue, if return value is 0 + * then Queue have no maximum size. + */ + int GetMaxSize() {return _max_size; } // --------- SET METHODS ----------------------------------- *************** *** 113,116 **** --- 119,127 ---- void SetMutex(Mutex* mutex) { _mutex = mutex; } + /** + * Set maximum size for Queue if max_size is 0 then Queue have + * no max size + */ + void SetMaxSize(int max_size) { _max_size = max_size; } // --------- OTHER METHODS --------------------------------- *************** *** 142,162 **** int Contains(void *data) const; - /** - * Returns TRUE if given node is _head node in Queue. - * @param element QueueNode* Node that should be checked. - * @return TRUE if given node is _head node in Queue, FALSE otherwize. - */ - bool IsFirst(const QueueNode* element) const { return ((element == this->_head) ? true : false); } - - /** - * Returns TRUE if given node is _tail node in Queue. - * @param element QueueNode* Node that should be checked. - * @return TRUE if given node oElement is _tail node in Queue, FALSE otherwize. - */ - bool IsLast(const QueueNode* element) const { return ((element->next == 0) ? true : false); } - protected: // Members int _count; /// Size of the list object (how many elements are stored inside) bool _sort; /// How priority queue is sorted QueueNode* _head; /// Pointer to _head element of the List. --- 153,160 ---- int Contains(void *data) const; protected: // Members int _count; /// Size of the list object (how many elements are stored inside) + int _max_size; /// Max size of Queue bool _sort; /// How priority queue is sorted QueueNode* _head; /// Pointer to _head element of the List. |
From: Mikko L. <laz...@us...> - 2004-06-13 19:54:51
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14886 Modified Files: Mutex.h Log Message: moved all OS specific header to source file Index: Mutex.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Mutex.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Mutex.h 13 Jun 2004 19:42:16 -0000 1.4 --- Mutex.h 13 Jun 2004 19:54:43 -0000 1.5 *************** *** 47,58 **** #include <rtk/Export.h> - #ifdef _WIN32 - # ifndef _WIN32_WCE - # include <process.h> - # endif - # include <windows.h> - # include <limits.h> - #endif - namespace Rtk { --- 47,50 ---- *************** *** 74,78 **** void Destroy(); ! void *_prv; }; // Mutex class --- 66,70 ---- void Destroy(); ! void *_prv; // OS specific context }; // Mutex class |
From: Mikko L. <laz...@us...> - 2004-06-13 19:54:34
|
Update of /cvsroot/rtk/rtk/src/core/platform/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14600 Modified Files: Mutex.cpp Log Message: moved all OS specific header to source file Index: Mutex.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/win32/Mutex.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Mutex.cpp 21 Feb 2004 10:06:54 -0000 1.2 --- Mutex.cpp 13 Jun 2004 19:54:25 -0000 1.3 *************** *** 46,72 **** */ #include <rtk/Mutex.h> namespace Rtk { void Mutex::Init() { ! InitializeCriticalSection(&_cs); } void Mutex::Destroy() { ! DeleteCriticalSection(&_cs); } void Mutex::Lock() { ! EnterCriticalSection(&_cs); } void Mutex::Unlock() { ! LeaveCriticalSection(&_cs); } --- 46,91 ---- */ + #include <rtk/Mutex.h> + #include <stdlib.h> + #ifndef _WIN32_WCE + # include <process.h> + #endif + #include <windows.h> + #include <limits.h> + namespace Rtk { + struct _private_data + { + CRITICAL_SECTION cs; + }; + + #define PRV ((struct _private_data*)_prv) + void Mutex::Init() { ! _prv = malloc(sizeof(_private_data)); ! memset(_prv, 0, sizeof(_private_data)); ! InitializeCriticalSection(&PRV->cs); } void Mutex::Destroy() { ! DeleteCriticalSection(&PRV->cs); ! free(_prv); ! _prv = 0; } void Mutex::Lock() { ! EnterCriticalSection(&PRV->cs); } void Mutex::Unlock() { ! LeaveCriticalSection(&PRV->cs); } |
From: Mikko L. <laz...@us...> - 2004-06-13 19:42:24
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2718 Modified Files: Mutex.h conf.h Log Message: Removed platform headers Index: Mutex.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Mutex.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Mutex.h 6 Mar 2004 12:04:06 -0000 1.3 --- Mutex.h 13 Jun 2004 19:42:16 -0000 1.4 *************** *** 53,60 **** # include <windows.h> # include <limits.h> - #else - # include <pthread.h> - # include <signal.h> - # include <unistd.h> #endif --- 53,56 ---- *************** *** 78,88 **** void Destroy(); ! #ifdef _WIN32 ! CRITICAL_SECTION _cs; ! #else ! pthread_mutex_t _cs; ! pthread_t _owner; ! int _recursive_counter; ! #endif // _WIN32 }; // Mutex class --- 74,78 ---- void Destroy(); ! void *_prv; }; // Mutex class Index: conf.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/conf.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** conf.h 8 Mar 2004 19:55:23 -0000 1.11 --- conf.h 13 Jun 2004 19:42:16 -0000 1.12 *************** *** 59,74 **** // Define this, if the platform uses UNICODE ! // RTK_BC_UNICODE is (like all *_BC_* macros) set by CMake/autotools ! // #define RTK_UNICODE 1 ! #if defined(_RTK_WINCE_) && !defined(RTK_UNICODE) ! // UNICODE is MUST under WinCE ! # define RTK_UNICODE 1 #endif ! #ifdef RTK_UNICODE ! # define UNICODE 1 ! #else ! # undef UNICODE #endif --- 59,72 ---- // Define this, if the platform uses UNICODE ! //#define UNICODE 1 ! #if defined(_RTK_WIN32_) ! // UNICODE is default WIN32, but not must ! # define UNICODE 1 #endif ! #if defined(_RTK_WINCE_) && !defined(UNICODE) ! // UNICODE is MUST under WinCE ! # define UNICODE 1 #endif *************** *** 88,93 **** #endif // __RTK_CONFIG_H__ - - /** - * $Id$ - ***************************************************************************/ --- 86,87 ---- |
From: Mikko L. <laz...@us...> - 2004-06-13 19:41:01
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv851/core Modified Files: Buffer.cpp Log Message: Moved all includes to source file in Mutex, we dont want to include platform specific files in our public header! File works now Index: Buffer.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Buffer.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Buffer.cpp 13 Jun 2004 12:16:48 -0000 1.11 --- Buffer.cpp 13 Jun 2004 19:40:37 -0000 1.12 *************** *** 43,51 **** #include <string.h> /* memcpy() */ #include <stdlib.h> /* malloc() */ - #include <rtk/Buffer.h> ! #if _DEBUG ! #include <rtk/debug.h> ! #endif namespace Rtk --- 43,49 ---- #include <string.h> /* memcpy() */ #include <stdlib.h> /* malloc() */ ! #include <rtk/Buffer.h> ! #include <rtk/debug.h> namespace Rtk |
From: Mikko L. <laz...@us...> - 2004-06-13 19:41:01
|
Update of /cvsroot/rtk/rtk/src/core/platform/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv851/core/platform/linux Modified Files: File.cpp Mutex.cpp Log Message: Moved all includes to source file in Mutex, we dont want to include platform specific files in our public header! File works now Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/File.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** File.cpp 13 Jun 2004 18:46:03 -0000 1.10 --- File.cpp 13 Jun 2004 19:40:51 -0000 1.11 *************** *** 223,227 **** } } ! RETURN_SUCCESS; } --- 223,228 ---- } } ! ! SetOpen(); RETURN_SUCCESS; } *************** *** 242,245 **** --- 243,249 ---- if(close(FD)<0) return false; + ClearOpen(); + _handle = INVALID_HANDLE_VALUE; + const RCHAR *file = _filename.c_str(); const char *afile = NULL; *************** *** 256,261 **** unlink(afile); - _handle = INVALID_HANDLE_VALUE; - return true; } --- 260,263 ---- Index: Mutex.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/Mutex.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Mutex.cpp 9 Mar 2004 17:01:28 -0000 1.6 --- Mutex.cpp 13 Jun 2004 19:40:52 -0000 1.7 *************** *** 40,44 **** * - ***************************************************************************/ ! #include <rtk/Mutex.h> #include <rtk/debug.h> --- 40,49 ---- * - ***************************************************************************/ ! ! #include <stdlib.h> ! #include <pthread.h> ! #include <signal.h> ! #include <unistd.h> ! #include <rtk/Mutex.h> #include <rtk/debug.h> *************** *** 47,50 **** --- 52,64 ---- { + struct _private_data + { + pthread_mutex_t cs; + pthread_t owner; + int recursive_counter; + }; + + #define PRV ((struct _private_data*)_prv) + // Linux supports recursive locks, use them directly, with some cheating: #ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP *************** *** 53,65 **** void Mutex::Init() { ! pthread_mutex_init(&_cs, &mutex_attr); } void Mutex::Lock() { ! pthread_mutex_lock(&_cs); } void Mutex::Unlock() { ! pthread_mutex_unlock(&_cs); } --- 67,81 ---- void Mutex::Init() { ! _prv = malloc(sizeof(_private_data)); ! memset(_prv, 0, sizeof(_private_data)); ! pthread_mutex_init(&PRV->cs, &mutex_attr); } void Mutex::Lock() { ! pthread_mutex_lock(&PRV->cs); } void Mutex::Unlock() { ! pthread_mutex_unlock(&PRV->cs); } *************** *** 69,93 **** void Mutex::Init() { ! recursive_counter = 0; ! pthread_mutex_init(&_cs, NULL); ! owner_ = 0; } void Mutex::Lock() { ! if(recursive_counter==0 || owner_ != pthread_self()) { ! pthread_mutex_lock(&_cs); ! owner_ = pthread_self(); } ! recursive_counter++; } void Mutex::Unlock() { ! if (--recursive_counter == 0) ! pthread_mutex_unlock(&_cs); #ifdef _DEBUG // This is bug in users code.. ! if (recursive_counter<0) { DBG(_R("Mutex recursive count < 0!! FATAL! Fix your code!\n")); exit(-1); --- 85,111 ---- void Mutex::Init() { ! _prv = malloc(sizeof(_private_data)); ! memset(_prv, 0, sizeof(_private_data)); ! PRV->recursive_counter = 0; ! pthread_mutex_init(&PRV->cs, NULL); ! PRV->owner = 0; } void Mutex::Lock() { ! if(PRV->recursive_counter==0 || PRV->owner != pthread_self()) { ! pthread_mutex_lock(&PRV->cs); ! PRV->owner = pthread_self(); } ! PRV->recursive_counter++; } void Mutex::Unlock() { ! if (--PRV->recursive_counter == 0) ! pthread_mutex_unlock(&PRV->cs); #ifdef _DEBUG // This is bug in users code.. ! if (PRV->recursive_counter<0) { DBG(_R("Mutex recursive count < 0!! FATAL! Fix your code!\n")); exit(-1); *************** *** 99,103 **** void Mutex::Destroy() { ! pthread_mutex_destroy(&_cs); } --- 117,123 ---- void Mutex::Destroy() { ! pthread_mutex_destroy(&PRV->cs); ! free(_prv); ! _prv = 0; } |
From: Mikko L. <laz...@us...> - 2004-06-13 18:46:12
|
Update of /cvsroot/rtk/rtk/src/core/platform/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23840/src/core/platform/linux Modified Files: File.cpp Log Message: Compiles again Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/File.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** File.cpp 13 Jun 2004 18:30:18 -0000 1.9 --- File.cpp 13 Jun 2004 18:46:03 -0000 1.10 *************** *** 324,329 **** } - }; // Rtk - long File::GetSize() { --- 324,327 ---- *************** *** 340,343 **** stat(afile,&file_size); return (long) file_size.st_size; - } --- 338,343 ---- stat(afile,&file_size); return (long) file_size.st_size; } + + }; // Rtk namespace + |
From: Dejan L. <dlo...@us...> - 2004-06-13 18:30:33
|
Update of /cvsroot/rtk/rtk/src/core/platform/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7991 Modified Files: File.cpp Log Message: fixed bug sys/stat Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/File.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** File.cpp 13 Jun 2004 17:25:50 -0000 1.8 --- File.cpp 13 Jun 2004 18:30:18 -0000 1.9 *************** *** 52,56 **** #include <unistd.h> #include <sys/file.h> ! #include <stat.h> namespace Rtk --- 52,56 ---- #include <unistd.h> #include <sys/file.h> ! #include <sys/stat.h> namespace Rtk |
From: Dejan L. <dlo...@us...> - 2004-06-13 17:25:58
|
Update of /cvsroot/rtk/rtk/src/core/platform/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14688 Modified Files: File.cpp Log Message: Added GetSize() Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/File.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** File.cpp 13 Jun 2004 10:38:33 -0000 1.7 --- File.cpp 13 Jun 2004 17:25:50 -0000 1.8 *************** *** 52,55 **** --- 52,56 ---- #include <unistd.h> #include <sys/file.h> + #include <stat.h> namespace Rtk *************** *** 228,232 **** int File::Close() { ! int ret; // return value if (_flags & EXTERN_HANDLE) ERROR_RETURN(CANNOT_CLOSE_EXTERNAL); --- 229,233 ---- int File::Close() { ! int ret; // return value if (_flags & EXTERN_HANDLE) ERROR_RETURN(CANNOT_CLOSE_EXTERNAL); *************** *** 325,327 **** --- 326,343 ---- }; // Rtk + long File::GetSize() + { + const RCHAR *file = _filename.c_str(); + const char *afile = NULL; + struct stat file_size; + #ifdef UNICODE + W2A(file, afile); + if(afile==NULL) ERROR_RETURN(OPERATION_FAILED); + #else + afile = file; + #endif + stat(afile,&file_size); + return (long) file_size.st_size; + + } |
From: Dejan L. <le...@us...> - 2004-06-13 14:17:53
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3542 Modified Files: CMakeLists.txt Log Message: Small fix in build system... Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/CMakeLists.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** CMakeLists.txt 13 Jun 2004 13:52:05 -0000 1.16 --- CMakeLists.txt 13 Jun 2004 14:17:40 -0000 1.17 *************** *** 33,40 **** #################################################################### - ##------------------------------------------------------------------- - # Let's get info about Threads - INCLUDE(${CMAKE_ROOT}/Modules/FindThreads.cmake) - #T0D0: For now we will leave this commented until we learn how to # add objects from platform/* to $RTK_LIBRTK library. --- 33,36 ---- *************** *** 45,49 **** error.cpp String.cpp Array.cpp rchar.cpp Vector.cpp Variant.cpp ! PriorityQueue.cpp Queue.cpp Buffer.cpp ) --- 41,45 ---- error.cpp String.cpp Array.cpp rchar.cpp Vector.cpp Variant.cpp ! PriorityQueue.cpp Buffer.cpp ) *************** *** 72,75 **** --- 68,72 ---- ADD_LIBRARY(${RTK_LIBRTK} STATIC ${RTK_CORE_SFILES}) MESSAGE("Files: ${RTK_CORE_SFILES}\n") + ## FLAGS # How each, separate file in CORE RTK library should be compiled. *************** *** 78,97 **** # CXX flags instead. #################################################################### - IF (RTK_OPT_DEBUG) - SET_SOURCE_FILES_PROPERTIES(${RTK_CORE_SFILES} - PROPERTIES COMPILE_FLAGS "-D_DEBUG -DDEBUG ${CMAKE_THREAD_LIBS_INIT}" - ) - ENDIF (RTK_OPT_DEBUG) ! # Threads ! SET_SOURCE_FILES_PROPERTIES(${RTK_CORE_SFILES} ! PROPERTIES COMPILE_FLAGS "${CMAKE_THREAD_LIBS_INIT}" ! ) IF (RTK_OPT_UNICODE) ! SET_SOURCE_FILES_PROPERTIES(${RTK_CORE_SFILES} ! PROPERTIES COMPILE_FLAGS "-DUNICODE=1" ! ) ENDIF (RTK_OPT_UNICODE) ############################################################ FLAGS ## ######### --- 75,92 ---- # CXX flags instead. #################################################################### ! IF (RTK_OPT_DEBUG) ! SET(RTK_CORE_FLAGS "-D_DEBUG -DDEBUG ${CMAKE_THREAD_LIBS_INIT}") ! ENDIF (RTK_OPT_DEBUG) IF (RTK_OPT_UNICODE) ! SET(RTK_CORE_FLAGS "-DUNICODE=1 ${RTK_CORE_FLAGS}") ENDIF (RTK_OPT_UNICODE) + + # Finally, set flags + SET_SOURCE_FILES_PROPERTIES(${RTK_CORE_SFILES} + PROPERTIES COMPILE_FLAGS ${RTK_CORE_FLAGS} + ) + ############################################################ FLAGS ## ######### |
From: Dejan L. <dlo...@us...> - 2004-06-13 13:52:14
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13321 Modified Files: CMakeLists.txt Log Message: added Queue.cpp Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/CMakeLists.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CMakeLists.txt 12 Jun 2004 16:32:20 -0000 1.15 --- CMakeLists.txt 13 Jun 2004 13:52:05 -0000 1.16 *************** *** 45,49 **** error.cpp String.cpp Array.cpp rchar.cpp Vector.cpp Variant.cpp ! PriorityQueue.cpp Buffer.cpp ) --- 45,49 ---- error.cpp String.cpp Array.cpp rchar.cpp Vector.cpp Variant.cpp ! PriorityQueue.cpp Queue.cpp Buffer.cpp ) |
From: Dejan L. <dlo...@us...> - 2004-06-13 13:50:20
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11426 Added Files: Queue.cpp Log Message: RTK Queue --- NEW FILE: Queue.cpp --- /** * * RTK * Fast and easy cross-platform GUI ToolKit. * * Copyright (C) 2001-200x RTK Development Team * * This library is free software; you can redistribute it and/or modify it * under the terms of the slightly modified (see the "EXCEPTION NOTICE" part * of RTK Library License) GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * and along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . * * Also you should have received a copy of RTK Library License, if not please * write an e-mail to some of RTK authors (listed in file AUTHORS). * * Bug reports: bu...@rt... * Suggestions: rf...@rt... ***************************************************************************/ /** * Queue.cpp * $description * Authors (chronological order): * Dejan Lozanovic, null§rtk.cx * Contributors (chronological order): * $fname $lname, $email ***************************************************************************/ // includes for this file... // We don't want precompiled headers in Borland C++ Builder... #if defined (_BORLANDC__) # pragma hdrstop #endif #include <rtk/Queue.h> #include <stdlib.h> // package also #if defined(__BORLANDC__) # pragma package(smart_init) #endif namespace Rtk { #define CALL_FREE_DATA(d) if(_free_func) (*_free_func)((d)) bool Queue::Enqueue(void *data) { if(_mutex) _mutex->Lock(); // Allocate space for new element QueueNode* new_element = (QueueNode*)malloc(sizeof(QueueNode)); if (new_element == (QueueNode*)0) // NULL return false; new_element->data = data; new_element->next=(QueueNode*)0; if (_head == (QueueNode*)0) // Queue is empty { _head=_tail=new_element; } else { _tail->next=new_element; } _count++; if(_mutex) _mutex->Unlock(); return true; } // Enqueue(void *data) //--------------------------------------------------------------------------- Queue::~Queue() { Clear(); } // ~List() //--------------------------------------------------------------------------- void Queue::Clear() { // Remove each element. QueueNode* element_node; if(_mutex) _mutex->Lock(); element_node = _head; while (element_node) { QueueNode* element_next = element_node->next; CALL_FREE_DATA(element_node->data); free(element_node); element_node = element_next; } _head = _tail= 0; _count = 0; if(_mutex) _mutex->Unlock(); } //--------------------------------------------------------------------------- void *Queue::Dequeue() { void *data = NULL; QueueNode *element_node; if (_count == 0) return data; // We cannot remove element from an EMPTY list object! if(_mutex) _mutex->Lock(); element_node=_head->next; data=_head->data; CALL_FREE_DATA(_head->data); free(_head); _head=element_node; // Adjust the _count of the Queue _count--; if(_mutex) _mutex->Unlock(); // Everything is OK, return data return data; } }; //namespace RTK |
From: Dejan L. <dlo...@us...> - 2004-06-13 13:20:59
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16594 Added Files: Queue.h Log Message: Ordinary Queue class --- NEW FILE: Queue.h --- #ifndef _RTK_QUEUE_H_ #define _RTK_QUEUE_H_ 1 /** * * RTK * Fast and easy cross-platform GUI ToolKit. * * Copyright (C) 2001-200x RTK Development Team * * This library is free software; you can redistribute it and/or modify it * under the terms of the slightly modified (see the "EXCEPTION NOTICE" part * of RTK Library License) GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * and along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . * * Also you should have received a copy of RTK Library License, if not please * write an e-mail to some of RTK authors (listed in file AUTHORS). * * Bug reports: bu...@rt... * Suggestions: rf...@rt... ***************************************************************************/ /** * $filename.$ext * $description * Authors (chronological order): * Dejan Lozanovic, null§rtk.cx * Contributors (chronological order): * $fname $lname, $email ***************************************************************************/ //--------------------------------------------------------------------------- #include "Export.h" #include "Mutex.h" #include "SList.h" // for SLNode struct //--------------------------------------------------------------------------- namespace Rtk { // Single-List Element type #define QueueNode SLNode /// S free data handler /// Called whenever element is removed from list. /// Parameter 'data' is pointer to data of removed element. typedef void (*FreeDataFunc)(void *data); /** * Queue or FIFO(first in, first out) class */ class RTK_API Queue { public: // --------- CONSTRUCTORS ---------------------------------- /** * Default constructor. * @param sort is order ascendencig or descendencing */ Queue(): _count(0), _head(0), _tail(0), _free_func(0), _mutex(0) { } // --------- DESTRUCTORS ----------------------------------- /** * Default destructor. */ ~Queue(); // --------- GET METHODS ----------------------------------- /** * Returns number of items in the list. */ int GetCount() const { return this->_count; } /** * Returns pointer to _head node in Queue. * @return QueueNode pointer to first node in Queue. */ QueueNode* GetFirst() const { return this->_head; } /** * Get free data function. */ FreeDataFunc GetFreeDataFunc() { return _free_func; } /** * Get Mutex from Queue */ Mutex* GetMutex() { return _mutex; } // --------- SET METHODS ----------------------------------- /** * Set function to free content of element. * Function is called whenever element is removed from list. */ void SetFreeDataFunc(FreeDataFunc func) { _free_func = func; } /** * Set mutex for Queue, if mutex is NULL then mutex is disabled */ void SetMutex(Mutex* mutex) { _mutex = mutex; } // --------- OTHER METHODS --------------------------------- /** * Clears the Queue. This wi ll call 'Free Data Handler' */ void Clear(); /** * Insert new element to Queue, element would be * placed to the last position * @param data Data to insert */ bool Enqueue(void *data); /** * Remove first element from Queue * This will call 'Free Data Handler' * @return Data assigned to removed element, or NULL on error */ void *Dequeue(); /** * Get number of items containing given data. * @param data Search for this data * @return Number of elements found, that contains given data. */ int Contains(void *data) const; /** * Returns TRUE if given node is _head node in Queue. * @param element QueueNode* Node that should be checked. * @return TRUE if given node is _head node in Queue, FALSE otherwize. */ bool IsFirst(const QueueNode* element) const { return ((element == this->_head) ? true : false); } /** * Returns TRUE if given node is _tail node in Queue. * @param element QueueNode* Node that should be checked. * @return TRUE if given node oElement is _tail node in Queue, FALSE otherwize. */ bool IsLast(const QueueNode* element) const { return ((element->next == 0) ? true : false); } protected: // Members int _count; /// Size of the list object (how many elements are stored inside) bool _sort; /// How priority queue is sorted QueueNode* _head; /// Pointer to _head element of the List. QueueNode* _tail; /// Pointer to _tail element of the List. FreeDataFunc _free_func; /// Free data function Mutex* _mutex; /// Thread safe }; // Queue }; // Rtk namespace #endif |
From: Dejan L. <le...@us...> - 2004-06-13 13:06:50
|
Update of /cvsroot/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4486 Modified Files: CMakeLists.txt Log Message: Added check for proper Threads (built-in in CMake) . Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/rtk/rtk/CMakeLists.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CMakeLists.txt 10 Mar 2004 12:42:46 -0000 1.13 --- CMakeLists.txt 13 Jun 2004 13:06:40 -0000 1.14 *************** *** 79,82 **** --- 79,85 ---- ENDIF (RTK_BC_HAVE_WCSCMP) + # Check for proper Threads + INCLUDE(${CMAKE_ROOT}/Modules/FindThreads.cmake) + ## # Various dependencies |
From: Dejan L. <de...@us...> - 2004-06-13 12:16:59
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21215/rtk Modified Files: Buffer.h Log Message: Index: Buffer.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Buffer.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Buffer.h 13 Jun 2004 10:28:57 -0000 1.10 --- Buffer.h 13 Jun 2004 12:16:48 -0000 1.11 *************** *** 32,36 **** ***** * Authors (chronological order): ! * Dejan Lekic, de...@nu... (dejanrtk.cx) * Contributors (chronological order): * $fname $lname, $email --- 32,37 ---- ***** * Authors (chronological order): ! * Dejan Lekic, de...@nu... (de...@rt...) ! * Mikko Lahteenmaki, mi...@rt... * Contributors (chronological order): * $fname $lname, $email |
From: Dejan L. <de...@us...> - 2004-06-13 12:16:59
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21215/src/core Modified Files: Buffer.cpp Log Message: Index: Buffer.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Buffer.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Buffer.cpp 13 Jun 2004 10:27:58 -0000 1.10 --- Buffer.cpp 13 Jun 2004 12:16:48 -0000 1.11 *************** *** 33,36 **** --- 33,37 ---- * Authors (chronological order): * Dejan Lekic, de...@nu... (de...@rt...) + * Mikko Lahteenmaki, mi...@rt... * Contributors (chronological order): * $fname $lname, $email |
From: Mikko L. <laz...@us...> - 2004-06-13 10:38:44
|
Update of /cvsroot/rtk/rtk/src/core/platform/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23534/core/platform/linux Modified Files: File.cpp Log Message: Some File changes for Linux (w/o testing) Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/File.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** File.cpp 13 Jun 2004 07:41:16 -0000 1.6 --- File.cpp 13 Jun 2004 10:38:33 -0000 1.7 *************** *** 154,158 **** } ! void File::SetMode(int mode) { ClearFlag(CAN_READ | CAN_WRITE, _flags); --- 154,158 ---- } ! void File::SetMode(uint mode) { ClearFlag(CAN_READ | CAN_WRITE, _flags); *************** *** 180,185 **** #endif ! bool File::Open() { const RCHAR *file = _filename.c_str(); const char *afile = NULL; --- 180,188 ---- #endif ! int File::Open() { + if(IsOpen()) + ERROR_RETURN(ALREADY_OPEN); + const RCHAR *file = _filename.c_str(); const char *afile = NULL; *************** *** 187,198 **** #ifdef UNICODE W2A(file, afile); ! if(afile==NULL) return false; #else afile = file; #endif - if (_handle!=INVALID_HANDLE_VALUE) - return false; - int open_flags = 0; if(_mode & READ) --- 190,198 ---- #ifdef UNICODE W2A(file, afile); ! if(afile==NULL) ERROR_RETURN(OPERATION_FAILED); #else afile = file; #endif int open_flags = 0; if(_mode & READ) *************** *** 211,214 **** --- 211,217 ---- _handle = (void*) open(afile, open_flags, 0666); + if(FD == -1) + ERROR_RETURN(OPERATION_FAILED); + if(_mode & LOCKED) { *************** *** 220,232 **** } ! return IsOpen(); } ! bool File::Close() { int ret; // return value ! // Do not close external handle! ! if (_flags & EXTERN_HANDLE) return false; ! if (_handle==INVALID_HANDLE_VALUE) return false; //unlock the file --- 223,235 ---- } ! RETURN_SUCCESS; } ! int File::Close() { int ret; // return value ! ! if (_flags & EXTERN_HANDLE) ERROR_RETURN(CANNOT_CLOSE_EXTERNAL); ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); //unlock the file *************** *** 243,247 **** #ifdef UNICODE W2A(file, afile); ! if(afile==NULL) return false; #else afile = file; --- 246,250 ---- #ifdef UNICODE W2A(file, afile); ! if(afile==NULL) ERROR_RETURN(OPERATION_FAILED); #else afile = file; *************** *** 257,269 **** } ! bool File::IsOpen() const ! { ! return (_handle!=INVALID_HANDLE_VALUE); ! } ! ! int File::Read(void *buffer, int buffer_len) { ! if(!CanRead()) return false; ! if(_handle==INVALID_HANDLE_VALUE) return -1; int read_bytes = 0; --- 260,268 ---- } ! long File::Read(void *buffer, long buffer_len) { ! if(!CanRead()) ERROR_RETURN(DEVICE_READ_PROTECTED); ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! int read_bytes = 0; *************** *** 279,286 **** } ! int File::Write(void *buffer, int buffer_len) { ! if(!CanWrite()) return false; ! if(_handle==INVALID_HANDLE_VALUE) return -1; int written_bytes = 0; --- 278,286 ---- } ! long File::Write(void *buffer, long buffer_len) { ! if(!CanWrite()) ERROR_RETURN(DEVICE_WRITE_PROTECTED); ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! int written_bytes = 0; *************** *** 297,302 **** long File::Seek(long pos, IO::SeekMethod method) { ! if(_handle==INVALID_HANDLE_VALUE) return -1; ! if(!CanSeek()) return -1; int seek_method = SEEK_SET; --- 297,302 ---- long File::Seek(long pos, IO::SeekMethod method) { ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! if(!CanSeek()) ERROR_RETURN(OPERATION_FAILED); int seek_method = SEEK_SET; *************** *** 311,315 **** long File::Tell() { ! if(_handle==INVALID_HANDLE_VALUE) return -1; if(!CanSeek()) return -1; --- 311,315 ---- long File::Tell() { ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); if(!CanSeek()) return -1; *************** *** 317,323 **** } ! bool File::Flush() { ! if(_handle==INVALID_HANDLE_VALUE) return false; return (fsync(FD)==0); } --- 317,323 ---- } ! int File::Flush() { ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); return (fsync(FD)==0); } |
From: Mikko L. <laz...@us...> - 2004-06-13 10:38:44
|
Update of /cvsroot/rtk/rtk/src/core/platform/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23534/core/platform/win32 Modified Files: File.cpp Log Message: Some File changes for Linux (w/o testing) Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/win32/File.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** File.cpp 13 Jun 2004 10:27:58 -0000 1.3 --- File.cpp 13 Jun 2004 10:38:34 -0000 1.4 *************** *** 244,247 **** --- 244,248 ---- { if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); + if(!CanSeek()) ERROR_RETURN(OPERATION_FAILED); DWORD W32method = FILE_BEGIN; *************** *** 268,272 **** { if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! Lock(); --- 269,274 ---- { if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! if(!CanSeek()) ERROR_RETURN(OPERATION_FAILED); ! Lock(); |
From: Mikko L. <laz...@us...> - 2004-06-13 10:29:08
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14903 Modified Files: Buffer.h File.h IO.h debug.h error.h error_codes.h Log Message: - Some IO changes - Use ERROR things in File - Buffer is now IO Index: error_codes.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/error_codes.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** error_codes.h 18 Jan 2004 20:17:07 -0000 1.1 --- error_codes.h 13 Jun 2004 10:28:57 -0000 1.2 *************** *** 3,9 **** #else ! ERROR_CODE0(UNKNOWN) ! ERROR_CODE1(OUT_OF_MEMORY, RunTime) ! ERROR_CODE1(FILE_NOT_FOUND, IO) #endif --- 3,17 ---- #else ! ERROR_CODE(UNKNOWN, RunTime) ! ERROR_CODE(OPERATION_FAILED, RunTime) ! ERROR_CODE(NOT_IMPLEMENTED, RunTime) ! ERROR_CODE(OUT_OF_MEMORY, RunTime) ! ERROR_CODE(FILE_NOT_FOUND, IO) ! ERROR_CODE(ALREADY_OPEN, IO) ! ERROR_CODE(DEVICE_NOT_OPEN, IO) ! ERROR_CODE(DEVICE_WRITE_PROTECTED, IO) ! ERROR_CODE(DEVICE_READ_PROTECTED, IO) ! ERROR_CODE(CANNOT_CLOSE_EXTERNAL, IO) ! ERROR_CODE(ACCESS_DENIED, IO) #endif Index: debug.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/debug.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** debug.h 28 Feb 2004 07:39:44 -0000 1.3 --- debug.h 13 Jun 2004 10:28:57 -0000 1.4 *************** *** 15,19 **** // Define macros for each package/module/section ! #define D_CORE 0x00000001 #define D_ALL 0xffffffff --- 15,20 ---- // Define macros for each package/module/section ! #define D_CORE (1<<1) ! #define D_IO (1<<2) #define D_ALL 0xffffffff Index: File.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/File.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** File.h 13 Jun 2004 07:51:25 -0000 1.4 --- File.h 13 Jun 2004 10:28:57 -0000 1.5 *************** *** 121,132 **** * Set new access mode. * If file is already open, it must be re-opened ! * to make this take effect. */ ! void SetMode(int mode); /** * Return current IO access. */ ! int GetMode() const { return _mode; } /** --- 121,132 ---- * Set new access mode. * If file is already open, it must be re-opened ! * to make new mode take effect. */ ! void SetMode(uint mode); /** * Return current IO access. */ ! uint GetMode() const { return _mode; } /** *************** *** 134,147 **** * Returns true on success. */ ! virtual bool Open(); /** * Try to close file. ! * Returns true on success. */ ! virtual bool Close(); ! ! /** Return true if file is open. */ ! virtual bool IsOpen() const; /** --- 134,144 ---- * Returns true on success. */ ! virtual int Open(); /** * Try to close file. ! * Returns SUCCESS on success. */ ! virtual int Close(); /** *************** *** 151,155 **** * @param buffer_len Size of input buffer */ ! virtual int Read(void *buffer, int buffer_len); /** --- 148,152 ---- * @param buffer_len Size of input buffer */ ! virtual long Read(void *buffer, long buffer_len); /** *************** *** 159,163 **** * @param buffer_len Size of input buffer */ ! virtual int Write(void *buffer, int buffer_len); /** --- 156,160 ---- * @param buffer_len Size of input buffer */ ! virtual long Write(void *buffer, long buffer_len); /** *************** *** 173,176 **** --- 170,176 ---- virtual long Tell(); + /** Return size of the IO device. Return RTK error code if failed. */ + virtual long GetSize(); + /** * Return true, passed to end-of-file. *************** *** 182,186 **** * Returns 0 on succes, -1 on error */ ! virtual bool Flush(); /** --- 182,186 ---- * Returns 0 on succes, -1 on error */ ! virtual int Flush(); /** *************** *** 193,197 **** private: String _filename; ! int _mode; void *_handle; bool _eos; --- 193,197 ---- private: String _filename; ! uint _mode; void *_handle; bool _eos; Index: error.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/error.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** error.h 18 Jan 2004 20:17:07 -0000 1.1 --- error.h 13 Jun 2004 10:28:57 -0000 1.2 *************** *** 32,52 **** //////////////////////////////////////////////////////////////////////////////// ! #define ERROR_CODE0(name) EC_ ## name, ! #define ERROR_CODE1(name,type) EC_ ## name, enum { ! EC_NO_ERROR = 0, ! #include "error_codes.h" EC_LAST_ERROR }; ! #undef ERROR_CODE0 ! #undef ERROR_CODE1 // if not using exceptions, errors are returned as negative integers #define ERROR_RET long // a macro for returning a success value #define RETURN_SUCCESS return (0) // a macro for returning an error #define ERROR_RETURN(name) return -EC_ ## name #undef INC_ERROR_CODES --- 32,54 ---- //////////////////////////////////////////////////////////////////////////////// ! #define ERROR_CODE(name,type) EC_ ## name, enum { ! EC_SUCCESS = 0, ! # include "error_codes.h" EC_LAST_ERROR }; ! #undef ERROR_CODE // if not using exceptions, errors are returned as negative integers #define ERROR_RET long + // a macro for returning a success value #define RETURN_SUCCESS return (0) + // a macro for returning an error #define ERROR_RETURN(name) return -EC_ ## name + #define SUCCESS(val) ((val) > -1) + #undef INC_ERROR_CODES Index: IO.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/IO.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IO.h 13 Jun 2004 07:51:25 -0000 1.9 --- IO.h 13 Jun 2004 10:28:57 -0000 1.10 *************** *** 45,48 **** --- 45,49 ---- #include "rtkdef.h" + #include "error.h" #include "Mutex.h" *************** *** 62,68 **** */ enum AccessFlags { ! CAN_READ = 1, ///< IO has read access. ! CAN_WRITE = 2, ///< IO has write access. ! CAN_SEEK = 4 ///< IO is seekable. }; --- 63,71 ---- */ enum AccessFlags { ! CAN_READ = (1<<1), ///< IO has read access. ! CAN_WRITE = (1<<2), ///< IO has write access. ! CAN_SEEK = (1<<3), ///< IO is seekable. ! ! OPENED = (1<<4) ///< IO device is opened (internal) }; *************** *** 89,120 **** /** Return true if device has read permission */ ! bool CanRead() const { return TestFlag(CAN_READ, _flags); } /** Return true if device has write permission */ ! bool CanWrite() const { return TestFlag(CAN_WRITE, _flags); } /** Return true if device can seek in stream */ ! bool CanSeek() const { return TestFlag(CAN_SEEK, _flags); } /** Return true if IO stream is open. */ ! virtual bool IsOpen() const { return false; } ! /** READ, Return -1 on error */ ! virtual int Read(void *buffer, int buffer_len) { return -1; } ! /** WRITE, Return -1 on error */ ! virtual int Write(void *buffer, int buffer_len) { return -1; } ! /** SEEK, Return -1 on error */ ! virtual long Seek(long pos, int method=BEGIN) { return -1; } ! /** Current position in stream. Return -1 on error */ ! virtual long Tell() { return -1; } ! /** Is end-of-stream. Return -1 on error */ ! virtual bool IsEos() { return true; } /** Flushes the buffer. Return -1 on error */ ! virtual bool Flush() { return 0; } /** Sets Mutex object for IO */ --- 92,138 ---- /** Return true if device has read permission */ ! bool CanRead() const { return TestFlag(CAN_READ, _flags); } /** Return true if device has write permission */ ! bool CanWrite() const { return TestFlag(CAN_WRITE, _flags); } /** Return true if device can seek in stream */ ! bool CanSeek() const { return TestFlag(CAN_SEEK, _flags); } /** Return true if IO stream is open. */ ! bool IsOpen() const { return (_flags & OPENED) == OPENED; } ! /** ! * Try to open IO device. Return ALREADY_OPEN, if device is already open. ! * Returns SUCCESS on success. ! */ ! virtual int Open() = 0; ! /** ! * Try to close IO device. ! * Returns SUCCESS on success. ! */ ! virtual int Close() = 0; ! /** READ, Return RTK error code if failed. */ ! virtual long Read(void *buffer, long buffer_len) { ERROR_RETURN(NOT_IMPLEMENTED); } ! /** WRITE, Return RTK error code if failed. */ ! virtual long Write(void *buffer, long buffer_len) { ERROR_RETURN(NOT_IMPLEMENTED); } ! /** SEEK, Return RTK error code if failed. */ ! virtual long Seek(long pos, int method=BEGIN) { ERROR_RETURN(NOT_IMPLEMENTED); } ! ! /** Current position in stream. Return RTK error code if failed. */ ! virtual long Tell() { ERROR_RETURN(NOT_IMPLEMENTED); } ! ! /** Return size of the IO device. Return RTK error code if failed. */ ! virtual long GetSize() { ERROR_RETURN(NOT_IMPLEMENTED); } ! ! /** Is end-of-stream. */ ! virtual bool IsEos() = 0; /** Flushes the buffer. Return -1 on error */ ! virtual int Flush() { ERROR_RETURN(NOT_IMPLEMENTED); } /** Sets Mutex object for IO */ *************** *** 122,130 **** /** Gets Mutex object from IO */ ! Mutex* GetMutex() const { return _mutex; } protected: IO() : _flags(0), _mutex(0) { } /** Set access flags. */ void flags(uint f) { _flags = f; } --- 140,151 ---- /** Gets Mutex object from IO */ ! Mutex* GetMutex() { return _mutex; } protected: IO() : _flags(0), _mutex(0) { } + void SetOpen() { _flags |= OPENED; } + void ClearOpen() { _flags &= ~OPENED; } + /** Set access flags. */ void flags(uint f) { _flags = f; } *************** *** 137,141 **** uint _flags; ! private: Mutex* _mutex; /// Mutex - by default not set --- 158,162 ---- uint _flags; ! private: Mutex* _mutex; /// Mutex - by default not set Index: Buffer.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/Buffer.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Buffer.h 12 Jun 2004 22:48:29 -0000 1.9 --- Buffer.h 13 Jun 2004 10:28:57 -0000 1.10 *************** *** 52,124 **** #include "rtkdef.h" ! namespace Rtk { ! /** Dynamic Buffer implementation. ! * @author de...@rt... */ ! class RTK_API Buffer ! { ! uchar* _data; /// Internal pointer to Buffer memory-block. ! ulong _allocated; /// Size of Buffer object in bytes. ! ulong _size; /// Number of data-bytes in Buffer object. ! ! /** ! * Allocates arg_num bytes and returns pointer to new memory block. ! * @returns uchar* pointer to new memory block. ! */ ! uchar* Allocate(ulong arg_num); ! ! public: ! /** ! * Default Buffer constructor. ! */ ! Buffer(): _size(0), _data(0), _allocated(0) { } ! ! virtual ~Buffer(); ! ! /** ! * Clear the buffer and free all it's resources. ! */ ! void Clear(); ! /** ! * Returns pointer to internal data memory-block. ! * @returns pointer to the data buffer. ! * @note return value value may be NULL, if buffer is not allocated yet ! */ ! const uchar* Data() const { return _data; } ! ! /** Returns current number of written data bytes in Buffer. ! * @returns ulong current size of Buffer. ! */ ! ulong GetSize() const { return _size; } ! ! /** Returns number of bytes allocated by Buffer currently ! * @returns ulong current internal size of Buffer. ! */ ! ulong GetAllocated() const { return _allocated; } ! ! /** ! * Resizes Buffer. ! * @returns int 0 if everything OK. ! */ ! int SetSize(ulong arg_size); ! ! /** Writes one single byte to the Buffer object ! * @param c uchar Byte to be written. ! */ ! void Write(uchar c) { *Allocate(1) = c; ++_size; } ! ! /** ! * Writes arbitrary number of bytes to the Buffer object. ! */ ! void Write(const uchar* arg_byte_array, ulong arg_num); ! void Fill(uchar arg_char); - // This should be removed after testing... - void From(IO* arg_io); - void To(IO* arg_io); - }; // Buffer }; // Rtk namespace --- 52,139 ---- #include "rtkdef.h" ! namespace Rtk { ! ! /** Dynamic Buffer implementation. ! * @author de...@rt... ! */ ! class RTK_API Buffer : public IO { ! public: ! /** ! * Default Buffer constructor. */ ! Buffer(): _size(0), _data(0), _allocated(0), _pos(0) { } ! virtual ~Buffer(); ! ! virtual int Open() { SetOpen(); RETURN_SUCCESS; } ! virtual int Close() { ClearOpen(); RETURN_SUCCESS; } ! ! /** READ, Return RTK error code if failed. */ ! virtual long Read(void *buffer, long buffer_len); ! ! /** WRITE, Return RTK error code if failed. */ ! virtual long Write(void *buffer, long buffer_len); ! ! /** SEEK, Return RTK error code if failed. */ ! virtual long Seek(long pos, int method=BEGIN); ! ! /** Current position in stream. Return RTK error code if failed. */ ! virtual long Tell(); ! ! /** Return size of the IO device. Return RTK error code if failed. */ ! virtual long GetSize() { return _size; } ! ! /** Is end-of-stream. */ ! virtual bool IsEos() { return (_pos == _size); } ! ! /** ! * Clear the buffer and free all it's resources. ! */ ! void Clear(); ! ! /** ! * Returns pointer to internal data memory-block. ! * @returns pointer to the data buffer. ! * @note return value value may be NULL, if buffer is not allocated yet ! */ ! const uchar* Data() const { return _data; } ! ! /** Returns number of bytes allocated by Buffer currently ! * @returns ulong current internal size of Buffer. ! */ ! ulong GetAllocated() const { return _allocated; } ! ! /** ! * Resizes Buffer. ! * @returns int 0 if everything OK. ! */ ! int SetSize(ulong arg_size); ! ! /** Writes one single byte to the Buffer object ! * @param c uchar Byte to be written. ! */ ! void Write(uchar c) { *Allocate(1) = c; ++_size; } ! ! void Fill(uchar arg_char); ! ! // This should be removed after testing... ! void From(IO* arg_io); ! void To(IO* arg_io); ! ! private: ! uchar* _data; /// Internal pointer to Buffer memory-block. ! ulong _allocated; /// Size of Buffer object in bytes. ! ulong _size; /// Number of data-bytes in Buffer object. ! ulong _pos; ! /** ! * Allocates arg_num bytes and returns pointer to new memory block. ! * @returns uchar* pointer to new memory block. ! */ ! uchar* Allocate(ulong arg_num); ! ! }; // Buffer }; // Rtk namespace |
From: Mikko L. <laz...@us...> - 2004-06-13 10:28:33
|
Update of /cvsroot/rtk/rtk/src/core/platform/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14291/platform/win32 Modified Files: File.cpp Log Message: - Some IO changes - Use ERROR things in File - Buffer is now IO Index: File.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/platform/win32/File.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** File.cpp 21 Feb 2004 19:18:11 -0000 1.2 --- File.cpp 13 Jun 2004 10:27:58 -0000 1.3 *************** *** 52,58 **** { - // Dejan@T0D0: We don't maybe need this, because this file is for Win32 only anyway! :) #include <windows.h> #include <io.h> #ifndef INVALID_SET_FILE_POINTER # define INVALID_SET_FILE_POINTER 0xFFFFFFFF --- 52,58 ---- { #include <windows.h> #include <io.h> + #ifndef INVALID_SET_FILE_POINTER # define INVALID_SET_FILE_POINTER 0xFFFFFFFF *************** *** 97,101 **** } ! void File::SetMode(int mode) { ClearFlag(CAN_READ | CAN_WRITE, _flags); --- 97,101 ---- } ! void File::SetMode(uint mode) { ClearFlag(CAN_READ | CAN_WRITE, _flags); *************** *** 110,119 **** } ! bool File::Open() { ! const RCHAR *file = _filename.c_str(); ! if (_handle!=INVALID_HANDLE_VALUE) ! return false; DWORD access_rights = 0; DWORD disposition = OPEN_EXISTING; --- 110,119 ---- } ! int File::Open() { ! if(IsOpen()) ! ERROR_RETURN(ALREADY_OPEN); + const RCHAR *file = _filename.c_str(); DWORD access_rights = 0; DWORD disposition = OPEN_EXISTING; *************** *** 160,222 **** NULL); // If in append mode, seek to end ! if(_mode & APPEND) ! Seek(0, END); ! return IsOpen(); } ! bool File::Close() { // Do not close external handle! ! if (_flags & EXTERN_HANDLE) return false; ! if (_handle==INVALID_HANDLE_VALUE) return false; BOOL ret = CloseHandle((HANDLE)_handle); _handle = INVALID_HANDLE_VALUE; ! return (ret==TRUE); ! } ! bool File::IsOpen() const ! { ! return (_handle!=INVALID_HANDLE_VALUE); } ! int File::Read(void *buffer, int buffer_len) { ! if(!CanRead()) return false; ! if(_handle==INVALID_HANDLE_VALUE) return -1; DWORD read_bytes = 0; ! if(ReadFile(_handle, buffer, buffer_len, &read_bytes, NULL)) ! { _eos = (read_bytes == 0); return read_bytes; ! } _eos = true;//(GetLastError()==ERROR_HANDLE_EOF); ! return -1; } ! int File::Write(void *buffer, int buffer_len) { ! if(!CanWrite()) return false; ! if(_handle==INVALID_HANDLE_VALUE) return -1; DWORD written_bytes = 0; ! _eos = false; ! if(WriteFile(_handle, buffer, buffer_len, &written_bytes, NULL)) ! { return written_bytes; } ! return -1; } long File::Seek(long pos, IO::SeekMethod method) { ! if(_handle==INVALID_HANDLE_VALUE) return -1; DWORD W32method = FILE_BEGIN; --- 160,247 ---- NULL); + if(GetLastError() == ERROR_ACCESS_DENIED) + { + ERROR_RETURN(ACCESS_DENIED); + } + else if(GetLastError() == ERROR_FILE_NOT_FOUND) + { + ERROR_RETURN(FILE_NOT_FOUND); + } + // If in append mode, seek to end ! if(_mode & APPEND) { ! long ret = Seek(0, END); ! if(!SUCCESS(ret)) ! return ret; ! } ! SetOpen(); ! ! RETURN_SUCCESS; } ! int File::Close() { // Do not close external handle! ! if (_flags & EXTERN_HANDLE) ERROR_RETURN(CANNOT_CLOSE_EXTERNAL); ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! ! Lock(); BOOL ret = CloseHandle((HANDLE)_handle); _handle = INVALID_HANDLE_VALUE; ! ClearOpen(); ! Unlock(); ! ! if(ret==TRUE) ! RETURN_SUCCESS; ! ! ERROR_RETURN(OPERATION_FAILED); } ! long File::Read(void *buffer, long buffer_len) { ! if(!CanRead()) ERROR_RETURN(DEVICE_READ_PROTECTED); ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); DWORD read_bytes = 0; ! Lock(); ! ! if(ReadFile(_handle, buffer, buffer_len, &read_bytes, NULL)) { _eos = (read_bytes == 0); + Unlock(); return read_bytes; ! } _eos = true;//(GetLastError()==ERROR_HANDLE_EOF); ! Unlock(); ! ! ERROR_RETURN(OPERATION_FAILED); } ! long File::Write(void *buffer, long buffer_len) { ! if(!CanWrite()) ERROR_RETURN(DEVICE_WRITE_PROTECTED); ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! DWORD written_bytes = 0; ! Lock(); ! _eos = false; ! if(WriteFile(_handle, buffer, buffer_len, &written_bytes, NULL)) { ! Unlock(); return written_bytes; } ! Unlock(); ! ERROR_RETURN(OPERATION_FAILED); } long File::Seek(long pos, IO::SeekMethod method) { ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); DWORD W32method = FILE_BEGIN; *************** *** 227,235 **** }; DWORD ret = SetFilePointer(_handle, pos, NULL, W32method); if(ret == INVALID_SET_FILE_POINTER) { _eos = (GetLastError()==ERROR_HANDLE_EOF); ! return -1; } return (long)ret; } --- 252,265 ---- }; + Lock(); + DWORD ret = SetFilePointer(_handle, pos, NULL, W32method); if(ret == INVALID_SET_FILE_POINTER) { _eos = (GetLastError()==ERROR_HANDLE_EOF); ! Unlock(); ! ERROR_RETURN(OPERATION_FAILED); } + + Unlock(); return (long)ret; } *************** *** 237,256 **** long File::Tell() { ! if(_handle==INVALID_HANDLE_VALUE) return -1; DWORD ret = SetFilePointer(_handle, 0, NULL, FILE_CURRENT); if(ret == INVALID_SET_FILE_POINTER) { _eos = (GetLastError()==ERROR_HANDLE_EOF); ! return -1; } return (long)ret; } ! bool File::Flush() { ! if(_handle==INVALID_HANDLE_VALUE) return false; ! bool ret = (FlushFileBuffers(_handle)==TRUE); ! return ret; } --- 267,303 ---- long File::Tell() { ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! ! Lock(); DWORD ret = SetFilePointer(_handle, 0, NULL, FILE_CURRENT); if(ret == INVALID_SET_FILE_POINTER) { _eos = (GetLastError()==ERROR_HANDLE_EOF); ! ERROR_RETURN(OPERATION_FAILED); } + + Unlock(); return (long)ret; } ! int File::Flush() { ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! Lock(); ! bool success = (FlushFileBuffers(_handle)!=0); ! Unlock(); ! ! if(success) { ! RETURN_SUCCESS; ! } ! ! ERROR_RETURN(OPERATION_FAILED); ! } ! ! long File::GetSize() ! { ! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN); ! return GetFileSize(_handle, NULL); } |
From: Mikko L. <laz...@us...> - 2004-06-13 10:28:33
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14291 Modified Files: Buffer.cpp error.cpp Log Message: - Some IO changes - Use ERROR things in File - Buffer is now IO Index: error.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/error.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** error.cpp 28 Feb 2004 07:39:44 -0000 1.3 --- error.cpp 13 Jun 2004 10:27:58 -0000 1.4 *************** *** 4,25 **** static const RCHAR * error_names[] = { ! _R("No Error"), ! #if 1 ! ! # define INC_ERROR_CODES 1 ! ! # define ERROR_CODE0(name) _R(#name), ! # define ERROR_CODE1(name,type) _R(#type) _R(":") _R(#name), ! # include <rtk/error_codes.h> ! # undef ERROR_CODE0 ! # undef ERROR_CODE1 ! # undef INC_ERROR_CODES ! #else ! _R("Out of memory"), ! _R("File not found"), ! #endif }; --- 4,16 ---- static const RCHAR * error_names[] = { ! _R("Operation Success"), ! #define INC_ERROR_CODES 1 ! #define ERROR_CODE(name,type) _R(#type) _R(":") _R(#name), ! #include <rtk/error_codes.h> ! #undef ERROR_CODE ! #undef INC_ERROR_CODES }; Index: Buffer.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Buffer.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Buffer.cpp 13 Jun 2004 07:51:56 -0000 1.9 --- Buffer.cpp 13 Jun 2004 10:27:58 -0000 1.10 *************** *** 50,127 **** namespace Rtk { ! Buffer::~Buffer() { ! Clear(); ! } ! uchar* Buffer::Allocate(ulong arg_num) { ! ulong newsize = _size + arg_num; ! if (newsize > _allocated) ! { ! if(_allocated) _allocated *= 2; ! else _allocated = RTK_BUFFER_SIZE; ! if (_allocated < newsize) ! _allocated = newsize; ! if(!_data) _data = (uchar*)malloc(_allocated); ! else _data = (uchar*)realloc(_data, _allocated); ! } // if ! return (_data + _size); ! } // Allocate() ! ! void Buffer::Write(const uchar* arg_byte_array, ulong arg_num) ! { ! memcpy(Allocate(arg_num), arg_byte_array, arg_num); ! _size += arg_num; ! } // Write() ! void Buffer::Clear() ! { ! if(_data) free(_data); ! _size = 0; ! _allocated = 0; ! _data = 0; } ! int Buffer::SetSize(ulong arg_size) { ! if (arg_size == 0) ! { ! Clear(); ! } else { ! Allocate(arg_size); ! _size = arg_size; ! } ! return 0; ! } ! void Buffer::Fill(uchar arg_char) ! { ! if(_data) { ! memset(_data, arg_char, _size); ! } ! } // Fill() ! void Buffer::From(IO* arg_io) { ! if(!arg_io->CanRead() && arg_io->IsOpen()) ! return; // Some error checks should be here... ! while(!arg_io->IsEos()) ! { ! uchar buf[1024]; ! int bytes = arg_io->Read(buf, sizeof(buf)); this->Write(buf, bytes); ! } ! } // From() ! void Buffer::To(IO* arg_io) ! { ! if (!_size) return; ! if (arg_io->CanWrite() && arg_io->IsOpen()) ! { ! arg_io->Write(_data, _size); ! } ! } // To() }; // Rtk --- 50,184 ---- namespace Rtk { ! Buffer::~Buffer() { ! Clear(); ! } ! uchar* Buffer::Allocate(ulong arg_num) ! { ! ulong newsize = _pos + arg_num; ! if (newsize > _allocated) { ! if(_allocated) _allocated *= 2; ! else _allocated = RTK_BUFFER_SIZE; ! if (_allocated < newsize) ! _allocated = newsize; ! if(!_data) _data = (uchar*)malloc(_allocated); ! else _data = (uchar*)realloc(_data, _allocated); ! } // if ! return (_data + _pos); ! } // Allocate() ! long Buffer::Read(void *buffer, long buffer_len) ! { ! if(IsEos()) return 0; ! ! ulong end = _pos+buffer_len; ! if(end > _size) ! end = _size; ! ulong len = end-_pos; ! memcpy(buffer, _data+_pos, len); ! _pos += len; ! return len; ! } ! ! long Buffer::Write(void *buffer, long buffer_len) ! { ! if(buffer_len <= 0) return buffer_len; ! memcpy(Allocate(buffer_len), buffer, buffer_len); ! _pos += buffer_len; ! if(_pos > _size) { ! _size = _pos; } + return buffer_len; + } + + long Buffer::Seek(long pos, int method) + { + long offset = 0; + switch(method) { + case IO::END: offset = _size; break; + case IO::CURRENT: offset = _pos; break; + default: break; + }; + + long after = offset + pos; + + if(after > (long)_size || after < 0) { + ERROR_RETURN(OPERATION_FAILED); + } + + return (_pos = after); + } + + long Buffer::Tell() + { + return _pos; + } + + + void Buffer::Clear() + { + if(_data) free(_data); + _size = 0; + _allocated = 0; + _data = 0; + _pos = 0; + } ! int Buffer::SetSize(ulong arg_size) ! { ! if (arg_size == 0) { ! Clear(); ! } else { ! _allocated = _size = arg_size; ! ! if(!_data) _data = (uchar*)malloc(_allocated); ! else _data = (uchar*)realloc(_data, _allocated); ! if(_pos > _size) ! _pos = _size; ! } ! RETURN_SUCCESS; ! } ! ! void Buffer::Fill(uchar arg_char) ! { ! if(_data) { ! memset(_data, arg_char, _size); ! } ! } // Fill() ! void Buffer::From(IO* arg_io) ! { ! if(!arg_io->CanRead() && arg_io->IsOpen()) ! return; // Some error checks should be here... ! ! Clear(); ! ! while(!arg_io->IsEos()) { ! uchar buf[1024]; ! int bytes = arg_io->Read(buf, sizeof(buf)); ! if(bytes < 0) { ! DBG(1, D_IO, _R("Buffer::From() IO::Read failed: %s [%d]\n"), error2str(bytes), bytes); ! break; ! } else if(bytes>0) { this->Write(buf, bytes); ! } ! } ! this->Seek(0); ! } // From() ! void Buffer::To(IO* arg_io) ! { ! if (!_size) return; ! if (arg_io->CanWrite() && arg_io->IsOpen()) ! { ! arg_io->Write(_data, _size); ! } ! } // To() }; // Rtk |
From: Mikko L. <laz...@us...> - 2004-06-13 07:52:05
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8391 Modified Files: Buffer.cpp Log Message: changed From func a bit Index: Buffer.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Buffer.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Buffer.cpp 12 Jun 2004 22:48:29 -0000 1.8 --- Buffer.cpp 13 Jun 2004 07:51:56 -0000 1.9 *************** *** 106,117 **** void Buffer::From(IO* arg_io) { ! if(!arg_io->CanRead()) return; // Some error checks should be here... ! arg_io->Seek(0, IO::END); ! long size = arg_io->Tell(); ! arg_io->Seek(0, IO::BEGIN); ! Allocate(size+1); ! _data[size] = '\0'; ! _size = arg_io->Read(_data, size); } // From() --- 106,117 ---- void Buffer::From(IO* arg_io) { ! if(!arg_io->CanRead() && arg_io->IsOpen()) return; // Some error checks should be here... ! while(!arg_io->IsEos()) ! { ! uchar buf[1024]; ! int bytes = arg_io->Read(buf, sizeof(buf)); ! this->Write(buf, bytes); ! } } // From() *************** *** 119,123 **** { if (!_size) return; ! if (arg_io->CanWrite()) { arg_io->Write(_data, _size); --- 119,123 ---- { if (!_size) return; ! if (arg_io->CanWrite() && arg_io->IsOpen()) { arg_io->Write(_data, _size); |
From: Mikko L. <laz...@us...> - 2004-06-13 07:51:37
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7857 Modified Files: File.h IO.h Log Message: Added IsOpen to IO Index: IO.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/IO.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IO.h 11 Jun 2004 21:06:38 -0000 1.8 --- IO.h 13 Jun 2004 07:51:25 -0000 1.9 *************** *** 97,100 **** --- 97,103 ---- bool CanSeek() const { return TestFlag(CAN_SEEK, _flags); } + /** Return true if IO stream is open. */ + virtual bool IsOpen() const { return false; } + /** READ, Return -1 on error */ virtual int Read(void *buffer, int buffer_len) { return -1; } Index: File.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/File.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** File.h 12 Jun 2004 18:52:31 -0000 1.3 --- File.h 13 Jun 2004 07:51:25 -0000 1.4 *************** *** 142,146 **** virtual bool Close(); ! /** Return tru if file is open. */ virtual bool IsOpen() const; --- 142,146 ---- virtual bool Close(); ! /** Return true if file is open. */ virtual bool IsOpen() const; |
From: Mikko L. <laz...@us...> - 2004-06-13 07:50:54
|
Update of /cvsroot/rtk/rtk/test/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7243 Modified Files: buffer0.cpp Log Message: minor Index: buffer0.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/test/core/buffer0.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** buffer0.cpp 12 Jun 2004 22:46:58 -0000 1.3 --- buffer0.cpp 13 Jun 2004 07:50:45 -0000 1.4 *************** *** 40,48 **** ***************************************************************************/ - #include "../test.h" #include <rtk/Buffer.h> #include <rtk/File.h> #include <stdio.h> using namespace Rtk; --- 40,49 ---- ***************************************************************************/ #include <rtk/Buffer.h> #include <rtk/File.h> #include <stdio.h> + #include "../test.h" + using namespace Rtk; *************** *** 50,66 **** { Buffer buf; ! File f("dump.dat", File::WRITE|File::CREATE|File::BINARY); printf("Initial allocated: %d\n", buf.GetAllocated()); printf("Initial size: %d\n", buf.GetSize()); ! buf.SetSize(256); ! printf("After resizing allocated: %d\n", buf.GetAllocated()); printf("After resizing size: %d\n", buf.GetSize()); ! buf.Fill(1); ! buf.To(&f); ! f.Close(); getchar(); --- 51,70 ---- { Buffer buf; ! File wf(_R("dump.out"), File::WRITE|File::CREATE|File::BINARY); ! File rf(_R("dump.in"), File::READ|File::BINARY); printf("Initial allocated: %d\n", buf.GetAllocated()); printf("Initial size: %d\n", buf.GetSize()); ! buf.SetSize(256); ! printf("After resizing allocated: %d\n", buf.GetAllocated()); printf("After resizing size: %d\n", buf.GetSize()); ! if(rf.IsOpen()) ! buf.From(&rf); ! else ! buf.Fill(1); ! buf.To(&wf); getchar(); |