You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(102) |
Dec
(255) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(38) |
Feb
(16) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mik...@us...> - 2003-12-24 14:10:36
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src In directory sc8-pr-cvs1:/tmp/cvs-serv9609/src Modified Files: Main.cpp Log Message: 24/12/2003 Barbeaux * Added simple test program for Semaphores. Index: Main.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/Main.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Main.cpp 24 Dec 2003 13:03:56 -0000 1.2 +++ Main.cpp 24 Dec 2003 14:10:32 -0000 1.3 @@ -19,6 +19,7 @@ #include "test/TestException.h" #include "test/TestThread.h" +#include "test/TestSemaphore.h" /** * Main program. @@ -26,9 +27,12 @@ int main() { TestException test_excp; test_excp.test(); - + TestThread test_th; test_th.test(); + + TestSemaphore test_sem; + test_sem.test(); return 0; } |
From: <mik...@us...> - 2003-12-24 14:10:36
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/test In directory sc8-pr-cvs1:/tmp/cvs-serv9609/src/test Added Files: TestSemaphore.h TestSemaphore.cpp Log Message: 24/12/2003 Barbeaux * Added simple test program for Semaphores. --- NEW FILE: TestSemaphore.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TEST_SEMAPHORE_H_ #define _TEST_SEMAPHORE_H_ #include "TestHandler.h" #include "../thread/Semaphore.h" #include "../thread/Thread.h" #include "../exceptions/ThreadException.h" #include <iostream> using namespace std; /** * Defines a thread class that will be handled by the semaphore. */ class MyThread : public Thread { private: // the semaphore Semaphore *semaphore; // thread id int id; public: /** * Creates a test thread for the semaphore */ MyThread(Semaphore *sem, int nb) : Thread() { semaphore = sem; id = nb; } /** * Destructor for MyThread */ ~MyThread() throw (ThreadException) {} /** * Runs the Thread */ virtual void run() { /* The thread will wait to be signaled by the tester by the semaphore * that it can enters its processing mode. */ cout << "Thread n" << id << " says : I am waiting for the semaphore" << endl; semaphore->wait(); cout << "Thread n" << id << "says : Thanks, Tester !"; cout << " I can process now" << endl; for(int i=0;i<9;i++) { cout << "Thread n" << id << " says : I am processing" << endl; Thread::sleep(1); } cout << "Thread n" << id << " has finished !" << endl; } }; /** * Defines a tester for threads synchronized with semaphores. */ class TestSemaphore : public TestHandler { private: // semaphore for synchronizing threads. Semaphore *sync; public: /** * Creates a TestSemaphore object. */ TestSemaphore(); /** * Destructor for TestSemaphore */ ~TestSemaphore(); /** * Runs the tester. */ virtual void test(); }; #endif --- NEW FILE: TestSemaphore.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "TestSemaphore.h" /** * Creates a TestSemaphore object. */ TestSemaphore::TestSemaphore() : TestHandler() { // initialize the semaphore sync = new Semaphore(0); } /** * Destructor for TestSemaphore */ TestSemaphore::~TestSemaphore() { // delete the semaphore delete sync; } /** * Runs the tester. */ void TestSemaphore::test() { /** This test tries to launch two threads and to * synchronize them with the semaphore. */ cout << endl; cout << "ShareDaemon Web Interface - Test" << endl << endl; cout << "Test for semaphores and threads... " << endl; cout << "Two threads wanting to process their work wants to get " << endl; cout << "the semaphore before continuing. The program will " <<endl; cout << "will test synchronization between threads thanks to the" << endl; cout << "semaphore." << endl; cout << "Press enter to continue" << endl; getchar(); cout << endl << endl; try { // Creates the threads MyThread t1(sync, 1); MyThread t2(sync, 2); // Launches the threads t1.start(); t2.start(); // Goes on working for(int i=1;i<15;i++) { cout << "Tester is working..." << endl; if((i %5) == 0) { cout << "I need help, releasing a thread !" << endl; sync->post(); } Thread::sleep(1); } cout << "Tester has finished !" << endl; cout << "Tester says : Waiting for threads to end" << endl; t1.wait(); t2.wait(); cout << "Tester says : Threads ended, thanks for the help !" << endl << endl; } catch(Exception& e) { // display the exception message cout << e.getMessage() << endl; } cout << "Did you see the threads being synchronized by the semaphore ?" << endl; cout << " If no => VERY BAD :(" << endl; cout << " If yes => Test worked !! :D" << endl << endl; cout << "Press enter to continue" << endl; getchar(); } |
From: <mik...@us...> - 2003-12-24 13:09:46
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web In directory sc8-pr-cvs1:/tmp/cvs-serv1411 Modified Files: Makefile.bsd Makefile.osx Makefile.win Makefile.lin ChangeLog Log Message: 24/12/2003 Barbeaux * Updated Makefiles for Win32, Linux and MacOS X Index: Makefile.bsd =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/Makefile.bsd,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.bsd 24 Dec 2003 13:03:56 -0000 1.2 +++ Makefile.bsd 24 Dec 2003 13:09:42 -0000 1.3 @@ -33,6 +33,11 @@ src/exceptions/ThreadException.o \ src/test/TestHandler.o \ src/test/TestException.o \ + src/test/TestThread.o \ + src/thread/Mutex.o \ + src/thread/Condition.o \ + src/thread/Semaphore.o \ + src/thread/Thread.o \ src/Main.o $(BIN) : $(OBJECTS) Index: Makefile.osx =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/Makefile.osx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.osx 24 Dec 2003 13:03:56 -0000 1.2 +++ Makefile.osx 24 Dec 2003 13:09:42 -0000 1.3 @@ -33,6 +33,11 @@ src/exceptions/ThreadException.o \ src/test/TestHandler.o \ src/test/TestException.o \ + src/test/TestThread.o \ + src/thread/Mutex.o \ + src/thread/Condition.o \ + src/thread/Semaphore.o \ + src/thread/Thread.o \ src/Main.o $(BIN) : $(OBJECTS) Index: Makefile.win =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/Makefile.win,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.win 24 Dec 2003 13:03:56 -0000 1.2 +++ Makefile.win 24 Dec 2003 13:09:42 -0000 1.3 @@ -32,14 +32,18 @@ INCLUDE_DIRS = -I"$(MINGW_DIR)/include/c++" -I"$(MINGW_DIR)/include/c++/mingw32" INLUCDE_DIRS += -I"$(MINGW_DIR)/include/c++/backward" -I"$(MINGW_DIR)/include" LIBRARIES_DIR = -L"$(MINGW_DIR)/lib" -LIBS = -L"$(MINGW_DIR)/lib" $(MINGW_DIR)/lib/libws2_32.a -# $(MINGW_DIR)/lib/libpthreadGCE.a +LIBS = -L"$(MINGW_DIR)/lib" OBJECTS = src/exceptions/Exception.o \ src/exceptions/ThreadException.o \ src/test/TestHandler.o \ src/test/TestException.o \ + src/test/TestThread.o \ + src/thread/Mutex.o \ + src/thread/Condition.o \ + src/thread/Semaphore.o \ + src/thread/Thread.o \ src/Main.o $(BIN) : $(OBJECTS) Index: Makefile.lin =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/Makefile.lin,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.lin 24 Dec 2003 13:03:56 -0000 1.2 +++ Makefile.lin 24 Dec 2003 13:09:42 -0000 1.3 @@ -31,6 +31,11 @@ src/exceptions/ThreadException.o \ src/test/TestHandler.o \ src/test/TestException.o \ + src/test/TestThread.o \ + src/thread/Mutex.o \ + src/thread/Condition.o \ + src/thread/Semaphore.o \ + src/thread/Thread.o \ src/Main.o $(BIN) : $(OBJECTS) Index: ChangeLog =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/ChangeLog,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ChangeLog 24 Dec 2003 13:03:56 -0000 1.3 +++ ChangeLog 24 Dec 2003 13:09:42 -0000 1.4 @@ -24,6 +24,7 @@ ----------------------------------------------------------- 24/12/2003 Barbeaux + * Updated Makefiles for Win32, Linux and MacOS X * Added simple test programs for Exceptions and Threads. * Implemented Semaphore and Thread. * Implemented Mutex and Condition. |
From: <mik...@us...> - 2003-12-24 13:04:01
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web In directory sc8-pr-cvs1:/tmp/cvs-serv659 Modified Files: .cdtbuild Makefile.lin Makefile.bsd Makefile.osx Makefile.win ChangeLog Log Message: 24/12/2003 Barbeaux * Added simple test programs for Exceptions and Threads. * Implemented Semaphore and Thread. Index: .cdtbuild =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/.cdtbuild,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- .cdtbuild 24 Dec 2003 11:04:46 -0000 1.1 +++ .cdtbuild 24 Dec 2003 13:03:56 -0000 1.2 @@ -21,6 +21,11 @@ <optionReference defaultValue="Optimize most (-O3)" id="linux.gnu.c.compiler.general.optimization.level"/> <optionReference defaultValue="None" id="linux.c.compiler.debugging.level"/> </toolReference> + <toolReference id="cdt.build.tool.linux.gnu.link"> + <optionReference id="linux.gnu.linker.libs.libs"> + <listOptionValue builtIn="false" value="pthread"/> + </optionReference> + </toolReference> </configuration> <configuration id="linux.gnu.exec.debug.872073189" name="Debug" parent="linux.gnu.exec.debug"> <toolReference id="cdt.build.tool.linux.gnu.compiler"> Index: Makefile.lin =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/Makefile.lin,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.lin 24 Dec 2003 10:49:48 -0000 1.1 +++ Makefile.lin 24 Dec 2003 13:03:56 -0000 1.2 @@ -1,51 +1,51 @@ -# Simple Makefile -# Author : Mikael Barbeaux - - -# Edit thoses variables for suiting to your computer - - -# Your flags from the C++ compiler -CCFLAGS = -O3 -march=athlon-xp - -# Do you want debugging ? -#CCFLAGS += -D_DEBUG_INFO_ - -# Name of the binary -BIN = ui-web-std - - - -# !!!!! -# DO NOT CHANGE ANYTHING FROM THIS POINT -# !!!!! - -CCFLAGS += -D_LINUX_ -g -Wall -pedantic -MAKE = make -CC = g++ -RM = rm -STRIP = strip -LIBS = -lpthread - -OBJECTS = src/exceptions/Exception.o \ - src/exceptions/ThreadException.o \ - src/test/TestHandler.o \ - src/test/TestException.o \ - src/Main.o - -$(BIN) : $(OBJECTS) - $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) - -%.o : %.cpp - $(CC) $(CCFLAGS) -o $@ -c $< - -all : $(BIN) - -strip: - $(STRIP) $(BIN) - -.PHONY : clean - -clean : - $(RM) -f $(BIN) $(OBJECTS) - +# Simple Makefile +# Author : Mikael Barbeaux + + +# Edit thoses variables for suiting to your computer + + +# Your flags from the C++ compiler +CCFLAGS = -O3 -march=athlon-xp + +# Do you want debugging ? +#CCFLAGS += -D_DEBUG_INFO_ + +# Name of the binary +BIN = ui-web + + + +# !!!!! +# DO NOT CHANGE ANYTHING FROM THIS POINT +# !!!!! + +CCFLAGS += -D_LINUX_ -g -Wall -pedantic +MAKE = make +CC = g++ +RM = rm +STRIP = strip +LIBS = -lpthread + +OBJECTS = src/exceptions/Exception.o \ + src/exceptions/ThreadException.o \ + src/test/TestHandler.o \ + src/test/TestException.o \ + src/Main.o + +$(BIN) : $(OBJECTS) + $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) + +%.o : %.cpp + $(CC) $(CCFLAGS) -o $@ -c $< + +all : $(BIN) + +strip: + $(STRIP) $(BIN) + +.PHONY : clean + +clean : + $(RM) -f $(BIN) $(OBJECTS) + Index: Makefile.bsd =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/Makefile.bsd,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.bsd 24 Dec 2003 10:49:48 -0000 1.1 +++ Makefile.bsd 24 Dec 2003 13:03:56 -0000 1.2 @@ -1,53 +1,53 @@ -# Simple Makefile -# Author : Mikael Barbeaux - -###################################################### -# Edit thoses variables for suiting to your computer # -###################################################### - -# Your flags from the C++ compiler -CCFLAGS = -O3 -march=athlon-xp - -# Do you want debugging ? -#CCFLAGS += -D_DEBUG_INFO_ - -# Name of the binary -BIN = ui-web-std - - -############################################# -# # -# DO NOT CHANGE ANYTHING FROM THIS POINT # -# # -############################################# - -CCFLAGS += -D_LINUX_ -g -Wall -MAKE = make -CC = g++ -RM = rm -STRIP = strip -LIBS = -pthread - - -OBJECTS = src/exceptions/Exception.o \ - src/exceptions/ThreadException.o \ - src/test/TestHandler.o \ - src/test/TestException.o \ - src/Main.o - -$(BIN) : $(OBJECTS) - $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) - -%.o : %.cpp - $(CC) $(CCFLAGS) -o $@ -c $< - -all : $(BIN) - -strip: - $(STRIP) $(BIN) - -.PHONY : clean - -clean : - $(RM) -f $(BIN) $(OBJECTS) - +# Simple Makefile +# Author : Mikael Barbeaux + +###################################################### +# Edit thoses variables for suiting to your computer # +###################################################### + +# Your flags from the C++ compiler +CCFLAGS = -O3 -march=athlon-xp + +# Do you want debugging ? +#CCFLAGS += -D_DEBUG_INFO_ + +# Name of the binary +BIN = ui-web + + +############################################# +# # +# DO NOT CHANGE ANYTHING FROM THIS POINT # +# # +############################################# + +CCFLAGS += -D_LINUX_ -g -Wall +MAKE = make +CC = g++ +RM = rm +STRIP = strip +LIBS = -pthread + + +OBJECTS = src/exceptions/Exception.o \ + src/exceptions/ThreadException.o \ + src/test/TestHandler.o \ + src/test/TestException.o \ + src/Main.o + +$(BIN) : $(OBJECTS) + $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) + +%.o : %.cpp + $(CC) $(CCFLAGS) -o $@ -c $< + +all : $(BIN) + +strip: + $(STRIP) $(BIN) + +.PHONY : clean + +clean : + $(RM) -f $(BIN) $(OBJECTS) + Index: Makefile.osx =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/Makefile.osx,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.osx 24 Dec 2003 10:49:48 -0000 1.1 +++ Makefile.osx 24 Dec 2003 13:03:56 -0000 1.2 @@ -1,53 +1,53 @@ -# Simple Makefile -# Author : Mikael Barbeaux - -###################################################### -# Edit thoses variables for suiting to your computer # -###################################################### - -# Your flags from the C++ compiler -CCFLAGS = -O3 -march=athlon-xp - -# Do you want debugging ? -#CCFLAGS += -D_DEBUG_INFO_ - -# Name of the binary -BIN = ui-web-std - - -############################################# -# # -# DO NOT CHANGE ANYTHING FROM THIS POINT # -# # -############################################# - -CCFLAGS += -D_MACOSX_ -g -Wall -MAKE = make -CC = g++ -RM = rm -STRIP = strip -LIBS = -lpthread - - -OBJECTS = src/exceptions/Exception.o \ - src/exceptions/ThreadException.o \ - src/test/TestHandler.o \ - src/test/TestException.o \ - src/Main.o - -$(BIN) : $(OBJECTS) - $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) - -%.o : %.cpp - $(CC) $(CCFLAGS) -o $@ -c $< - -all : $(BIN) - -strip: - $(STRIP) $(BIN) - -.PHONY : clean - -clean : - $(RM) -f $(BIN) $(OBJECTS) - +# Simple Makefile +# Author : Mikael Barbeaux + +###################################################### +# Edit thoses variables for suiting to your computer # +###################################################### + +# Your flags from the C++ compiler +CCFLAGS = -O3 -march=athlon-xp + +# Do you want debugging ? +#CCFLAGS += -D_DEBUG_INFO_ + +# Name of the binary +BIN = ui-web + + +############################################# +# # +# DO NOT CHANGE ANYTHING FROM THIS POINT # +# # +############################################# + +CCFLAGS += -D_MACOSX_ -g -Wall +MAKE = make +CC = g++ +RM = rm +STRIP = strip +LIBS = -lpthread + + +OBJECTS = src/exceptions/Exception.o \ + src/exceptions/ThreadException.o \ + src/test/TestHandler.o \ + src/test/TestException.o \ + src/Main.o + +$(BIN) : $(OBJECTS) + $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) + +%.o : %.cpp + $(CC) $(CCFLAGS) -o $@ -c $< + +all : $(BIN) + +strip: + $(STRIP) $(BIN) + +.PHONY : clean + +clean : + $(RM) -f $(BIN) $(OBJECTS) + Index: Makefile.win =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/Makefile.win,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.win 24 Dec 2003 10:49:48 -0000 1.1 +++ Makefile.win 24 Dec 2003 13:03:56 -0000 1.2 @@ -1,60 +1,60 @@ -# Simple Makefile -# Author : Mikael Barbeaux - -###################################################### -# Edit thoses variables for suiting to your computer # -###################################################### - -# MinGW direcoty -MINGW_DIR = G:/Dev-Cpp - -# Your flags from the C++ compiler -CCFLAGS = -O3 -march=athlon-xp - -# Do you want debugging ? -#CCFLAGS += -D_DEBUG_INFO_ - -# Name of the binary -BIN = ui-web-std.exe - - -############################################# -# # -# DO NOT CHANGE ANYTHING FROM THIS POINT # -# # -############################################# - -CCFLAGS += -D_WIN32_ -g -Wall -MAKE = $(MINGW_DIR)/bin/make.exe -CC = $(MINGW_DIR)/bin/g++.exe -RM = $(MINGW_DIR)/bin/rm.exe -STRIP = $(MINGW_DIR)/bin/strip.exe -INCLUDE_DIRS = -I"$(MINGW_DIR)/include/c++" -I"$(MINGW_DIR)/include/c++/mingw32" -INLUCDE_DIRS += -I"$(MINGW_DIR)/include/c++/backward" -I"$(MINGW_DIR)/include" -LIBRARIES_DIR = -L"$(MINGW_DIR)/lib" -LIBS = -L"$(MINGW_DIR)/lib" $(MINGW_DIR)/lib/libws2_32.a -# $(MINGW_DIR)/lib/libpthreadGCE.a - - -OBJECTS = src/exceptions/Exception.o \ - src/exceptions/ThreadException.o \ - src/test/TestHandler.o \ - src/test/TestException.o \ - src/Main.o - -$(BIN) : $(OBJECTS) - $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBRARIES_DIR) $(LIBS) - -%.o : %.cpp - $(CC) $(CCFLAGS) $(INCLUDE_DIRS) -o $@ -c $< - -all : $(BIN) - -strip: - $(STRIP) $(BIN) - -.PHONY : clean - -clean : - $(RM) -f $(BIN) $(OBJECTS) - +# Simple Makefile +# Author : Mikael Barbeaux + +###################################################### +# Edit thoses variables for suiting to your computer # +###################################################### + +# MinGW direcoty +MINGW_DIR = G:/Dev-Cpp + +# Your flags from the C++ compiler +CCFLAGS = -O3 -march=athlon-xp + +# Do you want debugging ? +#CCFLAGS += -D_DEBUG_INFO_ + +# Name of the binary +BIN = ui-web.exe + + +############################################# +# # +# DO NOT CHANGE ANYTHING FROM THIS POINT # +# # +############################################# + +CCFLAGS += -D_WIN32_ -g -Wall +MAKE = $(MINGW_DIR)/bin/make.exe +CC = $(MINGW_DIR)/bin/g++.exe +RM = $(MINGW_DIR)/bin/rm.exe +STRIP = $(MINGW_DIR)/bin/strip.exe +INCLUDE_DIRS = -I"$(MINGW_DIR)/include/c++" -I"$(MINGW_DIR)/include/c++/mingw32" +INLUCDE_DIRS += -I"$(MINGW_DIR)/include/c++/backward" -I"$(MINGW_DIR)/include" +LIBRARIES_DIR = -L"$(MINGW_DIR)/lib" +LIBS = -L"$(MINGW_DIR)/lib" $(MINGW_DIR)/lib/libws2_32.a +# $(MINGW_DIR)/lib/libpthreadGCE.a + + +OBJECTS = src/exceptions/Exception.o \ + src/exceptions/ThreadException.o \ + src/test/TestHandler.o \ + src/test/TestException.o \ + src/Main.o + +$(BIN) : $(OBJECTS) + $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBRARIES_DIR) $(LIBS) + +%.o : %.cpp + $(CC) $(CCFLAGS) $(INCLUDE_DIRS) -o $@ -c $< + +all : $(BIN) + +strip: + $(STRIP) $(BIN) + +.PHONY : clean + +clean : + $(RM) -f $(BIN) $(OBJECTS) + Index: ChangeLog =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ChangeLog 24 Dec 2003 11:52:49 -0000 1.2 +++ ChangeLog 24 Dec 2003 13:03:56 -0000 1.3 @@ -24,6 +24,8 @@ ----------------------------------------------------------- 24/12/2003 Barbeaux + * Added simple test programs for Exceptions and Threads. + * Implemented Semaphore and Thread. * Implemented Mutex and Condition. * Implemented a ThreadException. * Added origin message into Exception handler. |
From: <mik...@us...> - 2003-12-24 13:03:59
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src In directory sc8-pr-cvs1:/tmp/cvs-serv659/src Modified Files: Main.cpp Log Message: 24/12/2003 Barbeaux * Added simple test programs for Exceptions and Threads. * Implemented Semaphore and Thread. Index: Main.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/Main.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Main.cpp 24 Dec 2003 10:49:48 -0000 1.1 +++ Main.cpp 24 Dec 2003 13:03:56 -0000 1.2 @@ -18,13 +18,17 @@ */ #include "test/TestException.h" - +#include "test/TestThread.h" + /** * Main program. */ int main() { - TestException test; - test.run(); + TestException test_excp; + test_excp.test(); + + TestThread test_th; + test_th.test(); return 0; } |
From: <mik...@us...> - 2003-12-24 13:03:59
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/test In directory sc8-pr-cvs1:/tmp/cvs-serv659/src/test Modified Files: TestException.cpp TestException.h TestHandler.h Added Files: TestThread.cpp TestThread.h Log Message: 24/12/2003 Barbeaux * Added simple test programs for Exceptions and Threads. * Implemented Semaphore and Thread. --- NEW FILE: TestThread.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "TestThread.h" #include <iostream> using namespace std; #include <stdio.h> /** * Constructor for TestThread. */ TestThread::TestThread() : TestHandler(), Thread() { } /** * Destructor for TestThread. */ TestThread::~TestThread() throw (ThreadException) { } /** * Runs the thread. */ void TestThread::run() { cout << "I am the thread, running 5 seconds..." << endl; for(int i=0;i<5;i++) { cout << "Thread says : \"Hello world !\"" << endl; Thread::sleep(1); } cout << "Thread has finished !" << endl; } /** * Runs the tester. */ void TestThread::test() { /** This test tries to launch a thread * and goes on working. */ cout << endl; cout << "ShareDaemon Web Interface - Test" << endl << endl; cout << "Test for threads... " << endl; cout << "A thread saying \"Hello world !\" will start to run for 5 seconds, " << endl; cout << "while the main thread will display \"Tester is working\". After " << endl; cout << "5 seconds, the thread should stop and the tester will goes" << endl; cout << "on working for 5 others seconds before exiting." << endl; cout << "Press enter to continue" << endl; getchar(); cout << endl << endl; try { // Launching the thread start(); // Goes on working for(int i=0;i<10;i++) { cout << "Tester is working..." << endl; Thread::sleep(1); } cout << "Tester has finished !" << endl << endl; } catch(Exception& e) { // display the exception message cout << e.getMessage() << endl; } cout << "Did you see the thread working ?" << endl; cout << " If no => VERY BAD :(" << endl; cout << " If yes => Test worked !! :D" << endl << endl; cout << "Press enter to continue" << endl; getchar(); } --- NEW FILE: TestThread.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TEST_THREAD_H_ #define _TEST_THREAD_H_ #include "TestHandler.h" #include "../thread/Thread.h" #include "../exceptions/ThreadException.h" /** * Defines a test class for threading. * Herits from TestHandler ( it's a test class ) and from * Thread ( this tester is itself a Thread ). */ class TestThread : public TestHandler, public Thread { public: /** * Creates a test for threading. */ TestThread(); /** * Destructor for TestThread */ ~TestThread() throw (ThreadException); /** * Runs the thread. */ virtual void run(); /** * Runs the tester. */ virtual void test(); }; #endif Index: TestException.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/test/TestException.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TestException.cpp 24 Dec 2003 11:52:49 -0000 1.2 +++ TestException.cpp 24 Dec 2003 13:03:55 -0000 1.3 @@ -22,6 +22,7 @@ #include "../exceptions/ThreadException.h" #include <iostream> using namespace std; +#include <stdio.h> /** * Creates a TestException object. @@ -32,20 +33,29 @@ /** * Runs the tester. */ -void TestException::run() { +void TestException::test() { /** This test tries to launch an exception * and to catch it. Then it displays the message * sent by the exception before exiting. */ - //cout << "Start of TestException" <<endl; + cout << endl; + cout << "ShareDaemon Web Interface - Test" << endl << endl; + cout << "Test for exceptions... " << endl; + cout << "The program will now try to throw an exception, and then" << endl; + cout << "will try to catch it. So don't worry if the console says an" <<endl; + cout << "exception occured, it's totally normal !!" << endl; + cout << "Press enter to continue" << endl; + getchar(); + cout << endl << endl; try { - //cout << "Throws exception" << endl; - throw ThreadException(MutexError, "MutexError test", "TestException::run"); - //cout << "Exception hasn't been thrown" << endl; + throw ThreadException(MutexExcp, "MutexError - Only a test !!", "TestException::run"); } catch(Exception& e) { - //cout << "Exception catched" << endl; // display the exception message cout << e.getMessage() << endl; } - //cout << "End of TestException" << endl; + cout << "Did you see the exception ?" << endl; + cout << " If no => VERY BAD :(" << endl; + cout << " If yes => Test worked !! :D" << endl << endl; + cout << "Press enter to continue" << endl; + getchar(); } Index: TestException.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/test/TestException.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TestException.h 24 Dec 2003 10:49:48 -0000 1.1 +++ TestException.h 24 Dec 2003 13:03:55 -0000 1.2 @@ -40,7 +40,7 @@ /** * Runs the tester. */ - virtual void run(); + virtual void test(); }; #endif Index: TestHandler.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/test/TestHandler.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TestHandler.h 24 Dec 2003 10:49:48 -0000 1.1 +++ TestHandler.h 24 Dec 2003 13:03:55 -0000 1.2 @@ -44,7 +44,7 @@ * Runs the test * Needs to be implemented into subclasses. */ - virtual void run() = 0; + virtual void test() = 0; }; |
From: <mik...@us...> - 2003-12-24 13:03:58
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions In directory sc8-pr-cvs1:/tmp/cvs-serv659/src/exceptions Modified Files: ThreadException.h ThreadException.cpp Log Message: 24/12/2003 Barbeaux * Added simple test programs for Exceptions and Threads. * Implemented Semaphore and Thread. Index: ThreadException.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/ThreadException.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ThreadException.h 24 Dec 2003 11:52:49 -0000 1.2 +++ ThreadException.h 24 Dec 2003 13:03:54 -0000 1.3 @@ -23,8 +23,9 @@ #include "Exception.h" enum ThreadError { - MutexError, - ConditionError + MutexExcp, + ConditionExcp, + ThreadExcp }; /** Index: ThreadException.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/ThreadException.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ThreadException.cpp 24 Dec 2003 11:52:49 -0000 1.2 +++ ThreadException.cpp 24 Dec 2003 13:03:54 -0000 1.3 @@ -40,8 +40,14 @@ message << "WARNING : Exception thrown !!" << endl; message << "| Type : "; switch(code) { - case MutexError: + case MutexExcp: message << "MutexError"; + break; + case ConditionExcp: + message << "ConditionError"; + break; + case ThreadExcp: + message << "ThreadError"; break; default: message << "UnknownError"; |
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread In directory sc8-pr-cvs1:/tmp/cvs-serv659/src/thread Modified Files: Mutex.cpp Condition.cpp Condition.h Added Files: Thread.cpp Semaphore.cpp Thread.h Semaphore.h Log Message: 24/12/2003 Barbeaux * Added simple test programs for Exceptions and Threads. * Implemented Semaphore and Thread. --- NEW FILE: Thread.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Thread.h" /** * Creates a thread object. * Initializes parameters only. */ Thread::Thread() : Condition(), thread(0), cancel_th(false), running(false) {} /** * Thread destructor * Waits for the thread to terminate before deleting it. */ Thread::~Thread() throw (ThreadException) { lock(); if(thread) { // try to cancel thread execution if still running cancel_th = true; if(running) waitForSignal(); // wait for thread to terminate #ifdef _WIN32_ ::WaitForSingleObject(*thread, INFINITE); #else ::pthread_join(*thread, 0); #endif // delete thread delete thread; } unlock(); } /** * Launch the thread */ void *Thread::launch(void* th) throw (ThreadException) { // Retrieve the thread to launch Thread *thread = (Thread*) th; // signal waiting threads that it is going to be run thread->lock(); thread->running = true; thread->sendSignal(); thread->unlock(); // run thread->run(); // signal waiting threads that it is terminated thread->lock(); thread->running = false; thread->sendBroadcastSignal(); thread->unlock(); return 0; } /** * Sets a cancellation point. */ void Thread::setCancelPoint() throw (ThreadException) { lock(); // exit thread if cancellation has been requested if(cancel_th) { running = false; sendBroadcastSignal(); unlock(); #ifdef _WIN32_ ::ExitThread(0); #else ::pthread_exit(0); #endif } unlock(); } /** * Cancels the thread execution. */ void Thread::cancel() { cancel_th = true; } /** * Tests if the thread is currently running. */ bool Thread::isRunning() { return running; } /** * Make the current thread stop execution * for the given time. */ void Thread::sleep(float time) throw (ThreadException) { if(time < 0) throw ThreadException(ThreadExcp, "Invalid sleep time.", "Thread::sleep"); // sleep #ifdef _WIN32_ ::Sleep((unsigned int) (1000*time)); #else if(::usleep((unsigned int) (1000000*time)) != 0) throw ThreadException(ThreadExcp, "Cannot sleep", "Thread::sleep"); #endif } /** * Starts the thread execution. */ void Thread::start() throw (ThreadException) { lock(); // Allocates pthread thread = new pthread_t; if(thread == 0) throw ThreadException(ThreadExcp, "Cannot allocate the thread.", "Thread::start"); #ifdef _WIN32_ if((*thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE) launch, this, 0 ,0)) == 0) throw ThreadException(ThreadExcp, "Cannot create the thread.", "Thread::start"); #else if(::pthread_create(thread, 0, launch, this) != 0) throw ThreadException(ThreadExcp, "Cannot create the thread.", "Thread::start"); #endif // wait for thread to start if(! running) waitForSignal(); unlock(); } /** * Wait for the condition, with locks * if given parameter is true. */ void Thread::wait(bool toLock) throw (ThreadException) { if(toLock) lock(); if(running) waitForSignal(); if(toLock) unlock(); } --- NEW FILE: Semaphore.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Semaphore.h" /** * Posts a signal. */ void Semaphore::post() throw (ThreadException) { lock(); ++number; if(number <= 0) sendSignal(); unlock(); } /** * Tries to enter the semaphore without any wait. */ bool Semaphore::tryWait() throw (ThreadException) { lock(); if(number <= 0) { unlock(); return false; } --number; if(number < 0) waitForSignal(); unlock(); return true; } /** * Wait for the semaphore to let the thread enter. */ void Semaphore::wait() throw (ThreadException) { lock(); --number; if(number < 0) waitForSignal(); unlock(); } --- NEW FILE: Thread.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _THREAD_H_ #define _THREAD_H_ #include "Condition.h" #ifdef _WIN32_ #include <windows.h> /** * As pthread doesn't exist for Windows, * create the object type. */ typedef HANDLE pthread_t; #else #include <pthread.h> #include <unistd.h> #include <sys/errno.h> #endif /** * Defines a Thread object. * A thread is used to run a part of code into a * system condition-thread. Implements the run() * method to define what your thread must do. */ class Thread : public Condition { private: /** * Launch the thread */ static void *launch(void* th) throw (ThreadException); protected: // the thread pthread_t *thread; // cancel ? bool cancel_th; // running ? bool running; /** * Defines what the thread will do. */ virtual void run() = 0; /** * Sets a cancellation point. */ void setCancelPoint() throw (ThreadException); public: /** * Creates a thread object. */ Thread(); /** * Thread destructor. */ virtual ~Thread() throw (ThreadException); /** * Cancels the thread execution. */ void cancel(); /** * Tests if the thread is currently running. * * @return bool */ bool isRunning(); /** * Make the current thread stop execution * for the given time. * * @param time */ static void sleep(float time) throw (ThreadException); /** * Starts the thread execution. */ void start() throw (ThreadException); /** * Wait for the condition, with locks * if given parameter is true. * * @param bool */ void wait(bool toLock = true) throw (ThreadException); }; #endif --- NEW FILE: Semaphore.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _SEMAPHORE_H_ #define _SEMAPHORE_H_ #include "Condition.h" #include "../exceptions/ThreadException.h" /** * Defines a Semaphore object. * A semaphore is a condition with a maximum * number of executing thread. If this number * is reached, every threads that will try * to enter the semaphore will be waiting for * another thread to leave the semaphore. */ class Semaphore : public Condition { protected: // Max number of executing threads. int number; public: /** * Creates a semaphore with the given maximum * number of executings threads. * * @param nb */ Semaphore(unsigned int nb) throw (ThreadException) : number(nb) {} /** * Semaphore destructor */ ~Semaphore() {} /** * Returns the max number of executings threads. * * @return unsigned int */ unsigned int getNumber() { return number; } /** * Posts a signal. */ void post() throw (ThreadException); /** * Sets the maximum number of executing threads. */ void setNumber(unsigned int nb) { number = nb; } /** * Tries to enter the semaphore without any wait. * * @return bool */ bool tryWait() throw (ThreadException); /** * Wait for the semaphore to let the thread enter. */ void wait() throw (ThreadException); }; #endif Index: Mutex.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread/Mutex.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Mutex.cpp 24 Dec 2003 11:52:49 -0000 1.1 +++ Mutex.cpp 24 Dec 2003 13:03:54 -0000 1.2 @@ -28,16 +28,16 @@ // Allocate mutex mutex = new pthread_mutex_t; if(mutex == 0) - throw ThreadException(MutexError, "Cannot allocate the mutex.", + throw ThreadException(MutexExcp, "Cannot allocate the mutex.", "Mutex::Mutex"); // Initialize the mutex #ifdef _WIN32_ if((*mutex = ::CreateMutex(0,0,0)) == 0) - throw ThreadException(MutexError, "Cannot create the mutex", + throw ThreadException(MutexExcp, "Cannot create the mutex", "Mutex::Mutex"); #else if(::pthread_mutex_init(mutex, 0)) - throw ThreadException(MutexError, "Cannot create the mutex", + throw ThreadException(MutexExcp, "Cannot create the mutex", "Mutex::Mutex"); #endif } @@ -73,11 +73,11 @@ #ifdef _WIN32_ // waits indefinitively for the mutex... if(::WaitForSingleObject(*mutex, INFINITE) != WAIT_OBJECT_0) - throw ThreadException(MutexError, "Cannot lock the mutex.", + throw ThreadException(MutexExcp, "Cannot lock the mutex.", "Mutex::lock"); #else if(::pthread_mutex_lock(mutex) != 0) - throw ThreadException(MutexError, "Cannot lock the mutex.", + throw ThreadException(MutexExcp, "Cannot lock the mutex.", "Mutex::lock"); #endif } @@ -98,7 +98,7 @@ if(ret == WAIT_TIMEOUT) return false; else if(ret != WAIT_OBJECT_0) - throw ThreadException(MutexError, "Cannot tryLock the mutex.", + throw ThreadException(MutexExcp, "Cannot tryLock the mutex.", "Mutex::tryLock"); return true; #else @@ -106,7 +106,7 @@ if(ret == EBUSY) return false; else if(ret != 0) - throw ThreadException(MutexError, "Cannot tryLock the mutex", + throw ThreadException(MutexExcp, "Cannot tryLock the mutex", "Mutex::tryLock"); return true; #endif @@ -119,11 +119,11 @@ // Unlocking the mutex... #ifdef _WIN32_ if(::ReleaseMutex(*mutex) == 0) - throw ThreadException(MutexError, "Cannot unlock the mutex.", + throw ThreadException(MutexExcp, "Cannot unlock the mutex.", "Mutex::unlock"); #else if(::pthread_mutex_unlock(mutex) != 0) - throw ThreadException(MutexError, "Cannot unlock the mutex.", + throw ThreadException(MutexExcp, "Cannot unlock the mutex.", "Mutex::unlock"); #endif } Index: Condition.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread/Condition.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Condition.cpp 24 Dec 2003 11:52:49 -0000 1.1 +++ Condition.cpp 24 Dec 2003 13:03:54 -0000 1.2 @@ -26,7 +26,7 @@ Condition::Condition() throw (ThreadException){ condition = new pthread_cond_t; if(condition == 0) - throw ThreadException(ConditionError, "Cannot allocate the condition.", + throw ThreadException(ConditionExcp, "Cannot allocate the condition.", "Condition::Condition"); #ifdef _WIN32_ // Init struct parameters @@ -40,12 +40,12 @@ can't create condition. */ if((condition->semaphore == 0) || (condition->waiters_done == 0)) - throw ThreadException(ConditionError, "Cannot create the condition.", + throw ThreadException(ConditionExcp, "Cannot create the condition.", "Condition::Condition"); #else // init pthread condition if(::pthread_cond_init(condition, 0) != 0) - throw ThreadException(ConditionError, "Cannot create the condition.", + throw ThreadException(ConditionExcp, "Cannot create the condition.", "Condition::Condition"); #endif } @@ -92,7 +92,7 @@ INFINITE, false) != WAIT_OBJECT_0) { // semaphore is invalid unlock(); - throw ThreadException(ConditionError, "Invalid semaphore.", + throw ThreadException(ConditionExcp, "Invalid semaphore.", "Condition::waitforSignal"); } // Waiting time is finished, we leave the waiting area @@ -108,7 +108,7 @@ INFINITE, false) != WAIT_OBJECT_0) { // the mutex is invalid unlock(); - throw ThreadException(ConditionError, "Invalid mutex.", + throw ThreadException(ConditionExcp, "Invalid mutex.", "Condition::waitForSignal"); } } @@ -117,13 +117,13 @@ else if(::WaitForSingleObject(*mutex_t, INFINITE) != WAIT_OBJECT_0) { unlock(); - throw ThreadException(ConditionError, "Invalid mutex.", + throw ThreadException(ConditionExcp, "Invalid mutex.", "Condition::waitForSignal"); } #else if(::pthread_cond_wait(condition, mutex) != 0) { unlock(); - throw ThreadException(ConditionError, "Invalid condition.", + throw ThreadException(ConditionExcp, "Invalid condition.", "Condition::waitForSignal"); } #endif @@ -144,13 +144,13 @@ (::ReleaseSemaphore(condition->semaphore,1,0) == 0)) { // if the condition is invalid unlock(); - throw ThreadException(ConditionError, "Invalid condition.", + throw ThreadException(ConditionExcp, "Invalid condition.", "Condition::sendSignal"); } #else if(::pthread_cond_signal(condition) != 0) { unlock(); - throw ThreadException(ConditionError, "Invalid condition", + throw ThreadException(ConditionExcp, "Invalid condition", "Condition::sendSignal"); } #endif @@ -171,7 +171,7 @@ condition->nb_waiting, 0)) { // Can't release the semaphore unlock(); - throw ThreadException(ConditionError, "Cannot release the semaphore.", + throw ThreadException(ConditionExcp, "Cannot release the semaphore.", "Condition::sendBroadcastSignal"); } LeaveCriticalSection(&(condition->waiting_lock)); @@ -179,7 +179,7 @@ if(::WaitForSingleObject(condition->waiters_done, INFINITE) != WAIT_OBJECT_0) { unlock(); - throw ThreadException(ConditionError, "Invalid event.", + throw ThreadException(ConditionExcp, "Invalid event.", "Condition::sendBroadcastSignal"); } condition->broadcast = false; @@ -188,7 +188,7 @@ #else if(::pthread_cond_broadcast(condition) != 0) { unlock(); - throw ThreadException(ConditionError, "Invalid condition.", + throw ThreadException(ConditionExcp, "Invalid condition.", "Condition::sendBroadcastSignal"); } #endif Index: Condition.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread/Condition.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Condition.h 24 Dec 2003 11:52:49 -0000 1.1 +++ Condition.h 24 Dec 2003 13:03:54 -0000 1.2 @@ -17,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _CONDITION_H -#define _CONDITION_H +#ifndef _CONDITION_H_ +#define _CONDITION_H_ #include "Mutex.h" #include "../exceptions/ThreadException.h" |
From: <mik...@us...> - 2003-12-24 11:52:53
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions In directory sc8-pr-cvs1:/tmp/cvs-serv22602/src/exceptions Modified Files: Exception.h ThreadException.cpp ThreadException.h Exception.cpp Log Message: 24/12/2003 Barbeaux * Implemented Mutex and Condition. * Implemented a ThreadException. * Added origin message into Exception handler. Index: Exception.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/Exception.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Exception.h 24 Dec 2003 10:49:48 -0000 1.1 +++ Exception.h 24 Dec 2003 11:52:49 -0000 1.2 @@ -35,6 +35,8 @@ // code of this exception int code; + // origin of this exception + string origin; public: @@ -43,8 +45,14 @@ * * @param eCode - code number of this exception * @param message - A message to explain this exception + * @param origin - Method of throw the exception */ - explicit Exception(int eCode, const string& message); + explicit Exception(int eCode, const string& message, const string& origin); + + /** + * Destructor for Exception + */ + virtual ~Exception() throw() {} /** * Returns the error code of this exception Index: ThreadException.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/ThreadException.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ThreadException.cpp 24 Dec 2003 10:49:48 -0000 1.1 +++ ThreadException.cpp 24 Dec 2003 11:52:49 -0000 1.2 @@ -25,8 +25,8 @@ * Creates a ThreadException object with the given error code and * message. */ -ThreadException::ThreadException(ThreadError eCode, const string& message) : - Exception(eCode, message) { +ThreadException::ThreadException(ThreadError eCode, const string& message, + const string& origin) : Exception(eCode, message, origin) { } /** @@ -36,6 +36,9 @@ const string ThreadException::getMessage() const { ostringstream message; // Build error message depending error code + message << "-----------------------" << endl; + message << "WARNING : Exception thrown !!" << endl; + message << "| Type : "; switch(code) { case MutexError: message << "MutexError"; @@ -44,8 +47,9 @@ message << "UnknownError"; break; } - message << ": "; - message << what(); + message << endl << "| From : " << origin << endl; + message << "| Message : " << what() << endl; + message << "-----------------------" << endl; return message.str(); } Index: ThreadException.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/ThreadException.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ThreadException.h 24 Dec 2003 10:49:48 -0000 1.1 +++ ThreadException.h 24 Dec 2003 11:52:49 -0000 1.2 @@ -23,7 +23,8 @@ #include "Exception.h" enum ThreadError { - MutexError + MutexError, + ConditionError }; /** @@ -38,8 +39,10 @@ * * @param eCode - code of this exception * @param message - Message to send to this exception + * @param origin - Method who throws the exception */ - ThreadException(ThreadError eCode, const string& message); + ThreadException(ThreadError eCode, const string& message, + const string& origin); /** * Returns the message sent by this Thread exception. Index: Exception.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions/Exception.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Exception.cpp 24 Dec 2003 10:49:48 -0000 1.1 +++ Exception.cpp 24 Dec 2003 11:52:49 -0000 1.2 @@ -23,8 +23,8 @@ * Creates a Exception object with the given code and * message. */ -Exception::Exception(int eCode, const string& message) : - runtime_error(message), code(eCode) { +Exception::Exception(int eCode, const string& message, const string& origin) : + runtime_error(message), code(eCode), origin(origin) { } /** |
From: <mik...@us...> - 2003-12-24 11:52:52
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/test In directory sc8-pr-cvs1:/tmp/cvs-serv22602/src/test Modified Files: TestException.cpp Log Message: 24/12/2003 Barbeaux * Implemented Mutex and Condition. * Implemented a ThreadException. * Added origin message into Exception handler. Index: TestException.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/test/TestException.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TestException.cpp 24 Dec 2003 10:49:48 -0000 1.1 +++ TestException.cpp 24 Dec 2003 11:52:49 -0000 1.2 @@ -36,19 +36,16 @@ /** This test tries to launch an exception * and to catch it. Then it displays the message * sent by the exception before exiting. */ - cout << "Start of TestException" <<endl; + //cout << "Start of TestException" <<endl; try { - cout << " Create a ThreadException" << endl; - ThreadError error = MutexError; - ThreadException excp(error,"Mutex isn't initialized"); - cout << " Throws exception" << endl; - throw excp; - cout << " Exception hasn't been thrown" << endl; + //cout << "Throws exception" << endl; + throw ThreadException(MutexError, "MutexError test", "TestException::run"); + //cout << "Exception hasn't been thrown" << endl; } catch(Exception& e) { - cout << " Exception catched" << endl; - // displays the exception message - cout << " " << e.getMessage() << endl; + //cout << "Exception catched" << endl; + // display the exception message + cout << e.getMessage() << endl; } - cout << "End of TestException" << endl; + //cout << "End of TestException" << endl; } |
From: <mik...@us...> - 2003-12-24 11:52:52
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web In directory sc8-pr-cvs1:/tmp/cvs-serv22602 Modified Files: ChangeLog Log Message: 24/12/2003 Barbeaux * Implemented Mutex and Condition. * Implemented a ThreadException. * Added origin message into Exception handler. Index: ChangeLog =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/ChangeLog,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ChangeLog 24 Dec 2003 10:49:48 -0000 1.1 +++ ChangeLog 24 Dec 2003 11:52:49 -0000 1.2 @@ -24,6 +24,9 @@ ----------------------------------------------------------- 24/12/2003 Barbeaux + * Implemented Mutex and Condition. + * Implemented a ThreadException. + * Added origin message into Exception handler. * Implemented a basic Main program. * Implemented generic Test handler. * Implemented generic Exception handler. |
From: <mik...@us...> - 2003-12-24 11:52:52
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread In directory sc8-pr-cvs1:/tmp/cvs-serv22602/src/thread Added Files: Mutex.h Mutex.cpp Condition.cpp Condition.h Log Message: 24/12/2003 Barbeaux * Implemented Mutex and Condition. * Implemented a ThreadException. * Added origin message into Exception handler. --- NEW FILE: Mutex.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _MUTEX_H_ #define _MUTEX_H_ #ifdef _WIN32_ #include <windows.h> // Use HANDLE as the pthread_mutex_t type typedef HANDLE pthread_mutex_t; #else #include <pthread.h> #include <sys/errno.h> #endif #include "../exceptions/ThreadException.h" /** * Defines a mutex handler. * A mutex is a synchronizer between mutliple * threads. It allows to define a part of code that * will be executed by only one thread at each time. */ class Mutex { protected: // the mutex pthread_mutex_t *mutex; public: /** * Creates a Mutex object. */ Mutex() throw (ThreadException); /** * Destroys a Mutex object. */ ~Mutex(); /** * Locks the mutex. */ void lock() throw (ThreadException); /** * Tries to enter the mutex without any wait. * * @return bool */ bool tryLock() throw (ThreadException); /** * Unlocks the mutex. */ void unlock() throw (ThreadException); }; #endif --- NEW FILE: Mutex.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Mutex.h" /** * Creates the Mutex object, by * allocating and initializing the * mutex parameter. */ Mutex::Mutex() throw (ThreadException) { // Allocate mutex mutex = new pthread_mutex_t; if(mutex == 0) throw ThreadException(MutexError, "Cannot allocate the mutex.", "Mutex::Mutex"); // Initialize the mutex #ifdef _WIN32_ if((*mutex = ::CreateMutex(0,0,0)) == 0) throw ThreadException(MutexError, "Cannot create the mutex", "Mutex::Mutex"); #else if(::pthread_mutex_init(mutex, 0)) throw ThreadException(MutexError, "Cannot create the mutex", "Mutex::Mutex"); #endif } /** * Destructs a Mutex object. * Before destroying it, we need to be sure * that the mutex is unlocked. */ Mutex::~Mutex() { // Waits for the mutex to unlock #ifdef _WIN32_ while(::CloseHandle(*mutex) == 0) { lock(); unlock(); } #else while(::pthread_mutex_destroy(mutex) == EBUSY) { lock(); unlock(); } #endif // delete the mutex delete mutex; mutex = 0; } /** * Locks the mutex. */ void Mutex::lock() throw (ThreadException) { // Locking the mutex #ifdef _WIN32_ // waits indefinitively for the mutex... if(::WaitForSingleObject(*mutex, INFINITE) != WAIT_OBJECT_0) throw ThreadException(MutexError, "Cannot lock the mutex.", "Mutex::lock"); #else if(::pthread_mutex_lock(mutex) != 0) throw ThreadException(MutexError, "Cannot lock the mutex.", "Mutex::lock"); #endif } /** * Tries to lock the mutex. * Returns false if the mutex is already ownded by another * thread. */ bool Mutex::tryLock() throw (ThreadException) { /** * Waits 0 second for the mutex, * if it returns a TIMEOUT, then the mutex is * already owned. */ #ifdef _WIN32_ int ret = ::WaitForSingleObject(*mutex, 0); if(ret == WAIT_TIMEOUT) return false; else if(ret != WAIT_OBJECT_0) throw ThreadException(MutexError, "Cannot tryLock the mutex.", "Mutex::tryLock"); return true; #else int ret = ::pthread_mutex_trylock(mutex); if(ret == EBUSY) return false; else if(ret != 0) throw ThreadException(MutexError, "Cannot tryLock the mutex", "Mutex::tryLock"); return true; #endif } /** * Unlocks the mutex. */ void Mutex::unlock() throw (ThreadException) { // Unlocking the mutex... #ifdef _WIN32_ if(::ReleaseMutex(*mutex) == 0) throw ThreadException(MutexError, "Cannot unlock the mutex.", "Mutex::unlock"); #else if(::pthread_mutex_unlock(mutex) != 0) throw ThreadException(MutexError, "Cannot unlock the mutex.", "Mutex::unlock"); #endif } --- NEW FILE: Condition.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Condition.h" /** * Creates a Condition object. * Allocates the condition object and initializes it. */ Condition::Condition() throw (ThreadException){ condition = new pthread_cond_t; if(condition == 0) throw ThreadException(ConditionError, "Cannot allocate the condition.", "Condition::Condition"); #ifdef _WIN32_ // Init struct parameters condition->nb_waiting = 0; condition->broadcast = false; ::InitializeCriticalSection(&(condition->waiting_lock)); condition->semaphore = ::CreateSemaphore(0, 0, 0x7fffffff, 0); condition->waiters_done = ::CreateEvent(0,false,false,0); /* If semaphore or waiters_done are nulls, can't create condition. */ if((condition->semaphore == 0) || (condition->waiters_done == 0)) throw ThreadException(ConditionError, "Cannot create the condition.", "Condition::Condition"); #else // init pthread condition if(::pthread_cond_init(condition, 0) != 0) throw ThreadException(ConditionError, "Cannot create the condition.", "Condition::Condition"); #endif } /** * Condition destructor * For win32 users, it deletes all data in the condition * structure. Then, it destroys the condition object. */ Condition::~Condition() { // Destroys the condition content #ifdef _WIN32_ ::DeleteCriticalSection(&(condition->waiting_lock)); /* While there are threads waiting for the condition, send the broadcast message to release them. */ while(::CloseHandle(condition->semaphore) == 0) sendBroadcastSignal(); while(::CloseHandle(condition->waiters_done) == 0) sendBroadcastSignal(); #else while(::pthread_cond_destroy(condition) == EBUSY) sendBroadcastSignal(); #endif //Delete the condition delete condition; condition = 0; } /** * Waits for a signal to release the condition. * Called when a new thread is added to the waiting threads * for the condition. */ void Condition::waitForSignal() throw (ThreadException) { #ifdef _WIN32_ // Adds a new waiting thread EnterCriticalSection(&(condition->waiting_lock)); ++(condition->nb_waiting); LeaveCriticalSection(&(condition->waiting_lock)); /* Waits indefinitively for the semaphore to release the mutex. */ HANDLE *mutex_t = (HANDLE*) mutex; if(::SignalObjectAndWait(*mutex_t, condition->semaphore, INFINITE, false) != WAIT_OBJECT_0) { // semaphore is invalid unlock(); throw ThreadException(ConditionError, "Invalid semaphore.", "Condition::waitforSignal"); } // Waiting time is finished, we leave the waiting area EnterCriticalSection(&(condition->waiting_lock)); --(condition->nb_waiting); // Are we the last waiter of a broadcast message ? bool last_waiter = (condition->broadcast && (condition->nb_waiting == 0)); LeaveCriticalSection(&(condition->waiting_lock)); if(last_waiter) { // Wait for all waiting threads to leave the mutex. if(::SignalObjectAndWait(condition->waiters_done, *mutex_t, INFINITE, false) != WAIT_OBJECT_0) { // the mutex is invalid unlock(); throw ThreadException(ConditionError, "Invalid mutex.", "Condition::waitForSignal"); } } /* if not last waiter of broadcast message, just wait for a single message on the mutex. */ else if(::WaitForSingleObject(*mutex_t, INFINITE) != WAIT_OBJECT_0) { unlock(); throw ThreadException(ConditionError, "Invalid mutex.", "Condition::waitForSignal"); } #else if(::pthread_cond_wait(condition, mutex) != 0) { unlock(); throw ThreadException(ConditionError, "Invalid condition.", "Condition::waitForSignal"); } #endif } /** * Sends a signal to the condition in order to release * a unique waiting thread. */ void Condition::sendSignal()throw (ThreadException) { #ifdef _WIN32_ // We retrieve first the number of waiting threads EnterCriticalSection(&(condition->waiting_lock)); int nb_waiting = condition->nb_waiting; LeaveCriticalSection(&(condition->waiting_lock)); // Release a unique thread if any are waiting if((nb_waiting > 0) && (::ReleaseSemaphore(condition->semaphore,1,0) == 0)) { // if the condition is invalid unlock(); throw ThreadException(ConditionError, "Invalid condition.", "Condition::sendSignal"); } #else if(::pthread_cond_signal(condition) != 0) { unlock(); throw ThreadException(ConditionError, "Invalid condition", "Condition::sendSignal"); } #endif } /** * Sends a signal to the condition in order to release * every waiting threads. */ void Condition::sendBroadcastSignal()throw (ThreadException) { #ifdef _WIN32_ EnterCriticalSection(&(condition->waiting_lock)); // If there are waiting threads if(condition->nb_waiting > 0) { condition->broadcast = true; // Release all waiting threads if(! ::ReleaseSemaphore(condition->semaphore, condition->nb_waiting, 0)) { // Can't release the semaphore unlock(); throw ThreadException(ConditionError, "Cannot release the semaphore.", "Condition::sendBroadcastSignal"); } LeaveCriticalSection(&(condition->waiting_lock)); // waits for the thread to acquire the semaphore if(::WaitForSingleObject(condition->waiters_done, INFINITE) != WAIT_OBJECT_0) { unlock(); throw ThreadException(ConditionError, "Invalid event.", "Condition::sendBroadcastSignal"); } condition->broadcast = false; } else LeaveCriticalSection(&(condition->waiting_lock)); #else if(::pthread_cond_broadcast(condition) != 0) { unlock(); throw ThreadException(ConditionError, "Invalid condition.", "Condition::sendBroadcastSignal"); } #endif } --- NEW FILE: Condition.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CONDITION_H #define _CONDITION_H #include "Mutex.h" #include "../exceptions/ThreadException.h" #ifdef _WIN32_ /** * For windows users, there isn't such a * pthread_cond_t object to handle. * Thanks to Marc Parizeau for his help and * D.C. Schmidt and Irfan Pyarali for their * pthread_cond_t implementation. */ #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #endif #include <windows.h> typedef struct { // Number of threads waiting for the condition int nb_waiting; // is it a broadcast signal ? bool broadcast; // A critical section for protecting nb_waiting CRITICAL_SECTION waiting_lock; /* A semaphore, used for queueing up waiting threads for condition */ HANDLE semaphore; /* An auto reset event used by the broadcast signal thread to wait for all the waiting threads to wake up */ HANDLE waiters_done; } pthread_cond_t; #else #include <pthread.h> #include <sys/errno.h> #endif /** * Defines a Condition object. * A condition is a mutex that is released when * another thread sends a signal to the condition. All * waiting threads can be released whe the signal sent * is a broadcast signal, or just one of them if * the signal is simple. */ class Condition : public Mutex { protected: // the condition pthread_cond_t *condition; public: /** * Creates a Condition object. */ Condition() throw (ThreadException); /** * Condition destructor */ ~Condition(); /** * Waits for a signal to be sent to the condition. */ void waitForSignal() throw (ThreadException); /** * Sends a simple signal to the condition. */ void sendSignal() throw (ThreadException); /** * Sends a broadcast signal to the condition. */ void sendBroadcastSignal() throw (ThreadException); }; #endif |
From: <mik...@us...> - 2003-12-24 11:04:50
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web In directory sc8-pr-cvs1:/tmp/cvs-serv14544 Added Files: .project .cdtbuild .cdtproject Log Message: 24/12/2003 Mikael Barbeaux * Added Eclipse project files --- NEW FILE: .project --- <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>ui-web</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.cdt.core.cnature</nature> <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> <nature>org.eclipse.cdt.core.ccnature</nature> </natures> </projectDescription> --- NEW FILE: .cdtbuild --- <?xml version="1.0" encoding="UTF-8"?> <ManagedProjectBuildInfo> <target artifactName="ui-web" cleanCommand="rm -rf" defaultExtension="" id="ui-web.linux.gnu.exec.274882379" isAbstract="false" isTest="false" name="Linux Executable" parent="linux.gnu.exec"> <configuration id="linux.gnu.exec.release.274882379" name="Release" parent="linux.gnu.exec.release"> <toolReference id="cdt.build.tool.linux.gnu.compiler"> <optionReference defaultValue="Optimize most (-O3)" id="linux.gnu.compiler.optimization.level"/> <optionReference defaultValue="None" id="linux.gnu.compiler.debugging.level"/> <optionReference defaultValue="false" id="linux.gnu.compiler.warnings.toerrors"/> <optionReference defaultValue="true" id="linux.gnu.compiler.warnings.allwarn"/> <optionReference defaultValue="true" id="linux.gnu.compiler.warnings.pedantic"/> <optionReference id="linux.gnu.compiler.preprocessor.def"> <listOptionValue builtIn="false" value="_LINUX_"/> </optionReference> <optionReference defaultValue="-march=athlon-xp" id="linux.compiler.optimization.flags"/> <optionReference defaultValue="false" id="linux.gnu.compiler.other.verbose"/> </toolReference> <toolReference id="cdt.build.tool.linux.gnu.c.compiler"> <optionReference defaultValue="Optimize most (-O3)" id="linux.gnu.c.compiler.general.optimization.level"/> <optionReference defaultValue="None" id="linux.c.compiler.debugging.level"/> </toolReference> </configuration> <configuration id="linux.gnu.exec.debug.872073189" name="Debug" parent="linux.gnu.exec.debug"> <toolReference id="cdt.build.tool.linux.gnu.compiler"> <optionReference defaultValue="None (-O0)" id="linux.gnu.compiler.optimization.level"/> <optionReference defaultValue="Maximum (-g3)" id="linux.gnu.compiler.debugging.level"/> </toolReference> <toolReference id="cdt.build.tool.linux.gnu.c.compiler"> <optionReference defaultValue="None (-O0)" id="linux.gnu.c.compiler.general.optimization.level"/> <optionReference defaultValue="Maximum (-g3)" id="linux.c.compiler.debugging.level"/> </toolReference> </configuration> </target> <defaultConfig id="linux.gnu.exec.release.274882379"/> <defaultTarget id="ui-web.linux.gnu.exec.274882379"/> </ManagedProjectBuildInfo> --- NEW FILE: .cdtproject --- <?xml version="1.0" encoding="UTF-8"?> <cdtproject id="org.eclipse.cdt.make.core.make"> <extension id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager" point="org.eclipse.cdt.core.ScannerInfoProvider"/> <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> </cdtproject> |
From: <mik...@us...> - 2003-12-24 10:49:52
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/test In directory sc8-pr-cvs1:/tmp/cvs-serv11724/src/test Added Files: TestException.cpp TestException.h TestHandler.cpp TestHandler.h Log Message: 24/12/2003 Barbeaux * Implemented a basic Main program. * Implemented generic Test handler. * Implemented generic Exception handler. * Started first revision of the project. --- NEW FILE: TestException.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "TestException.h" #include "../exceptions/ThreadException.h" #include <iostream> using namespace std; /** * Creates a TestException object. */ TestException::TestException() : TestHandler() { } /** * Runs the tester. */ void TestException::run() { /** This test tries to launch an exception * and to catch it. Then it displays the message * sent by the exception before exiting. */ cout << "Start of TestException" <<endl; try { cout << " Create a ThreadException" << endl; ThreadError error = MutexError; ThreadException excp(error,"Mutex isn't initialized"); cout << " Throws exception" << endl; throw excp; cout << " Exception hasn't been thrown" << endl; } catch(Exception& e) { cout << " Exception catched" << endl; // displays the exception message cout << " " << e.getMessage() << endl; } cout << "End of TestException" << endl; } --- NEW FILE: TestException.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TEST_EXCEPTION_H_ #define _TEST_EXCEPTION_H_ #include "../exceptions/Exception.h" #include "TestHandler.h" /** * Defines a Test handler for testing exceptions objects. * Implements the TestHandler object and tests exceptions. */ class TestException : public TestHandler { public: /** * Creates an object for testing an exception handler. */ TestException(); /** * Runs the tester. */ virtual void run(); }; #endif --- NEW FILE: TestHandler.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "TestHandler.h" /** * Creates a TestHandler object. * Does nothing... */ TestHandler::TestHandler() { } /** * TestHandler destructor * Does nothing... */ TestHandler::~TestHandler() { } --- NEW FILE: TestHandler.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TEST_HANDLER_H_ #define _TEST_HANDLER_H_ /** * Defines a generic object for making test units. * If you want to create your own test class, you need to * create a new subclass implementing the run() * method. */ class TestHandler{ public: /** * Creates a TestHandler object. */ TestHandler(); /** * Destructor for TestHandler */ virtual ~TestHandler(); /** * Runs the test * Needs to be implemented into subclasses. */ virtual void run() = 0; }; #endif |
Update of /cvsroot/sharedaemon/sharedaemon-ui-web In directory sc8-pr-cvs1:/tmp/cvs-serv11724 Added Files: AUTHORS COPYING ChangeLog INSTALL Makefile.bsd Makefile.lin Makefile.osx Makefile.win README TODO Log Message: 24/12/2003 Barbeaux * Implemented a basic Main program. * Implemented generic Test handler. * Implemented generic Exception handler. * Started first revision of the project. --- NEW FILE: AUTHORS --- ShareDaemon Standard webInterface Authors Original code author: Mikael Barbeaux <mik...@us...> --- NEW FILE: COPYING --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS --- NEW FILE: ChangeLog --- Changelog for ShareDaemon webInterface ----------------------------------------------------------- Notice about ShareDaemon webInterface Changelog usage and formatting. Please use ONLY the following formatting in this Changelog: @DATE @PERSON * @CHANGE @DATE is date of commiting to CVS (changes that are not commited to CVS should NEVER be added to Changelog). Local time is ok. @PERSON is the full REAL name of the one commiting to CVS (not necceserely the code author). If you wish to add your nick/handle, add it after your name in parenthesis. @CHANGE is a short description of the modification done. If you are not the author of parts/all of the code, add note about the original author in parenthesis. ALWAYS keep line lenghts UNDER/AT 80 characters. ALL ChangeLog entries end with a dot ----------------------------------------------------------- 24/12/2003 Barbeaux * Implemented a basic Main program. * Implemented generic Test handler. * Implemented generic Exception handler. * Started first revision of the project. --- NEW FILE: INSTALL --- INSTALLATION NOTES --- NEW FILE: Makefile.bsd --- # Simple Makefile # Author : Mikael Barbeaux ###################################################### # Edit thoses variables for suiting to your computer # ###################################################### # Your flags from the C++ compiler CCFLAGS = -O3 -march=athlon-xp # Do you want debugging ? #CCFLAGS += -D_DEBUG_INFO_ # Name of the binary BIN = ui-web-std ############################################# # # # DO NOT CHANGE ANYTHING FROM THIS POINT # # # ############################################# CCFLAGS += -D_LINUX_ -g -Wall MAKE = make CC = g++ RM = rm STRIP = strip LIBS = -pthread OBJECTS = src/exceptions/Exception.o \ src/exceptions/ThreadException.o \ src/test/TestHandler.o \ src/test/TestException.o \ src/Main.o $(BIN) : $(OBJECTS) $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) %.o : %.cpp $(CC) $(CCFLAGS) -o $@ -c $< all : $(BIN) strip: $(STRIP) $(BIN) .PHONY : clean clean : $(RM) -f $(BIN) $(OBJECTS) --- NEW FILE: Makefile.lin --- # Simple Makefile # Author : Mikael Barbeaux # Edit thoses variables for suiting to your computer # Your flags from the C++ compiler CCFLAGS = -O3 -march=athlon-xp # Do you want debugging ? #CCFLAGS += -D_DEBUG_INFO_ # Name of the binary BIN = ui-web-std # !!!!! # DO NOT CHANGE ANYTHING FROM THIS POINT # !!!!! CCFLAGS += -D_LINUX_ -g -Wall -pedantic MAKE = make CC = g++ RM = rm STRIP = strip LIBS = -lpthread OBJECTS = src/exceptions/Exception.o \ src/exceptions/ThreadException.o \ src/test/TestHandler.o \ src/test/TestException.o \ src/Main.o $(BIN) : $(OBJECTS) $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) %.o : %.cpp $(CC) $(CCFLAGS) -o $@ -c $< all : $(BIN) strip: $(STRIP) $(BIN) .PHONY : clean clean : $(RM) -f $(BIN) $(OBJECTS) --- NEW FILE: Makefile.osx --- # Simple Makefile # Author : Mikael Barbeaux ###################################################### # Edit thoses variables for suiting to your computer # ###################################################### # Your flags from the C++ compiler CCFLAGS = -O3 -march=athlon-xp # Do you want debugging ? #CCFLAGS += -D_DEBUG_INFO_ # Name of the binary BIN = ui-web-std ############################################# # # # DO NOT CHANGE ANYTHING FROM THIS POINT # # # ############################################# CCFLAGS += -D_MACOSX_ -g -Wall MAKE = make CC = g++ RM = rm STRIP = strip LIBS = -lpthread OBJECTS = src/exceptions/Exception.o \ src/exceptions/ThreadException.o \ src/test/TestHandler.o \ src/test/TestException.o \ src/Main.o $(BIN) : $(OBJECTS) $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBS) %.o : %.cpp $(CC) $(CCFLAGS) -o $@ -c $< all : $(BIN) strip: $(STRIP) $(BIN) .PHONY : clean clean : $(RM) -f $(BIN) $(OBJECTS) --- NEW FILE: Makefile.win --- # Simple Makefile # Author : Mikael Barbeaux ###################################################### # Edit thoses variables for suiting to your computer # ###################################################### # MinGW direcoty MINGW_DIR = G:/Dev-Cpp # Your flags from the C++ compiler CCFLAGS = -O3 -march=athlon-xp # Do you want debugging ? #CCFLAGS += -D_DEBUG_INFO_ # Name of the binary BIN = ui-web-std.exe ############################################# # # # DO NOT CHANGE ANYTHING FROM THIS POINT # # # ############################################# CCFLAGS += -D_WIN32_ -g -Wall MAKE = $(MINGW_DIR)/bin/make.exe CC = $(MINGW_DIR)/bin/g++.exe RM = $(MINGW_DIR)/bin/rm.exe STRIP = $(MINGW_DIR)/bin/strip.exe INCLUDE_DIRS = -I"$(MINGW_DIR)/include/c++" -I"$(MINGW_DIR)/include/c++/mingw32" INLUCDE_DIRS += -I"$(MINGW_DIR)/include/c++/backward" -I"$(MINGW_DIR)/include" LIBRARIES_DIR = -L"$(MINGW_DIR)/lib" LIBS = -L"$(MINGW_DIR)/lib" $(MINGW_DIR)/lib/libws2_32.a # $(MINGW_DIR)/lib/libpthreadGCE.a OBJECTS = src/exceptions/Exception.o \ src/exceptions/ThreadException.o \ src/test/TestHandler.o \ src/test/TestException.o \ src/Main.o $(BIN) : $(OBJECTS) $(CC) $(CCFLAGS) -o $(BIN) $(OBJECTS) $(LIBRARIES_DIR) $(LIBS) %.o : %.cpp $(CC) $(CCFLAGS) $(INCLUDE_DIRS) -o $@ -c $< all : $(BIN) strip: $(STRIP) $(BIN) .PHONY : clean clean : $(RM) -f $(BIN) $(OBJECTS) --- NEW FILE: README --- --- NEW FILE: TODO --- |
From: <mik...@us...> - 2003-12-24 10:49:51
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions In directory sc8-pr-cvs1:/tmp/cvs-serv11724/src/exceptions Added Files: Exception.cpp Exception.h ThreadException.cpp ThreadException.h Log Message: 24/12/2003 Barbeaux * Implemented a basic Main program. * Implemented generic Test handler. * Implemented generic Exception handler. * Started first revision of the project. --- NEW FILE: Exception.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Exception.h" /** * Creates a Exception object with the given code and * message. */ Exception::Exception(int eCode, const string& message) : runtime_error(message), code(eCode) { } /** * Returns the code number of this exception. */ int Exception::getErrorCode() const { return code; } --- NEW FILE: Exception.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _EXCEPTION_H_ #define _EXCEPTION_H_ #include <string> #include <stdexcept> using namespace std; /** * Defines a generic Exception object for handling * exceptions into the program. * */ class Exception : public runtime_error { protected: // code of this exception int code; public: /** * Creates a Exception object. * * @param eCode - code number of this exception * @param message - A message to explain this exception */ explicit Exception(int eCode, const string& message); /** * Returns the error code of this exception * * @return int */ int getErrorCode() const; /** * Returns the message sent with this exception * * @return const string */ virtual const string getMessage() const = 0; }; #endif --- NEW FILE: ThreadException.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "ThreadException.h" #include <sstream> using namespace std; /** * Creates a ThreadException object with the given error code and * message. */ ThreadException::ThreadException(ThreadError eCode, const string& message) : Exception(eCode, message) { } /** * Returns the message sent by this exception, depending the * error code sent. */ const string ThreadException::getMessage() const { ostringstream message; // Build error message depending error code switch(code) { case MutexError: message << "MutexError"; break; default: message << "UnknownError"; break; } message << ": "; message << what(); return message.str(); } --- NEW FILE: ThreadException.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _THREAD_EXCEPTION_H_ #define _THREAD_EXCEPTION_H_ #include "Exception.h" enum ThreadError { MutexError }; /** * Defines a Exception for handling threading errors. */ class ThreadException : public Exception { public: /** * Creates a Thread exception handler. * * @param eCode - code of this exception * @param message - Message to send to this exception */ ThreadException(ThreadError eCode, const string& message); /** * Returns the message sent by this Thread exception. * * @return const string */ virtual const string getMessage() const; }; #endif |
From: <mik...@us...> - 2003-12-24 10:49:51
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src In directory sc8-pr-cvs1:/tmp/cvs-serv11724/src Added Files: Main.cpp Log Message: 24/12/2003 Barbeaux * Implemented a basic Main program. * Implemented generic Test handler. * Implemented generic Exception handler. * Started first revision of the project. --- NEW FILE: Main.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "test/TestException.h" /** * Main program. */ int main() { TestException test; test.run(); return 0; } |
From: <mik...@us...> - 2003-12-24 10:46:43
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread In directory sc8-pr-cvs1:/tmp/cvs-serv11279/thread Log Message: Directory /cvsroot/sharedaemon/sharedaemon-ui-web/src/thread added to the repository |
From: <mik...@us...> - 2003-12-24 10:46:43
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/test In directory sc8-pr-cvs1:/tmp/cvs-serv11279/test Log Message: Directory /cvsroot/sharedaemon/sharedaemon-ui-web/src/test added to the repository |
From: <mik...@us...> - 2003-12-24 10:46:42
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions In directory sc8-pr-cvs1:/tmp/cvs-serv11279/exceptions Log Message: Directory /cvsroot/sharedaemon/sharedaemon-ui-web/src/exceptions added to the repository |
From: <mik...@us...> - 2003-12-24 10:46:19
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src In directory sc8-pr-cvs1:/tmp/cvs-serv11236/src Log Message: Directory /cvsroot/sharedaemon/sharedaemon-ui-web/src added to the repository |
From: <ma...@us...> - 2003-12-24 10:07:50
|
Update of /cvsroot/sharedaemon/ui-wx/src In directory sc8-pr-cvs1:/tmp/cvs-serv5853 Modified Files: MBitmapButton.h Log Message: Fixes bitmapbutton for Mandrake, SuSE and RedHat. However, probably breaks for \"Classical\" controls that Slackware, Debian and others use :( Index: MBitmapButton.h =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/MBitmapButton.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- MBitmapButton.h 24 Dec 2003 07:34:10 -0000 1.4 +++ MBitmapButton.h 24 Dec 2003 10:07:46 -0000 1.5 @@ -39,9 +39,9 @@ #define LABEL_WIDTH_ADDITION 10 /* Extra width */ #define BITMAP_Y_POS_OFFSET 0 /* Text Y positioning offset */ #define TEXT_Y_POS_OFFSET 0 /* Text Y positioning offset */ - #define LABEL_POS_OFFSET -6 /* Pixels between image/button borders */ - #define BTN_FONT_SIZE 12 /* Button font size */ -#elif !defined (__WXMSW__) + #define LABEL_POS_OFFSET -8 /* Pixels between image/button borders */ + #define BTN_FONT_SIZE 12 /* Button font size */ +#elif !defined (__WXMSW__) #error Need MBitmapButton constants for your port. #endif |
From: <ma...@us...> - 2003-12-24 07:37:30
|
Update of /cvsroot/sharedaemon/ui-wx/src In directory sc8-pr-cvs1:/tmp/cvs-serv18575 Modified Files: wxInterface.cpp MainDlg.cpp Log Message: Minor debugging messages to stderr Index: wxInterface.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/wxInterface.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- wxInterface.cpp 23 Dec 2003 23:38:25 -0000 1.12 +++ wxInterface.cpp 24 Dec 2003 07:37:26 -0000 1.13 @@ -48,6 +48,7 @@ bool wxInterface::OnInit() { int show_splash = true; mainframe_active = false; + wxLog::SetActiveTarget(new wxLogStderr()); SetVendorName(wxT("ShareDaemon")); SetAppName(wxT("wxInterface")); Index: MainDlg.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- MainDlg.cpp 23 Dec 2003 00:40:50 -0000 1.36 +++ MainDlg.cpp 24 Dec 2003 07:37:26 -0000 1.37 @@ -250,7 +250,10 @@ return false; /* Nothing to show */ } else if (cur_page->short_title == to_show) { return false; /* Already shown */ + } else if (pages.Find(to_show) == NULL) { + return false; /* Not found */ } + wxLogDebug(wxT("Setting active page to `%s`"), to_show.c_str()); Page *new_page = pages.Find(to_show)->GetData(); if (new_page == NULL) { wxFAIL_MSG(wxString::Format( @@ -994,6 +997,11 @@ wxFAIL_MSG(wxT("Empty page passed for adding!")); return; } + wxLogDebug( + wxT("%s,%d: Adding page `%s` with title `%s`, image `%s`."), + wxString(__FILE__).c_str(), __LINE__, short_title.c_str(), + long_title.c_str(), image.c_str() + ); Page *newpage = new Page; newpage->content = page; newpage->short_title = short_title; |
From: <ma...@us...> - 2003-12-24 07:36:48
|
Update of /cvsroot/sharedaemon/ui-wx/src In directory sc8-pr-cvs1:/tmp/cvs-serv18480 Modified Files: SBPanel.cpp Log Message: Sidebar now resizes correctly according to largest open section width. Index: SBPanel.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/SBPanel.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- SBPanel.cpp 22 Dec 2003 12:06:23 -0000 1.12 +++ SBPanel.cpp 24 Dec 2003 07:36:46 -0000 1.13 @@ -116,7 +116,8 @@ mainsizer->Show(content); shown = true; } - GetParent()->Layout(); + GetParent()->Fit(); + GetParent()->GetParent()->Fit(); wxGetTopLevelParent(this)->Layout(); } |
From: <ma...@us...> - 2003-12-24 07:34:13
|
Update of /cvsroot/sharedaemon/ui-wx/src In directory sc8-pr-cvs1:/tmp/cvs-serv18188 Modified Files: MBitmapButton.cpp MBitmapButton.h Log Message: Bitmapbutton now works at least bearably on wxMSW Index: MBitmapButton.cpp =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/MBitmapButton.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- MBitmapButton.cpp 23 Dec 2003 00:41:40 -0000 1.6 +++ MBitmapButton.cpp 24 Dec 2003 07:34:10 -0000 1.7 @@ -59,7 +59,7 @@ this, 1000, image, wxDefaultPosition, wxSize(image.GetWidth(), image.GetHeight()), 5, imgname ); - s_main->Add(img, 0, wxLEFT|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 5); + s_main->Add(img, 0, wxALL, 5); /** * Dirty trick: @@ -70,7 +70,7 @@ wxDefaultSize, wxTRANSPARENT_WINDOW ); txt->Hide(); - s_main->Add(txt, 1, wxALL|wxADJUST_MINSIZE, 5); + s_main->Add(txt, 1, wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 15); SetSizer(s_main); SetAutoLayout(true); Index: MBitmapButton.h =================================================================== RCS file: /cvsroot/sharedaemon/ui-wx/src/MBitmapButton.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- MBitmapButton.h 23 Dec 2003 00:41:40 -0000 1.3 +++ MBitmapButton.h 24 Dec 2003 07:34:10 -0000 1.4 @@ -40,7 +40,9 @@ #define BITMAP_Y_POS_OFFSET 0 /* Text Y positioning offset */ #define TEXT_Y_POS_OFFSET 0 /* Text Y positioning offset */ #define LABEL_POS_OFFSET -6 /* Pixels between image/button borders */ - #define BTN_FONT_SIZE 12 /* Button font size */ + #define BTN_FONT_SIZE 12 /* Button font size */ +#elif !defined (__WXMSW__) + #error Need MBitmapButton constants for your port. #endif |