certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi libCERTI/SocketSHM.hh libCERTI/RingBuffer...


From: certi-cvs
Subject: [certi-cvs] certi libCERTI/SocketSHM.hh libCERTI/RingBuffer...
Date: Sun, 28 Mar 2010 11:42:35 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Eric NOULARD <erk>      10/03/28 11:42:35

Modified files:
        libCERTI       : SocketSHM.hh RingBuffer.cc SocketSHMPosix.hh 
                         SocketSHMSysV.cc SocketSHM.cc RingBuffer.hh 
                         CMakeLists.txt SocketSHMPosix.cc 
        libHLA         : CMakeLists.txt 
        test/utility   : CMakeLists.txt 
Added files:
        libHLA         : SHMWin32.hh SHMSysV.cc SHMWin32.cc SHM.hh 
                         SHMSysV.hh SemaphorePosix.hh SHMPosix.cc 
                         SemaphoreSysV.cc Semaphore.hh SemaphorePosix.cc 
                         SHMPosix.hh SemaphoreWin32.hh SemaphoreWin32.cc 
                         SemaphoreSysV.hh 
Removed files:
        libCERTI       : SHMWin32.hh SHMSysV.hh SemaphorePosix.hh 
                         SemaphoreSysV.hh SHMPosix.hh Semaphore.hh 
                         SHM.hh SemaphoreWin32.hh SHMPosix.cc SHMSysV.cc 
                         SHMWin32.cc SemaphorePosix.cc SemaphoreSysV.cc 
                         SemaphoreWin32.cc 

Log message:
        Move SHM and Semaphore basic classes to libHLA

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHM.hh?cvsroot=certi&r1=3.1&r2=3.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/RingBuffer.cc?cvsroot=certi&r1=3.1&r2=3.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHMPosix.hh?cvsroot=certi&r1=3.1&r2=3.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHMSysV.cc?cvsroot=certi&r1=3.1&r2=3.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHM.cc?cvsroot=certi&r1=3.1&r2=3.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/RingBuffer.hh?cvsroot=certi&r1=3.1&r2=3.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/CMakeLists.txt?cvsroot=certi&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHMPosix.cc?cvsroot=certi&r1=3.1&r2=3.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SHMWin32.hh?cvsroot=certi&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SHMSysV.hh?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SemaphorePosix.hh?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SemaphoreSysV.hh?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SHMPosix.hh?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Semaphore.hh?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SHM.hh?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SemaphoreWin32.hh?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SHMPosix.cc?cvsroot=certi&r1=3.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SHMSysV.cc?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SHMWin32.cc?cvsroot=certi&r1=1.3&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SemaphorePosix.cc?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SemaphoreSysV.cc?cvsroot=certi&r1=3.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SemaphoreWin32.cc?cvsroot=certi&r1=3.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/CMakeLists.txt?cvsroot=certi&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SHMWin32.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SHMSysV.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SHMWin32.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SHM.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SHMSysV.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SemaphorePosix.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SHMPosix.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SemaphoreSysV.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/Semaphore.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SemaphorePosix.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SHMPosix.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SemaphoreWin32.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SemaphoreWin32.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/SemaphoreSysV.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/test/utility/CMakeLists.txt?cvsroot=certi&r1=1.5&r2=1.6

Patches:
Index: libCERTI/SocketSHM.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketSHM.hh,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -b -r3.1 -r3.2
--- libCERTI/SocketSHM.hh       16 Jan 2010 20:17:14 -0000      3.1
+++ libCERTI/SocketSHM.hh       28 Mar 2010 11:42:34 -0000      3.2
@@ -2,11 +2,13 @@
 #define SOCKET_SHM_H
 
 #include <iostream>
+// libhla includes
+#include "Semaphore.hh"
+#include "SHM.hh"
 
 // Specifics includes
 #include "certi.hh"
-#include "Semaphore.hh"
-#include "SHM.hh"
+#include "Exception.hh"
 
 class CERTI_EXPORT SocketSHM {
 public :
@@ -36,12 +38,12 @@
     size_t _Size_Side ;
 
     /***** Server -->>> Customer ******/
-    SHM *_Shm_SC ;
-    Semaphore *_Sem_full_SC, *_Sem_empty_SC ;
+    libhla::ipc::SHM *_Shm_SC ;
+    libhla::ipc::Semaphore *_Sem_full_SC, *_Sem_empty_SC ;
 
     /***** Customer -->>> Server ******/
-    SHM *_Shm_CS ;
-    Semaphore *_Sem_full_CS, *_Sem_empty_CS ;
+    libhla::ipc::SHM *_Shm_CS ;
+    libhla::ipc::Semaphore *_Sem_full_CS, *_Sem_empty_CS ;
 
 }; // End of --> class SocketSHM
 

Index: libCERTI/RingBuffer.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/RingBuffer.cc,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -b -r3.1 -r3.2
--- libCERTI/RingBuffer.cc      16 Jan 2010 20:17:14 -0000      3.1
+++ libCERTI/RingBuffer.cc      28 Mar 2010 11:42:34 -0000      3.2
@@ -28,13 +28,22 @@
    #include "SocketSHMWin32.hh"
    #include "SemaphoreWin32.hh"
    #include "SHMWin32.hh"
+using libhla::ipc::SHMWin32;
+using libhla::ipc::SemaphoreWin32;
 #else
    #include "SemaphorePosix.hh"
    #include "SHMPosix.hh"
    #include "SemaphoreSysV.hh"
    #include "SHMSysV.hh"
+using libhla::ipc::SHMPosix;
+using libhla::ipc::SemaphorePosix;
+using libhla::ipc::SHMSysV;
+using libhla::ipc::SemaphoreSysV;
 #endif
 
+using libhla::ipc::SHM;
+using libhla::ipc::Semaphore;
+
 #include "RingBuffer.hh"
 
 RingBuffer::RingBuffer(const std::string& RingBuffer_Name,

Index: libCERTI/SocketSHMPosix.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketSHMPosix.hh,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -b -r3.1 -r3.2
--- libCERTI/SocketSHMPosix.hh  16 Jan 2010 20:17:14 -0000      3.1
+++ libCERTI/SocketSHMPosix.hh  28 Mar 2010 11:42:34 -0000      3.2
@@ -2,13 +2,9 @@
 #define SOCKET_SHM_POSIX_H
 
 // Specifics includes
-#include "SemaphorePosix.hh"
-#include "SHMPosix.hh"
 #include "SocketSHM.hh"
-#include "SHM.hh"
-#include "Semaphore.hh"
 
-class SocketSHMPosix : public SocketSHM {
+class CERTI_EXPORT SocketSHMPosix : public SocketSHM {
 private:   
 
 public :

Index: libCERTI/SocketSHMSysV.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketSHMSysV.cc,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -b -r3.1 -r3.2
--- libCERTI/SocketSHMSysV.cc   16 Jan 2010 20:17:14 -0000      3.1
+++ libCERTI/SocketSHMSysV.cc   28 Mar 2010 11:42:34 -0000      3.2
@@ -1,4 +1,8 @@
 #include "SocketSHMSysV.hh"
+using libhla::ipc::Semaphore;
+using libhla::ipc::SHM;
+using libhla::ipc::SemaphoreSysV;
+using libhla::ipc::SHMSysV;
 
 // ************************************************
 // Constructor with args

Index: libCERTI/SocketSHM.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketSHM.cc,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -b -r3.1 -r3.2
--- libCERTI/SocketSHM.cc       16 Jan 2010 20:17:14 -0000      3.1
+++ libCERTI/SocketSHM.cc       28 Mar 2010 11:42:34 -0000      3.2
@@ -17,7 +17,7 @@
 
 if(_Side == SHM_CS){
     try {
-       _Sem_full_SC->Attach(Semaphore::buildSemName(_Name+"_FULL_SC")) ;
+       
_Sem_full_SC->Attach(libhla::ipc::Semaphore::buildSemName(_Name+"_FULL_SC")) ;
     }
     catch(certi::SharedMemoryNotAttached& e)
     {
@@ -25,7 +25,7 @@
         throw (certi::SocketNotConnected("Connect() failed."));
     }
     try {
-       _Sem_empty_SC->Attach(Semaphore::buildSemName(_Name+"_EMPTY_SC")) ;
+       
_Sem_empty_SC->Attach(libhla::ipc::Semaphore::buildSemName(_Name+"_EMPTY_SC")) ;
     }
     catch(certi::SharedMemoryNotAttached& e)
     {
@@ -35,7 +35,7 @@
   }
 else{
     try {
-       _Sem_full_CS->Attach(Semaphore::buildSemName(_Name+"_FULL_CS")) ;
+       
_Sem_full_CS->Attach(libhla::ipc::Semaphore::buildSemName(_Name+"_FULL_CS")) ;
     }
     catch(certi::SharedMemoryNotAttached& e)
     {
@@ -43,7 +43,7 @@
         throw (certi::SocketNotConnected("Connect() failed."));
     }
     try {
-       _Sem_empty_CS->Attach(Semaphore::buildSemName(_Name+"_EMPTY_CS")) ;
+       
_Sem_empty_CS->Attach(libhla::ipc::Semaphore::buildSemName(_Name+"_EMPTY_CS")) ;
     }
     catch(certi::SharedMemoryNotAttached& e)
     {

Index: libCERTI/RingBuffer.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/RingBuffer.hh,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -b -r3.1 -r3.2
--- libCERTI/RingBuffer.hh      16 Jan 2010 20:17:14 -0000      3.1
+++ libCERTI/RingBuffer.hh      28 Mar 2010 11:42:34 -0000      3.2
@@ -23,6 +23,9 @@
 #include <iostream>
 
 // Specifics includes
+#include "certi.hh"
+#include "Exception.hh"
+#include "libhla.hh"
 #include "SHM.hh"
 #include "Semaphore.hh"
 
@@ -60,20 +63,20 @@
     size_t _Size ;
 
     /***** Server -->>> Customer ******/
-    SHM *_Shm_SC ;
-    SHM *_Pw_Pr_SC ;
+    libhla::ipc::SHM *_Shm_SC ;
+    libhla::ipc::SHM *_Pw_Pr_SC ;
     // _Count_SC, _Write_SC, _Read_SC
     // int _Tab_SC[3] ;
     int* _Tab_SC ;
-    Semaphore *_Sem_SC ;
+    libhla::ipc::Semaphore *_Sem_SC ;
 
     /***** Customer -->>> Server ******/
-    SHM *_Shm_CS ;
-    SHM *_Pw_Pr_CS ;
+    libhla::ipc::SHM *_Shm_CS ;
+    libhla::ipc::SHM *_Pw_Pr_CS ;
     // _Count_CS, _Write_CS, _Read_CS
     // int _Tab_CS[3] ;
     int* _Tab_CS ;
-    Semaphore *_Sem_CS ;
+    libhla::ipc::Semaphore *_Sem_CS ;
 
 }; // End of --> class SocketSHM
 

Index: libCERTI/CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/libCERTI/CMakeLists.txt,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- libCERTI/CMakeLists.txt     21 Mar 2010 17:10:10 -0000      1.32
+++ libCERTI/CMakeLists.txt     28 Mar 2010 11:42:34 -0000      1.33
@@ -102,33 +102,17 @@
 if (WIN32)
     include_directories(${CERTI_SOURCE_DIR}/libHLA)
     ADD_DEFINITIONS(-DDEBUG)
-    SET(CERTI_SHM_SRCS
-        SHM.hh SHMWin32.hh SHMWin32.cc)
-
-    SET(CERTI_SEMAPHORE_SRCS
-        Semaphore.hh SemaphoreWin32.hh SemaphoreWin32.cc)
 
     SET(CERTI_SOCKET_SHM_SRC
         SocketSHM.cc SocketSHM.hh
         SocketSHMWin32.cc SocketSHMWin32.hh
        RingBuffer.cc RingBuffer.hh)
 
-    LIST(APPEND CERTI_SOCKET_SRCS ${CERTI_SHM_SRCS} ${CERTI_SEMAPHORE_SRCS} 
${CERTI_SOCKET_SHM_SRC})
+    LIST(APPEND CERTI_SOCKET_SRCS ${CERTI_SOCKET_SHM_SRC})
 else(WIN32)
     include_directories(${CERTI_SOURCE_DIR}/libHLA)
     ADD_DEFINITIONS(-DDEBUG)
 
-    SET(CERTI_SHM_SRCS
-        SHM.hh
-        SHMPosix.cc SHMPosix.hh
-        SHMSysV.cc SHMSysV.hh)
-
-    SET(CERTI_SEMAPHORE_SRCS
-        Semaphore.hh
-        SemaphorePosix.cc SemaphorePosix.hh
-        SemaphoreSysV.cc SemaphoreSysV.hh
-        )
-
     SET(CERTI_SOCKET_SHM_SRC
         SocketSHM.cc SocketSHM.hh
         SocketSHMPosix.cc SocketSHMPosix.hh
@@ -136,7 +120,7 @@
        RingBuffer.cc RingBuffer.hh
         )
 
-    LIST(APPEND CERTI_SOCKET_SRCS ${CERTI_SHM_SRCS} ${CERTI_SEMAPHORE_SRCS} 
${CERTI_SOCKET_SHM_SRC})
+    LIST(APPEND CERTI_SOCKET_SRCS ${CERTI_SOCKET_SHM_SRC})
 endif(WIN32)
 
 SET(CERTI_SOCKET_SRCS ${CERTI_SOCKET_SRCS} SocketUDP.cc SocketMC.cc 
SocketUN.cc SocketUDP.hh SocketMC.hh SocketUN.hh)

Index: libCERTI/SocketSHMPosix.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketSHMPosix.cc,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -b -r3.1 -r3.2
--- libCERTI/SocketSHMPosix.cc  16 Jan 2010 20:17:14 -0000      3.1
+++ libCERTI/SocketSHMPosix.cc  28 Mar 2010 11:42:34 -0000      3.2
@@ -1,4 +1,11 @@
 #include "SocketSHMPosix.hh"
+#include "SemaphorePosix.hh"
+#include "SHMPosix.hh"
+
+using libhla::ipc::Semaphore;
+using libhla::ipc::SHM;
+using libhla::ipc::SemaphorePosix;
+using libhla::ipc::SHMPosix;
 
 // ************************************************
 // Constructor with args

Index: libHLA/CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/libHLA/CMakeLists.txt,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- libHLA/CMakeLists.txt       21 Mar 2010 17:10:10 -0000      1.6
+++ libHLA/CMakeLists.txt       28 Mar 2010 11:42:34 -0000      1.7
@@ -3,6 +3,7 @@
 SET(LIBHLA_TYPES1516_SRCS
     HLAbuffer.hh HLAbuffer.cc
 )
+SOURCE_GROUP("Source Files\\Types1516" FILES ${LIBHLA_TYPES1516_SRCS})
 
 LIST(APPEND LIBHLA_EXPORTED_INCLUDES 
     HLAtypesIEEE1516.hh
@@ -19,6 +20,8 @@
 LIST(APPEND LIBHLA_EXPORTED_INCLUDES sha1.h)
 set_source_files_properties(sha1.c sha1.h PROPERTIES LANGUAGE "C")
 
+SOURCE_GROUP("Source Files\\Hash" FILES ${LIBHLA_HASH_SRCS})
+
 SET(LIBHLA_CLOCK_SRCS 
     Clock.cc
     ClockFactory.cc)
@@ -44,7 +47,25 @@
    LIST(APPEND LIBHLA_EXPORTED_INCLUDES WinClock.hh WinPerfClock.hh) 
 ENDIF(HAVE_WIN_CLOCK)        
  
-SOURCE_GROUP("Source Files\\Types1516" FILES ${LIBHLA_TYPES1516_SRCS})
+SOURCE_GROUP("Source Files\\Clock" FILES ${LIBHLA_CLOCK_SRCS})
+
+SET(LIBHLA_IPC_SRCS)
+LIST(APPEND LIBHLA_EXPORTED_INCLUDES SHM.hh Semaphore.hh)
+
+IF (WIN32) 
+   LIST(APPEND LIBHLA_IPC_SRCS SHMWin32.cc)
+   LIST(APPEND LIBHLA_IPC_SRCS SemaphoreWin32.cc)          
+   LIST(APPEND LIBHLA_EXPORTED_INCLUDES SHMWin32.hh SemaphoreWin32.hh)
+ELSE (WIN32)
+   LIST(APPEND LIBHLA_IPC_SRCS 
+        SHMPosix.cc SHMSysV.cc
+        SemaphorePosix.cc SemaphoreSysV.cc)        
+   LIST(APPEND LIBHLA_EXPORTED_INCLUDES 
+       SHMPosix.hh SHMSysV.hh 
+       SemaphorePosix.hh SemaphoreSysV.hh)
+ENDIF (WIN32)
+
+SOURCE_GROUP("Source Files\\IPC" FILES ${LIBHLA_IPC_SRCS})
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 
@@ -60,6 +81,7 @@
     ${LIBHLA_TYPES1516_SRCS}    
     ${LIBHLA_HASH_SRCS}    
     ${LIBHLA_CLOCK_SRCS}
+    ${LIBHLA_IPC_SRCS}
     ${LIBHLA_EXPORTED_INCLUDES}
 )
 

Index: test/utility/CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/test/utility/CMakeLists.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- test/utility/CMakeLists.txt 16 Jan 2010 20:17:14 -0000      1.5
+++ test/utility/CMakeLists.txt 28 Mar 2010 11:42:35 -0000      1.6
@@ -1,5 +1,6 @@
 INCLUDE_DIRECTORIES(
   ${CMAKE_SOURCE_DIR}/libCERTI 
+  ${CMAKE_SOURCE_DIR}/libHLA
   )
 
 SET(CertiUtil_SRCS
@@ -19,9 +20,9 @@
 
 ADD_EXECUTABLE(CertiProcessus_A Main_SocketSHM.cc SharedStruct.hh)
 IF(WIN32)
-    TARGET_LINK_LIBRARIES(CertiProcessus_A CERTI)
+    TARGET_LINK_LIBRARIES(CertiProcessus_A CERTI HLA)
 ELSE(WIN32)
-    TARGET_LINK_LIBRARIES(CertiProcessus_A CERTI rt)
+    TARGET_LINK_LIBRARIES(CertiProcessus_A CERTI HLA rt)
 ENDIF(WIN32)
 
 SET_TARGET_PROPERTIES(CertiProcessus_A PROPERTIES COMPILE_FLAGS -DSIDE_SC)
@@ -29,9 +30,9 @@
 ADD_EXECUTABLE(CertiProcessus_B Main_SocketSHM.cc SharedStruct.hh)
 
 IF(WIN32)
-    TARGET_LINK_LIBRARIES(CertiProcessus_B CERTI)
+    TARGET_LINK_LIBRARIES(CertiProcessus_B CERTI HLA)
 ELSE(WIN32)
-    TARGET_LINK_LIBRARIES(CertiProcessus_B CERTI rt)
+    TARGET_LINK_LIBRARIES(CertiProcessus_B CERTI HLA rt)
 ENDIF(WIN32)
 
 SET_TARGET_PROPERTIES(CertiProcessus_B PROPERTIES COMPILE_FLAGS -DSIDE_CS)

Index: libHLA/SHMWin32.hh
===================================================================
RCS file: libHLA/SHMWin32.hh
diff -N libHLA/SHMWin32.hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SHMWin32.hh  28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,29 @@
+#ifndef SHM_WIN32_H
+#define SHM_WIN32_H
+
+// Specifics includes
+#include "SHM.hh"
+
+namespace libhla {
+namespace ipc {
+
+class HLA_EXPORT SHMWin32 : public SHM {
+
+    private :
+        HANDLE _hMapFile ;
+        LPCTSTR _pBuf;
+
+    public :
+    SHMWin32(const std::string& SHMName, const int SHMSize, const bool True) ;
+    SHMWin32(const std::string& SHMName, const int SHMSize) ;
+    ~SHMWin32() ;
+
+    void Open() throw(certi::SharedMemoryNotOpen) ;
+    void Attach() throw(certi::SharedMemoryNotAttached) ;
+    void Close() throw(certi::SharedMemoryNotClosed,
+                       certi::HandleNotClosed);
+
+} ;
+} /* end namespace ipc  */
+} /* end namespace libhla */
+#endif

Index: libHLA/SHMSysV.cc
===================================================================
RCS file: libHLA/SHMSysV.cc
diff -N libHLA/SHMSysV.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SHMSysV.cc   28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,121 @@
+#include "SHMSysV.hh"
+#include "sha1.h"
+
+namespace libhla {
+namespace ipc {
+
+key_t SHMSysV::ntokUser(const char* name, int32_t user_specific_value) {
+
+key_t s_key ;
+int32_t retcode ;
+
+SHA1Context sha ;
+ uint8_t Message_Digest[20] ;
+
+/* We use the first byte of a SHA1 hash of the BBname
+ * unless the algorithm fail.
+ * If SHA1 fail we go back to poor key generation method
+ * using the name length.
+ * In both case we must Xored the key with user_specific in order
+ * to isolate different user from using the same key
+ */
+         
+retcode  = SHA1Reset(&sha) ;
+retcode &= SHA1Input(&sha, (const unsigned char *) name,strlen(name)) ;
+retcode &= SHA1Result(&sha, Message_Digest);
+
+/* SHA 1 NOK back to old poor method */
+if (0 != retcode) {
+   s_key = ((strlen(name) << 16) & 0xFFFF0000) ^ (user_specific_value & 
0x0000FFFF);
+   } 
+else { s_key = (Message_Digest[0]        |
+       (Message_Digest[1] << 8) |
+       (Message_Digest[2] << 16)|
+       (Message_Digest[3] << 24)) ^
+        user_specific_value;
+       }
+       return s_key;
+}
+
+key_t
+SHMSysV::ntok(const char* name) {
+       return SHMSysV::ntokUser(name,getuid());
+        // return SHMSysV::ntokUser(name,1);
+}
+
+
+// ************************************************
+// Constructors with args
+// ************************************************
+SHMSysV::SHMSysV(const std::string& SHMName, const int SHMSize, const bool 
True)  : SHM(SHMName, SHMSize, True) { 
+    _Key = ntok(SHMName.c_str());
+
+#ifdef DEBUG
+std::cout << " Cle produite : " << _Key << std::endl ;
+#endif
+
+    _Id = 0 ;  
+}
+
+SHMSysV::SHMSysV(const std::string& SHMName, const int SHMSize)  : 
SHM(SHMName, SHMSize) { 
+     _Key = ntok(SHMName.c_str());
+
+#ifdef DEBUG
+std::cout << " Cle produite : " << _Key << std::endl ;
+#endif
+
+    _Id = 0 ;  
+}
+
+
+// ************************************************
+// Destructor
+// ************************************************
+SHMSysV::~SHMSysV() {}
+
+// ************************************************
+// Method : SHMSysV::Open()
+// ************************************************
+void SHMSysV::Open() {
+
+if ((_Id = shmget(_Key, (size_t)_Size, IPC_CREAT| 0666 )) < 0){  
+    perror("Error with shmget in SHMSysV::Open()"); 
+    exit(1);
+    } // End of if
+
+} // End of Open()
+
+// ************************************************
+// Method : SHMSysV::Attach()
+// ************************************************
+void SHMSysV::Attach() {
+
+if ( ( _Shm = shmat(_Id, NULL, 0) ) == (void*) -1){
+    perror("Error with shmat() in SHMSysV::Attach() "); 
+    exit(1);
+    } // End of if
+
+} // End of Attach(...)
+
+// ************************************************
+// Method : Close()
+// ************************************************
+void SHMSysV::Close() {
+
+// Close
+if(shmdt(_Shm)){
+        perror("Error with shmdt() in SHMSysV::Close()");
+        exit(1);
+      } // End of if(shmdt(_Shm))
+
+if(_IsCreator){
+// Destroy
+if(shmctl(_Id, IPC_RMID,0)){
+   perror("Error with shmctl() in SHMSysV::Close()");
+   exit(1);
+   } // End of if(shmctl(_Shm_Id, IPC_RMID,0))
+} // End of (_IsServer)
+
+} // End of Close()
+} /* end namespace ipc  */
+} /* end namespace libhla */

Index: libHLA/SHMWin32.cc
===================================================================
RCS file: libHLA/SHMWin32.cc
diff -N libHLA/SHMWin32.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SHMWin32.cc  28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,110 @@
+// SHM useful systems includes
+#include <windows.h>
+#include <conio.h>
+#include <tchar.h>
+
+// Others Systems includes
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <iostream>
+#include <string>
+
+#include "SHMWin32.hh"
+
+namespace libhla {
+namespace ipc {
+// ************************************************
+// Constructor with args
+// ************************************************
+SHMWin32::SHMWin32(const std::string& SHMName, const int SHMSize, const bool 
True)  : SHM(SHMName, SHMSize, True) {
+        _hMapFile = NULL ;
+        _pBuf = NULL ;
+}
+
+SHMWin32::SHMWin32(const std::string& SHMName, const int SHMSize)  : 
SHM(SHMName,SHMSize) {
+        _hMapFile = NULL ;
+        _pBuf = NULL ;
+}
+
+// ************************************************
+// Destructor
+SHMWin32::~SHMWin32() {}
+
+// ************************************************
+// Method : SHMWin32::Open()
+// ************************************************
+void SHMWin32::Open() throw(certi::SharedMemoryNotOpen) {
+
+int ret ;
+
+   _hMapFile = CreateFileMapping(
+                      INVALID_HANDLE_VALUE,                // use paging file
+                      NULL,                                // default security
+                      PAGE_READWRITE,                      // read/write access
+                      (DWORD)0,                                   // max. 
object size
+                      (DWORD)_Size,                        // buffer size
+                      (LPCTSTR)(_Name.c_str()));           // name of mapping 
object
+
+    if (_hMapFile == NULL) {
+        throw(certi::SharedMemoryNotOpen("CreateFileMapping() failed.")) ;
+        }
+
+#ifdef DEBUG
+std::cout <<  "Created shared memory object : " << _Name.c_str() << std::endl ;
+#endif
+
+} // End of Open()
+
+// ************************************************
+// Method : SHMWin32::Attach()
+// ************************************************
+void SHMWin32::Attach() throw(certi::SharedMemoryNotAttached) {
+
+BOOL WINAPI retcode ;
+
+_pBuf = (LPTSTR) MapViewOfFile(_hMapFile,
+                   FILE_MAP_ALL_ACCESS,      // read/write permission
+                   0,
+                   0,
+                   (SIZE_T)(GetSize()));
+
+    if (_pBuf == NULL) {
+        retcode=UnmapViewOfFile((PVOID)_pBuf);
+        CloseHandle(_hMapFile);
+        throw(certi::SharedMemoryNotAttached("MapViewOfFile() failed.")) ;
+    }
+
+    _Shm = (void *) _pBuf ;
+
+} // End of Attach()
+
+// ************************************************
+// Method : SHMWin32::Close()
+// ************************************************
+void SHMWin32::Close() throw(certi::SharedMemoryNotClosed,
+                             certi::HandleNotClosed) {
+
+BOOL WINAPI retcode ;
+
+// Unmap
+   retcode=UnmapViewOfFile((PVOID)_pBuf);
+
+if (retcode == 0) {
+    throw(certi::SharedMemoryNotClosed("UnMapViewOfFile() failed.")) ;
+    }
+
+#ifdef DEBUG
+std::cout <<  "Close SHM (UnmapViewOfFile) : " << _Name.c_str() << std::endl ;
+#endif
+
+// Close handle
+   retcode = CloseHandle(_hMapFile);
+
+if(retcode == 0){
+   throw(certi::HandleNotClosed("CloseHandle() failed.")) ;
+   } // End of if
+
+} // End of Close()
+} /* end namespace ipc  */
+} /* end namespace libhla */

Index: libHLA/SHM.hh
===================================================================
RCS file: libHLA/SHM.hh
diff -N libHLA/SHM.hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SHM.hh       28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,61 @@
+#ifndef SHM_H
+#define SHM_H
+
+#include <string>
+#include "libhla.hh"
+
+namespace libhla {
+namespace ipc {
+
+
+/**
+ * A Shared Memory class.
+ * This class is an abstract base for representing a shared memory
+ * segment. A shared memory segment is identified by its name and
+ * has a size and a creator process.
+ */
+class HLA_EXPORT SHM {
+protected :
+       std::string _Name ;
+       int  _Size ;
+       bool _IsCreator ;
+       void *_Shm ;
+
+public :
+       /**
+        * Constructor.
+        * @param[in] SHNName, the name of the shared memory segment.
+        *            this should be unique on a specified host.
+        * @param[in] SHMSize, the requested size of the SHM
+        */
+       SHM(const std::string& SHMName, const int SHMSize, const bool True)
+               {_Name=SHMName;
+                _Size=SHMSize;
+                _IsCreator=True;
+                }
+       SHM(const std::string& SHMName, const int SHMSize)
+               {_Name=SHMName;
+                _Size=SHMSize;
+                _IsCreator=false;
+                }
+       virtual ~SHM() {};
+       const std::string getName() const {return _Name ; } ;
+       inline void* GetShm(){return _Shm ; } ;
+       inline bool IsCreator(){return _IsCreator ; } ;
+       inline int GetSize(){return _Size ; } ;
+       virtual void Open() = 0 ;
+       virtual void Attach() = 0 ;
+       virtual void Close() = 0 ;
+
+        /**
+        * Build a proper SHM name from a user provided name.
+        * Idea kindly borrowed from TSP (https://savannah.nongnu.org)
+        * bb_utils_build_shm_name
+        */
+       static std::string buildShmName(const std::string& ShmName) {
+         return "/"+ShmName+"_shm";
+       }
+} ;
+} /* end namespace ipc  */
+} /* end namespace libhla */
+#endif

Index: libHLA/SHMSysV.hh
===================================================================
RCS file: libHLA/SHMSysV.hh
diff -N libHLA/SHMSysV.hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SHMSysV.hh   28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,73 @@
+#ifndef SHM_SYSV_H
+#define SHM_SYSV_H
+
+// SHMs useful systems includes
+#include <sys/types.h>
+#include <sys/ipc.h> 
+#include <sys/shm.h>
+
+// Others systems includes
+#include <fcntl.h>
+#include <math.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <iostream>
+#include <string.h>
+
+// Specifics includes
+#include "SHM.hh"
+
+namespace libhla {
+namespace ipc {
+
+class HLA_EXPORT SHMSysV : public SHM {
+
+    private :
+    int _Id ;  
+    key_t _Key ; 
+   
+    public :
+    SHMSysV(const std::string& SHMName, const int SHMSize, const bool True) ;
+    SHMSysV(const std::string& SHMName, const int SHMSize) ;  
+    ~SHMSysV() ;
+    void Open() ;
+    void Attach() ;
+    void Close() ;
+
+        /**
+     * Build a SysV IPC key from a name and user specific value.
+     * The purpose of this function is to build a (quasi) unique
+     * key from unique entry as ftok(3) do with existing file name.
+     * We use SHA1 hash function Xored with the user_specific
+     * value supplied.
+     * @param[in] name, the name representing the IPC element for which
+     *                 we want a key.
+     * @param[in] user_specific_value, any user specific value
+     *                               (for example uid).
+     * @return The generated SysV IPC key corresponding to the specified entry
+     */
+    key_t
+    static ntokUser(const char* name, int32_t user_specific_value);
+
+    /**
+     * Build a SysV IPC key from a name.
+     * L'objectif de cette fonction est de generer des
+     * clefs differentes pour des noms differents, a la maniere
+     * d'une fonction de hachage ou checksum parfaite.
+     * Cette fonction vise les meme objectifs que ftok(3)
+     * avec les noms de fichiers mais avec une chaine
+     * de caractere quelconque.
+     * @param name un nom representant l'element IPC pour lequel on
+     *                veut generer une clef.
+     * @return SysV IPC key corresponding to the specified name.
+     */
+    key_t
+    static ntok(const char* name);
+
+
+} ;
+
+} /* end namespace ipc  */
+} /* end namespace libhla */
+#endif

Index: libHLA/SemaphorePosix.hh
===================================================================
RCS file: libHLA/SemaphorePosix.hh
diff -N libHLA/SemaphorePosix.hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SemaphorePosix.hh    28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,41 @@
+#ifndef SEMAPHORE_POSIX_H
+#define SEMAPHORE_POSIX_H
+
+// Posix Semaphores systems includes
+// Don't forget to add "-lrt" to compilation line
+#include <sys/types.h>
+#include <Semaphore.hh>
+#include <fcntl.h>
+
+// Others Systems includes
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+
+// Specifics includes
+#include "Semaphore.hh"
+#include <semaphore.h>
+
+namespace libhla {
+namespace ipc {
+
+class HLA_EXPORT SemaphorePosix : public Semaphore {
+    private :
+    std::string _Semname ;
+    sem_t *_Sem ;
+
+    public :
+    SemaphorePosix() ;
+    virtual ~SemaphorePosix() ;
+    void Create_Init(const int initval, const std::string& New_Semname ) ;
+    void Attach(const std::string& New_Semname ) ;
+    void P() ;
+    void V() ;
+    void Delete() ;
+
+} ;
+} /* end namespace ipc  */
+} /* end namespace libhla */
+#endif

Index: libHLA/SHMPosix.cc
===================================================================
RCS file: libHLA/SHMPosix.cc
diff -N libHLA/SHMPosix.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SHMPosix.cc  28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,121 @@
+// SHM useful systems includes
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+// Others Systems includes
+#include <math.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <iostream>
+#include <string.h>
+
+#include "SHMPosix.hh"
+namespace libhla {
+namespace ipc {
+// ************************************************
+// Constructor with args
+// ************************************************
+SHMPosix::SHMPosix(const std::string& SHMName, const int SHMSize, const bool 
True)  : SHM(SHMName, SHMSize, True) { 
+    _Id = 0 ;  
+}
+
+SHMPosix::SHMPosix(const std::string& SHMName, const int SHMSize)  : 
SHM(SHMName,SHMSize) { 
+    _Id = 0 ;  
+}
+
+// ************************************************
+// Destructor
+SHMPosix::~SHMPosix() {}
+
+// ************************************************
+// Method : SHMPosix::Open()
+// ************************************************
+void SHMPosix::Open() {
+
+int ret ;
+
+ if (IsCreator()){
+    ret = shm_unlink(_Name.c_str());
+    _Id = shm_open(_Name.c_str(), O_CREAT | O_EXCL | O_RDWR , S_IRWXU | 
S_IRWXG);
+    if (_Id < 0) {
+        perror("Error with shm_open() in SHMPosix::Open()");
+        exit(1);
+        }
+#ifdef DEBUG
+std::cout <<  "Created shared memory object : " << _Name.c_str() << std::endl ;
+#endif
+
+    ret = ftruncate(_Id, _Size);
+     if (ret < 0) {
+        perror("In ftruncate()");
+        exit(1);
+        }
+
+ } // End of if IsCreator()
+ else{
+    _Id = shm_open(_Name.c_str(), O_RDONLY, S_IRWXU | S_IRWXG);
+    if (_Id < 0) {
+        perror("Error with shm_open() in SHMPosix::Open()");
+        exit(1);
+        }
+#ifdef DEBUG
+std::cout <<  "Attach shared memory object : " << _Name.c_str() << std::endl ;
+#endif
+ } // End of else IsCreator()
+
+} // End of Open()
+
+// ************************************************
+// Method : SHMPosix::Attach()
+// ************************************************
+void SHMPosix::Attach() {
+
+if (IsCreator()){
+    /* requesting the shared segment for write    --  mmap() */    
+    _Shm = mmap(NULL, _Size, PROT_READ | PROT_WRITE , MAP_SHARED, _Id, 0);
+    if (_Shm == NULL) {
+        perror("Error with mmap() in SHMPosix::Attach() ");
+        exit(1);}
+    if (_Shm == MAP_FAILED) {
+        perror("Error with mmap() in SHMPosix::Attach() ");
+        exit(1);}
+    close(_Id) ;
+} // End of IsServer
+else{
+ /* requesting the shared segment for write    --  mmap() */    
+    _Shm = mmap(NULL, _Size, PROT_READ , MAP_SHARED, _Id, 0);
+    if (_Shm == NULL) {
+        perror("Error with mmap() in SHMPosix::Attach() ");
+        exit(1);}
+    if (_Shm == MAP_FAILED) {
+        perror("Error with mmap() in SHMPosix::Attach() ");
+        exit(1);}
+    close(_Id) ;
+} // End of else (IsServer)
+} // End of Attach()
+
+// ************************************************
+// Method : SHMPosix::Close()
+// ************************************************
+void SHMPosix::Close() {
+
+// Close
+if (shm_unlink(_Name.c_str()) != 0) {
+    perror("Error with shm_unlink() in SHMPosix::Close() ");
+    exit(1);
+    }
+
+// Destroy
+if (IsCreator()){
+if(munmap(_Shm, _Size)){
+   perror("Error with munmap() in SHMPosix::Close() ");
+   exit(1);
+   } // End of if
+}
+
+} // End of Close()
+} /* end namespace ipc  */
+} /* end namespace libhla */

Index: libHLA/SemaphoreSysV.cc
===================================================================
RCS file: libHLA/SemaphoreSysV.cc
diff -N libHLA/SemaphoreSysV.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SemaphoreSysV.cc     28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,180 @@
+#include "SemaphoreSysV.hh"
+#include "sha1.h"
+#include <cstring>
+#include <cstdio>
+
+namespace libhla {
+namespace ipc {
+
+key_t SemaphoreSysV::ntokUser(const char* name, int32_t user_specific_value) {
+
+key_t s_key ;
+int32_t retcode ;
+
+SHA1Context sha ;
+ uint8_t Message_Digest[20] ;
+
+/* We use the first byte of a SHA1 hash of the BBname
+ * unless the algorithm fail.
+ * If SHA1 fail we go back to poor key generation method
+ * using the name length.
+ * In both case we must Xored the key with user_specific in order
+ * to isolate different user from using the same key
+ */
+         
+retcode  = SHA1Reset(&sha) ;
+retcode &= SHA1Input(&sha, (const unsigned char *) name,strlen(name)) ;
+retcode &= SHA1Result(&sha, Message_Digest);
+
+/* SHA 1 NOK back to old poor method */
+if (0 != retcode) {
+   s_key = ((strlen(name) << 16) & 0xFFFF0000) ^ (user_specific_value & 
0x0000FFFF);
+   } 
+else { s_key = (Message_Digest[0]        |
+       (Message_Digest[1] << 8) |
+       (Message_Digest[2] << 16)|
+       (Message_Digest[3] << 24)) ^
+        user_specific_value;
+       }
+       return s_key;
+}
+
+key_t SemaphoreSysV::ntok(const char* name) {
+       return SemaphoreSysV::ntokUser(name,getuid());
+        // return SemaphoreSysV::ntokUser(name,1);
+
+}
+// ************************************************
+// Constructor
+// ************************************************
+SemaphoreSysV::SemaphoreSysV(){
+_Sem_Id = 0 ;
+_Sem_Key = 0 ;
+}
+
+// ************************************************
+// Destructor
+// ************************************************
+SemaphoreSysV::~SemaphoreSysV() {}
+
+// ************************************************
+// Method : SemaphoreSysV::Create_Init(...)
+// ************************************************
+void SemaphoreSysV::Create_Init(const int initval, const std::string& 
New_Semname) {
+
+ _Sem_Key = ntok(New_Semname.c_str()) ;
+ _Sem_Id = semget(_Sem_Key,1,IPC_CREAT |0666);
+ if (_Sem_Id == -1){
+      perror("Error with semget() in SemaphoreSysV::Create_Init(...)") ;
+      exit(1) ;
+ }
+ #ifdef DEBUG
+ std::cout << "We create the semaphore identified by number : " << _Sem_Id << 
std::endl ;
+ #endif
+
+ union semun{
+     int val ;  
+   struct semid_ds *buf ; // Not use here
+   ushort *array; // Not use here       
+ } arg_ctl ;
+
+ // Initialize
+ arg_ctl.val = initval ;
+ if (semctl(_Sem_Id,0,SETVAL,arg_ctl) == -1){
+    perror("Error during semaphore initialization") ;
+    exit(1) ;
+        }
+ #ifdef DEBUG
+ std::cout <<"We init the semaphore with value : " << initval << std::endl ;
+ #endif
+
+} // End of method : Create_Init(...)
+
+// ************************************************
+// Method : SemaphoreSysV::Attach(...)
+// ************************************************
+void SemaphoreSysV::Attach(const std::string& New_Semname) {
+
+_Sem_Key = ntok(New_Semname.c_str()) ;
+_Sem_Id = semget(_Sem_Key,1,0666) ;
+if (_Sem_Id == -1) {
+      perror("Error with semget() in SemaphoreSysV::Attach(...)") ;
+      exit(1) ;
+      }
+ #ifdef DEBUG
+ std::cout <<  "We attach the semaphore identified by number : " << _Sem_Id << 
std::endl ;
+ #endif
+
+} // End of method : Attach(...)
+
+// ************************************************
+// Method : SemaphoreSysV::P
+// ************************************************
+// Decrement Semaphore Value SV=SV-1 
+
+void SemaphoreSysV::P() {
+
+#ifdef DEBUG
+std::cout << "Begin of Operation P for the semaphore identified by number : " 
<< _Sem_Id << std::endl ;
+#endif
+
+struct sembuf semparP ;
+  semparP.sem_num = 0 ;
+  semparP.sem_op = -1 ;
+  semparP.sem_flg = SEM_UNDO ;
+
+ if (semop(_Sem_Id,&semparP,1) == -1) {
+    perror("Error with semop() in SemaphoreSysV::P()") ;
+    exit(1);
+    } 
+
+#ifdef DEBUG
+std::cout << "End of Operation P for the semaphore identified by number : " << 
_Sem_Id << std::endl  ;
+#endif
+
+} // End of P()
+
+
+// ************************************************
+// Method : SemaphoreSysV::V
+// ************************************************
+// Increment Semaphore Value SV=SV+1 
+
+void SemaphoreSysV::V() {
+
+#ifdef DEBUG
+std::cout << "Begin of Operation V for the semaphore identified by number : " 
<< _Sem_Id << std::endl ;
+#endif
+
+struct sembuf semparV ;
+  semparV.sem_num = 0 ;
+  semparV.sem_op = 1 ;
+  semparV.sem_flg = SEM_UNDO ;
+
+  if (semop(_Sem_Id,&semparV,1) ==-1) {
+    perror("Error with semop() in SemaphoreSysV::V() ") ;
+    exit(1);
+    } 
+
+#ifdef DEBUG
+std::cout << "End of Operation V for the semaphore identified by number : " << 
_Sem_Id << std::endl  ;
+#endif
+
+} // End of V()
+
+// ************************************************
+// Method : SemaphoreSysV::Delete
+// ************************************************
+void SemaphoreSysV::Delete(){
+
+#ifdef DEBUG
+std::cout << "Destroy the semaphore identified by number : " << _Sem_Id << 
std::endl ;
+#endif
+
+if(semctl(_Sem_Id,0,IPC_RMID,0) == -1)
+    perror("Error with semctl() in SemaphoreSysV::Delete()") ;
+
+} // End of Delete()
+
+} /* end namespace ipc  */
+} /* end namespace libhla */

Index: libHLA/Semaphore.hh
===================================================================
RCS file: libHLA/Semaphore.hh
diff -N libHLA/Semaphore.hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/Semaphore.hh 28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,38 @@
+#ifndef SEMAPHORE_H
+#define SEMAPHORE_H
+
+// Systems includes
+#include <string>
+#include "libhla.hh"
+
+namespace libhla {
+namespace ipc {
+
+class HLA_EXPORT Semaphore {
+
+protected:
+
+    public :
+    // Semaphore() ;
+    virtual ~Semaphore() {};
+    virtual void Create_Init(const int initval, const std::string& 
New_Semname) = 0 ;
+    virtual void Attach(const std::string& New_Semname ) = 0 ;
+    virtual void P() = 0 ;
+    virtual void V() = 0 ;
+    virtual void Delete() = 0 ;
+
+
+       /**
+        * Build a proper Semaphore name from a user provided name.
+        * Idea kindly borrowed from TSP (https://savannah.nongnu.org)
+        * bb_utils_build_sem_name
+        */
+       static std::string buildSemName(const std::string& SemName) {
+               return "/"+SemName+"_sem";
+       }
+
+} ;
+} /* end namespace ipc  */
+} /* end namespace libhla */
+
+#endif

Index: libHLA/SemaphorePosix.cc
===================================================================
RCS file: libHLA/SemaphorePosix.cc
diff -N libHLA/SemaphorePosix.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SemaphorePosix.cc    28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,115 @@
+#include "SemaphorePosix.hh"
+
+namespace libhla {
+namespace ipc {
+
+// ************************************************
+// Constructor
+// ************************************************
+SemaphorePosix::SemaphorePosix(){
+_Sem = NULL ;
+}
+
+// ************************************************
+// Destructor
+// ************************************************
+SemaphorePosix::~SemaphorePosix() {
+if (_Sem!=NULL) {
+  Delete() ;
+}
+}
+
+// ************************************************
+// Method : SemaphorePosix::Create_Init(...)
+// ************************************************
+void SemaphorePosix::Create_Init(const int initval, const std::string& 
New_Semname) {
+
+ _Semname.assign(New_Semname) ;
+sem_unlink(_Semname.c_str()) ;
+_Sem = sem_open( _Semname.c_str(), O_CREAT | O_EXCL , S_IRUSR | S_IWUSR 
,(int)initval) ;
+if(_Sem == SEM_FAILED) {
+     perror("Error with sem_open() in SemaphorePosix::Create_Init(...)") ; 
+     }
+
+#ifdef DEBUG
+int sem_val ;
+sem_getvalue(_Sem, &sem_val) ; 
+std::cout << "We create the semaphore identified by name : " << 
_Semname.c_str() << " with an init value : " <<  sem_val << std ::endl ; 
+#endif
+
+} // End of Create_Init(...)
+
+// ************************************************
+// Method : SemaphorePosix::Attach(...)
+// ************************************************
+void SemaphorePosix::Attach(const std::string& New_Semname) {
+
+ _Semname.assign(New_Semname) ;
+_Sem = sem_open( New_Semname.c_str(), O_CREAT ) ;  
+if(_Sem == SEM_FAILED){
+   perror("Error with sem_open() in SemaphorePosix::Attach(...)") ; 
+   } 
+
+#ifdef DEBUG
+int sem_val ;
+sem_getvalue(_Sem, &sem_val) ; 
+std::cout << "We attach the semaphore identified by name : " << 
_Semname.c_str() << " which have the value : " <<  sem_val << std ::endl ; 
+#endif
+} // End of Attach(...)
+
+// ************************************************
+// Method : SemaphorePosix::P()
+// ************************************************
+// Decrement Semaphore Value SV=SV-1 
+
+void SemaphorePosix::P() {
+
+#ifdef DEBUG
+int sem_val ;
+sem_getvalue(_Sem, &sem_val) ; 
+std::cout << "Begin of Operation P for the semaphore identified by name : " << 
_Semname << " which have the value : " << sem_val << std::endl ;
+#endif
+
+sem_wait(_Sem) ;
+
+#ifdef DEBUG
+sem_getvalue(_Sem, &sem_val) ;
+std::cout << "End of Operation P for the semaphore identified by name : " << 
_Semname << " which have the value : " << sem_val << std::endl ; 
+#endif
+
+} // End of P()
+
+
+// ************************************************
+// Methode : SemaphorePosix::V()
+// ************************************************
+// Increment Semaphore Value SV=SV+1 
+
+void SemaphorePosix::V() {
+
+#ifdef DEBUG
+int sem_val ;
+sem_getvalue(_Sem, &sem_val) ; 
+std::cout << "Begin of Operation V for the semaphore identified by name <" << 
_Semname << "> which have the value : " << sem_val << std::endl ;
+#endif
+
+sem_post(_Sem) ;
+
+#ifdef DEBUG
+sem_getvalue(_Sem, &sem_val) ;
+std::cout << "End of Operation V for the semaphore identified by name <" << 
_Semname << "> which have the value : " << sem_val << std::endl ; 
+#endif
+
+} // End of V()
+
+// ************************************************
+// Methode : SemaphorePosix::Delete()
+// ************************************************
+void SemaphorePosix::Delete(){
+
+sem_close(_Sem) ;
+sem_destroy(_Sem) ;
+
+} // End of Delete()
+} /* end namespace ipc  */
+} /* end namespace libhla */

Index: libHLA/SHMPosix.hh
===================================================================
RCS file: libHLA/SHMPosix.hh
diff -N libHLA/SHMPosix.hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SHMPosix.hh  28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,27 @@
+#ifndef SHM_POSIX_H
+#define SHM_POSIX_H
+
+// Specifics includes
+#include "SHM.hh"
+
+namespace libhla {
+namespace ipc {
+
+class HLA_EXPORT SHMPosix : public SHM {
+
+    private :
+    int _Id ;  // identifiant du segment memoire affecté dans la methode : 
Open()
+   
+    public :
+    SHMPosix(const std::string& SHMName, const int SHMSize, const bool True) ;
+    SHMPosix(const std::string& SHMName, const int SHMSize) ;  
+    ~SHMPosix() ;
+
+    void Open() ;
+    void Attach() ;
+    void Close() ;
+
+} ;
+} /* end namespace ipc  */
+} /* end namespace libhla */
+#endif

Index: libHLA/SemaphoreWin32.hh
===================================================================
RCS file: libHLA/SemaphoreWin32.hh
diff -N libHLA/SemaphoreWin32.hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SemaphoreWin32.hh    28 Mar 2010 11:42:34 -0000      1.1
@@ -0,0 +1,43 @@
+#ifndef SEMAPHOREWIN32_H
+#define SEMAPHOREWIN32_H
+
+// Semaphores usefull systems includes
+#include <windows.h>
+#include <conio.h>
+#include <tchar.h>
+
+// Others systems includes
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <iostream>
+
+// Specifics includes
+#include "certi.hh"
+#include "Semaphore.hh"
+
+namespace libhla {
+namespace ipc {
+
+class HLA_EXPORT SemaphoreWin32 : public Semaphore {
+    private :
+        HANDLE WINAPI _hSemaphore;
+
+    public :
+    SemaphoreWin32() ;
+    virtual ~SemaphoreWin32() ;
+    void Create_Init(const int initval, const std::string& New_Semname)
+                     throw(certi::SemaphoreNotCreated) ;
+    void Attach(const std::string& New_Semname )
+                throw(certi::SemaphoreNotOpen) ;
+    void P()
+         throw(certi::SemaphoreHandlingError) ;
+    void V()
+         throw(certi::SemaphoreHandlingError) ;
+    void Delete()
+         throw(certi::HandleNotClosed) ;
+
+} ;
+} /* end namespace ipc  */
+} /* end namespace libhla */
+#endif

Index: libHLA/SemaphoreWin32.cc
===================================================================
RCS file: libHLA/SemaphoreWin32.cc
diff -N libHLA/SemaphoreWin32.cc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SemaphoreWin32.cc    28 Mar 2010 11:42:35 -0000      1.1
@@ -0,0 +1,146 @@
+#include "SemaphoreWin32.hh"
+
+namespace libhla {
+namespace ipc {
+// ************************************************
+// Constructor
+// ************************************************
+SemaphoreWin32::SemaphoreWin32(){
+_hSemaphore = NULL ;
+}
+
+// ************************************************
+// Destructor
+// ************************************************
+SemaphoreWin32::~SemaphoreWin32() {}
+
+// ************************************************
+// Method : SemaphoreWin32::Create_Init(...)
+// ************************************************
+void SemaphoreWin32::Create_Init(const int initval, const std::string& 
New_Semname)
+                                 throw(certi::SemaphoreNotCreated) {
+
+_hSemaphore = CreateSemaphore(
+                      (LPSECURITY_ATTRIBUTES)NULL,             // security 
attributes
+                      (LONG)(initval),                         // initial count
+                      (LONG)(1),                               // maximum count
+                      (LPCTSTR)(New_Semname.c_str()));         // named 
semaphore
+
+ if (_hSemaphore == NULL){
+      throw(certi::SemaphoreNotCreated("CreateSemaphore() failed.")) ;
+ }
+ #ifdef DEBUG
+ std::cout << "We create the semaphore identified by handle : " << _hSemaphore 
<< " and name : " << New_Semname << std::endl ;
+ #endif
+
+} // End of method : Create_Init(...)
+
+// ************************************************
+// Method : SemaphoreWin32::Attach(...)
+// ************************************************
+void SemaphoreWin32::Attach(const std::string& New_Semname)
+                            throw(certi::SemaphoreNotOpen){
+
+// Open the semaphore
+
+   _hSemaphore = OpenSemaphore(
+                      SEMAPHORE_ALL_ACCESS,             // security attributes
+                      FALSE,                            // Inherit Handle
+                      (LPCTSTR)(New_Semname.c_str()));                        
// named semaphore
+
+#ifdef DEBUG
+  std::cout << "We try to attach the semaphore identified by handle : " << 
_hSemaphore << " and name : " << New_Semname << std::endl ;
+#endif
+
+   if (_hSemaphore == NULL)
+   {
+        throw(certi::SemaphoreNotOpen("OpenSemaphore() failed.")) ;
+   }
+
+} // End of method : Attach(...)
+
+// ************************************************
+// Method : SemaphoreWin32::P
+// ************************************************
+
+void SemaphoreWin32::P()
+                    throw(certi::SemaphoreHandlingError) {
+
+#ifdef DEBUG
+std::cout << "Begin of Operation P for the semaphore identified by handle : " 
<< _hSemaphore << std::endl ;
+#endif
+
+DWORD  WINAPI dwRetCode;
+
+dwRetCode = WaitForSingleObject(
+                   (HANDLE)_hSemaphore,  // handle to semaphore
+                   INFINITE);    // if we want to have P blocked
+
+switch (dwRetCode)
+      {
+    // The semaphore object was signaled.
+          case WAIT_OBJECT_0:
+    // Semaphore is signaled
+    // go ahead and continue the work
+             break;
+
+          default:
+             // Handle errors
+             throw(certi::SemaphoreHandlingError("WaitForSingleObject() 
failed.")) ;
+      }
+
+#ifdef DEBUG
+std::cout << "End of Operation P for the semaphore identified by handle : " << 
_hSemaphore << std::endl  ;
+#endif
+
+} // End of P()
+
+
+// ************************************************
+// Method : SemaphoreWin32::V
+// ************************************************
+
+void SemaphoreWin32::V()
+                    throw(certi::SemaphoreHandlingError) {
+
+#ifdef DEBUG
+std::cout << "Begin of Operation V for the semaphore identified by handle : " 
<< _hSemaphore << std::endl ;
+#endif
+
+BOOL WINAPI retcode ;
+
+  retcode = ReleaseSemaphore(
+        _hSemaphore,  // handle to semaphore
+        1,            // increase count by one
+        NULL) ;       // not interested in previous count
+
+  if (retcode == 0) {
+      throw(certi::SemaphoreHandlingError("ReleaseSemaphore() failed.")) ;
+    }
+
+#ifdef DEBUG
+std::cout << "End of Operation V for the semaphore identified by handle : " << 
_hSemaphore << std::endl  ;
+#endif
+
+} // End of V()
+
+// ************************************************
+// Method : SemaphoreWin32::Delete
+// ************************************************
+void SemaphoreWin32::Delete()
+                    throw(certi::HandleNotClosed) {
+
+BOOL WINAPI retcode ;
+
+#ifdef DEBUG
+std::cout << "Destroy the semaphore identified by handle : " << _hSemaphore << 
std::endl ;
+#endif
+
+retcode = CloseHandle(_hSemaphore);
+
+if(retcode == 0)
+   throw(certi::HandleNotClosed("CloseHandle() failed.")) ;
+} // End of Delete()
+
+} /* end namespace ipc  */
+} /* end namespace libhla */

Index: libHLA/SemaphoreSysV.hh
===================================================================
RCS file: libHLA/SemaphoreSysV.hh
diff -N libHLA/SemaphoreSysV.hh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libHLA/SemaphoreSysV.hh     28 Mar 2010 11:42:35 -0000      1.1
@@ -0,0 +1,67 @@
+#ifndef SEMAPHORESYSV_H
+#define SEMAPHORESYSV_H
+
+// Semaphores usefull systems includes
+#include <sys/types.h>
+#include <sys/ipc.h> 
+#include <sys/sem.h>
+
+// Others systems includes 
+#include <unistd.h>
+#include <cstdlib>
+#include <iostream>
+
+// Specifics includes
+#include "Semaphore.hh"
+
+namespace libhla {
+namespace ipc {
+
+class HLA_EXPORT SemaphoreSysV : public Semaphore {
+    private :
+    int _Sem_Id ;
+    key_t _Sem_Key ;
+
+    public :
+    SemaphoreSysV() ;
+    virtual ~SemaphoreSysV() ;
+    void Create_Init(const int initval, const std::string& New_Semname) ;
+    void Attach(const std::string& New_Semname ) ;
+    void P() ;
+    void V() ;
+    void Delete() ;
+
+    /**
+     * Build a SysV IPC key from a name and user specific value.
+     * The purpose of this function is to build a (quasi) unique
+     * key from unique entry as ftok(3) do with existing file name.
+     * We use SHA1 hash function Xored with the user_specific
+     * value supplied.
+     * @param[in] name, the name representing the IPC element for which
+     *                 we want a key.
+     * @param[in] user_specific_value, any user specific value
+     *                               (for example uid).
+     * @return The generated SysV IPC key corresponding to the specified entry
+     */
+    key_t
+    static ntokUser(const char* name, int32_t user_specific_value);
+
+    /**
+     * Build a SysV IPC key from a name.
+     * L'objectif de cette fonction est de generer des
+     * clefs differentes pour des noms differents, a la maniere
+     * d'une fonction de hachage ou checksum parfaite.
+     * Cette fonction vise les meme objectifs que ftok(3)
+     * avec les noms de fichiers mais avec une chaine
+     * de caractere quelconque.
+     * @param name un nom representant l'element IPC pour lequel on
+     *                veut generer une clef.
+     * @return SysV IPC key corresponding to the specified name.
+     */
+    key_t
+    static ntok(const char* name);
+
+} ;
+} /* end namespace ipc  */
+} /* end namespace libhla */
+#endif

Index: libCERTI/SHMWin32.hh
===================================================================
RCS file: libCERTI/SHMWin32.hh
diff -N libCERTI/SHMWin32.hh
--- libCERTI/SHMWin32.hh        20 Jan 2010 12:57:09 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,27 +0,0 @@
-#ifndef SHM_WIN32_H
-#define SHM_WIN32_H
-
-// Specifics includes
-#include "SHM.hh"
-#include "certi.hh"
-#include "Exception.hh"
-
-class CERTI_EXPORT SHMWin32 : public SHM {
-
-    private :
-        HANDLE _hMapFile ;
-        LPCTSTR _pBuf;
-
-    public :
-    SHMWin32(const std::string& SHMName, const int SHMSize, const bool True) ;
-    SHMWin32(const std::string& SHMName, const int SHMSize) ;
-    ~SHMWin32() ;
-
-    void Open() throw(certi::SharedMemoryNotOpen) ;
-    void Attach() throw(certi::SharedMemoryNotAttached) ;
-    void Close() throw(certi::SharedMemoryNotClosed,
-                       certi::HandleNotClosed);
-
-} ;
-
-#endif

Index: libCERTI/SHMSysV.hh
===================================================================
RCS file: libCERTI/SHMSysV.hh
diff -N libCERTI/SHMSysV.hh
--- libCERTI/SHMSysV.hh 16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
-#ifndef SHM_SYSV_H
-#define SHM_SYSV_H
-
-// SHMs useful systems includes
-#include <sys/types.h>
-#include <sys/ipc.h> 
-#include <sys/shm.h>
-
-// Others systems includes
-#include <fcntl.h>
-#include <math.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <iostream>
-#include <string.h>
-
-// Specifics includes
-#include "SHM.hh"
-
-class SHMSysV : public SHM {
-
-    private :
-    int _Id ;  
-    key_t _Key ; 
-   
-    public :
-    SHMSysV(const std::string& SHMName, const int SHMSize, const bool True) ;
-    SHMSysV(const std::string& SHMName, const int SHMSize) ;  
-    ~SHMSysV() ;
-    void Open() ;
-    void Attach() ;
-    void Close() ;
-
-        /**
-     * Build a SysV IPC key from a name and user specific value.
-     * The purpose of this function is to build a (quasi) unique
-     * key from unique entry as ftok(3) do with existing file name.
-     * We use SHA1 hash function Xored with the user_specific
-     * value supplied.
-     * @param[in] name, the name representing the IPC element for which
-     *                 we want a key.
-     * @param[in] user_specific_value, any user specific value
-     *                               (for example uid).
-     * @return The generated SysV IPC key corresponding to the specified entry
-     */
-    key_t
-    static ntokUser(const char* name, int32_t user_specific_value);
-
-    /**
-     * Build a SysV IPC key from a name.
-     * L'objectif de cette fonction est de generer des
-     * clefs differentes pour des noms differents, a la maniere
-     * d'une fonction de hachage ou checksum parfaite.
-     * Cette fonction vise les meme objectifs que ftok(3)
-     * avec les noms de fichiers mais avec une chaine
-     * de caractere quelconque.
-     * @param name un nom representant l'element IPC pour lequel on
-     *                veut generer une clef.
-     * @return SysV IPC key corresponding to the specified name.
-     */
-    key_t
-    static ntok(const char* name);
-
-
-} ;
-
-#endif

Index: libCERTI/SemaphorePosix.hh
===================================================================
RCS file: libCERTI/SemaphorePosix.hh
diff -N libCERTI/SemaphorePosix.hh
--- libCERTI/SemaphorePosix.hh  16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-#ifndef SEMAPHORE_POSIX_H
-#define SEMAPHORE_POSIX_H
-
-// Posix Semaphores systems includes
-// Don't forget to add "-lrt" to compilation line
-#include <sys/types.h>
-#include <Semaphore.hh>
-#include <fcntl.h>
-
-// Others Systems includes
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <iostream>
-
-// Specifics includes
-#include "Semaphore.hh"
-#include <semaphore.h>
-
-class SemaphorePosix : public Semaphore {
-    private :
-    std::string _Semname ;
-    sem_t *_Sem ;
-
-    public :
-    SemaphorePosix() ;
-    virtual ~SemaphorePosix() ;
-    void Create_Init(const int initval, const std::string& New_Semname ) ;
-    void Attach(const std::string& New_Semname ) ;
-    void P() ;
-    void V() ;
-    void Delete() ;
-
-} ;
-
-#endif

Index: libCERTI/SemaphoreSysV.hh
===================================================================
RCS file: libCERTI/SemaphoreSysV.hh
diff -N libCERTI/SemaphoreSysV.hh
--- libCERTI/SemaphoreSysV.hh   16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-#ifndef SEMAPHORESYSV_H
-#define SEMAPHORESYSV_H
-
-// Semaphores usefull systems includes
-#include <sys/types.h>
-#include <sys/ipc.h> 
-#include <sys/sem.h>
-
-// Others systems includes 
-#include <unistd.h>
-#include <cstdlib>
-#include <iostream>
-
-// Specifics includes
-#include "Semaphore.hh"
-
-
-class SemaphoreSysV : public Semaphore {
-    private :
-    int _Sem_Id ;
-    key_t _Sem_Key ;
-
-    public :
-    SemaphoreSysV() ;
-    virtual ~SemaphoreSysV() ;
-    void Create_Init(const int initval, const std::string& New_Semname) ;
-    void Attach(const std::string& New_Semname ) ;
-    void P() ;
-    void V() ;
-    void Delete() ;
-
-    /**
-     * Build a SysV IPC key from a name and user specific value.
-     * The purpose of this function is to build a (quasi) unique
-     * key from unique entry as ftok(3) do with existing file name.
-     * We use SHA1 hash function Xored with the user_specific
-     * value supplied.
-     * @param[in] name, the name representing the IPC element for which
-     *                 we want a key.
-     * @param[in] user_specific_value, any user specific value
-     *                               (for example uid).
-     * @return The generated SysV IPC key corresponding to the specified entry
-     */
-    key_t
-    static ntokUser(const char* name, int32_t user_specific_value);
-
-    /**
-     * Build a SysV IPC key from a name.
-     * L'objectif de cette fonction est de generer des
-     * clefs differentes pour des noms differents, a la maniere
-     * d'une fonction de hachage ou checksum parfaite.
-     * Cette fonction vise les meme objectifs que ftok(3)
-     * avec les noms de fichiers mais avec une chaine
-     * de caractere quelconque.
-     * @param name un nom representant l'element IPC pour lequel on
-     *                veut generer une clef.
-     * @return SysV IPC key corresponding to the specified name.
-     */
-    key_t
-    static ntok(const char* name);
-
-} ;
-
-#endif

Index: libCERTI/SHMPosix.hh
===================================================================
RCS file: libCERTI/SHMPosix.hh
diff -N libCERTI/SHMPosix.hh
--- libCERTI/SHMPosix.hh        16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,23 +0,0 @@
-#ifndef SHM_POSIX_H
-#define SHM_POSIX_H
-
-// Specifics includes
-#include "SHM.hh"
-
-class SHMPosix : public SHM {
-
-    private :
-    int _Id ;  // identifiant du segment memoire affecté dans la methode : 
Open()
-   
-    public :
-    SHMPosix(const std::string& SHMName, const int SHMSize, const bool True) ;
-    SHMPosix(const std::string& SHMName, const int SHMSize) ;  
-    ~SHMPosix() ;
-
-    void Open() ;
-    void Attach() ;
-    void Close() ;
-
-} ;
-
-#endif

Index: libCERTI/Semaphore.hh
===================================================================
RCS file: libCERTI/Semaphore.hh
diff -N libCERTI/Semaphore.hh
--- libCERTI/Semaphore.hh       16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
-#ifndef SEMAPHORE_H
-#define SEMAPHORE_H
-
-#include "certi.hh"
-#include "Exception.hh"
-// Systems includes
-#include <string>
-
-class CERTI_EXPORT Semaphore {
-
-protected:
-
-    public :
-    // Semaphore() ;
-    virtual ~Semaphore() {};
-    virtual void Create_Init(const int initval, const std::string& 
New_Semname) = 0 ;
-    virtual void Attach(const std::string& New_Semname ) = 0 ;
-    virtual void P() = 0 ;
-    virtual void V() = 0 ;
-    virtual void Delete() = 0 ;
-
-
-       /**
-        * Build a proper Semaphore name from a user provided name.
-        * Idea kindly borrowed from TSP (https://savannah.nongnu.org)
-        * bb_utils_build_sem_name
-        */
-       static std::string buildSemName(const std::string& SemName) {
-               return "/"+SemName+"_sem";
-       }
-
-} ;
-
-#endif

Index: libCERTI/SHM.hh
===================================================================
RCS file: libCERTI/SHM.hh
diff -N libCERTI/SHM.hh
--- libCERTI/SHM.hh     16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,56 +0,0 @@
-#ifndef SHM_H
-#define SHM_H
-
-#include <string>
-#include "certi.hh"
-
-/**
- * A Shared Memory class.
- * This class is an abstract base for representing a shared memory
- * segment. A shared memory segment is identified by its name and
- * has a size and a creator process.
- */
-class CERTI_EXPORT SHM {
-protected :
-       std::string _Name ;
-       int  _Size ;
-       bool _IsCreator ;
-       void *_Shm ;
-
-public :
-       /**
-        * Constructor.
-        * @param[in] SHNName, the name of the shared memory segment.
-        *            this should be unique on a specified host.
-        * @param[in] SHMSize, the requested size of the SHM
-        */
-       SHM(const std::string& SHMName, const int SHMSize, const bool True)
-               {_Name=SHMName;
-                _Size=SHMSize;
-                _IsCreator=True;
-                }
-       SHM(const std::string& SHMName, const int SHMSize)
-               {_Name=SHMName;
-                _Size=SHMSize;
-                _IsCreator=false;
-                }
-       virtual ~SHM() {};
-       const std::string getName() const {return _Name ; } ;
-       inline void* GetShm(){return _Shm ; } ;
-       inline bool IsCreator(){return _IsCreator ; } ;
-       inline int GetSize(){return _Size ; } ;
-       virtual void Open() = 0 ;
-       virtual void Attach() = 0 ;
-       virtual void Close() = 0 ;
-
-        /**
-        * Build a proper SHM name from a user provided name.
-        * Idea kindly borrowed from TSP (https://savannah.nongnu.org)
-        * bb_utils_build_shm_name
-        */
-       static std::string buildShmName(const std::string& ShmName) {
-         return "/"+ShmName+"_shm";
-       }
-} ;
-
-#endif

Index: libCERTI/SemaphoreWin32.hh
===================================================================
RCS file: libCERTI/SemaphoreWin32.hh
diff -N libCERTI/SemaphoreWin32.hh
--- libCERTI/SemaphoreWin32.hh  16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-#ifndef SEMAPHOREWIN32_H
-#define SEMAPHOREWIN32_H
-
-// Semaphores usefull systems includes
-#include <windows.h>
-#include <conio.h>
-#include <tchar.h>
-
-// Others systems includes
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <iostream>
-
-// Specifics includes
-#include "certi.hh"
-#include "Semaphore.hh"
-
-
-class CERTI_EXPORT SemaphoreWin32 : public Semaphore {
-    private :
-        HANDLE WINAPI _hSemaphore;
-
-    public :
-    SemaphoreWin32() ;
-    virtual ~SemaphoreWin32() ;
-    void Create_Init(const int initval, const std::string& New_Semname)
-                     throw(certi::SemaphoreNotCreated) ;
-    void Attach(const std::string& New_Semname )
-                throw(certi::SemaphoreNotOpen) ;
-    void P()
-         throw(certi::SemaphoreHandlingError) ;
-    void V()
-         throw(certi::SemaphoreHandlingError) ;
-    void Delete()
-         throw(certi::HandleNotClosed) ;
-
-} ;
-
-#endif

Index: libCERTI/SHMPosix.cc
===================================================================
RCS file: libCERTI/SHMPosix.cc
diff -N libCERTI/SHMPosix.cc
--- libCERTI/SHMPosix.cc        22 Mar 2010 16:15:45 -0000      3.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,119 +0,0 @@
-// SHM useful systems includes
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-// Others Systems includes
-#include <math.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <iostream>
-#include <string.h>
-
-#include "SHMPosix.hh"
-
-// ************************************************
-// Constructor with args
-// ************************************************
-SHMPosix::SHMPosix(const std::string& SHMName, const int SHMSize, const bool 
True)  : SHM(SHMName, SHMSize, True) { 
-    _Id = 0 ;  
-}
-
-SHMPosix::SHMPosix(const std::string& SHMName, const int SHMSize)  : 
SHM(SHMName,SHMSize) { 
-    _Id = 0 ;  
-}
-
-// ************************************************
-// Destructor
-SHMPosix::~SHMPosix() {}
-
-// ************************************************
-// Method : SHMPosix::Open()
-// ************************************************
-void SHMPosix::Open() {
-
-int ret ;
-
- if (IsCreator()){
-    ret = shm_unlink(_Name.c_str());
-    _Id = shm_open(_Name.c_str(), O_CREAT | O_EXCL | O_RDWR , S_IRWXU | 
S_IRWXG);
-    if (_Id < 0) {
-        perror("Error with shm_open() in SHMPosix::Open()");
-        exit(1);
-        }
-#ifdef DEBUG
-std::cout <<  "Created shared memory object : " << _Name.c_str() << std::endl ;
-#endif
-
-    ret = ftruncate(_Id, _Size);
-     if (ret < 0) {
-        perror("In ftruncate()");
-        exit(1);
-        }
-
- } // End of if IsCreator()
- else{
-    _Id = shm_open(_Name.c_str(), O_RDONLY, S_IRWXU | S_IRWXG);
-    if (_Id < 0) {
-        perror("Error with shm_open() in SHMPosix::Open()");
-        exit(1);
-        }
-#ifdef DEBUG
-std::cout <<  "Attach shared memory object : " << _Name.c_str() << std::endl ;
-#endif
- } // End of else IsCreator()
-
-} // End of Open()
-
-// ************************************************
-// Method : SHMPosix::Attach()
-// ************************************************
-void SHMPosix::Attach() {
-
-if (IsCreator()){
-    /* requesting the shared segment for write    --  mmap() */    
-    _Shm = mmap(NULL, _Size, PROT_READ | PROT_WRITE , MAP_SHARED, _Id, 0);
-    if (_Shm == NULL) {
-        perror("Error with mmap() in SHMPosix::Attach() ");
-        exit(1);}
-    if (_Shm == MAP_FAILED) {
-        perror("Error with mmap() in SHMPosix::Attach() ");
-        exit(1);}
-    close(_Id) ;
-} // End of IsServer
-else{
- /* requesting the shared segment for write    --  mmap() */    
-    _Shm = mmap(NULL, _Size, PROT_READ , MAP_SHARED, _Id, 0);
-    if (_Shm == NULL) {
-        perror("Error with mmap() in SHMPosix::Attach() ");
-        exit(1);}
-    if (_Shm == MAP_FAILED) {
-        perror("Error with mmap() in SHMPosix::Attach() ");
-        exit(1);}
-    close(_Id) ;
-} // End of else (IsServer)
-} // End of Attach()
-
-// ************************************************
-// Method : SHMPosix::Close()
-// ************************************************
-void SHMPosix::Close() {
-
-// Close
-if (shm_unlink(_Name.c_str()) != 0) {
-    perror("Error with shm_unlink() in SHMPosix::Close() ");
-    exit(1);
-    }
-
-// Destroy
-if (IsCreator()){
-if(munmap(_Shm, _Size)){
-   perror("Error with munmap() in SHMPosix::Close() ");
-   exit(1);
-   } // End of if
-}
-
-} // End of Close()
-

Index: libCERTI/SHMSysV.cc
===================================================================
RCS file: libCERTI/SHMSysV.cc
diff -N libCERTI/SHMSysV.cc
--- libCERTI/SHMSysV.cc 16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,117 +0,0 @@
-#include "SHMSysV.hh"
-#include "sha1.h"
-
-key_t SHMSysV::ntokUser(const char* name, int32_t user_specific_value) {
-
-key_t s_key ;
-int32_t retcode ;
-
-SHA1Context sha ;
- uint8_t Message_Digest[20] ;
-
-/* We use the first byte of a SHA1 hash of the BBname
- * unless the algorithm fail.
- * If SHA1 fail we go back to poor key generation method
- * using the name length.
- * In both case we must Xored the key with user_specific in order
- * to isolate different user from using the same key
- */
-         
-retcode  = SHA1Reset(&sha) ;
-retcode &= SHA1Input(&sha, (const unsigned char *) name,strlen(name)) ;
-retcode &= SHA1Result(&sha, Message_Digest);
-
-/* SHA 1 NOK back to old poor method */
-if (0 != retcode) {
-   s_key = ((strlen(name) << 16) & 0xFFFF0000) ^ (user_specific_value & 
0x0000FFFF);
-   } 
-else { s_key = (Message_Digest[0]        |
-       (Message_Digest[1] << 8) |
-       (Message_Digest[2] << 16)|
-       (Message_Digest[3] << 24)) ^
-        user_specific_value;
-       }
-       return s_key;
-}
-
-key_t
-SHMSysV::ntok(const char* name) {
-       return SHMSysV::ntokUser(name,getuid());
-        // return SHMSysV::ntokUser(name,1);
-}
-
-
-// ************************************************
-// Constructors with args
-// ************************************************
-SHMSysV::SHMSysV(const std::string& SHMName, const int SHMSize, const bool 
True)  : SHM(SHMName, SHMSize, True) { 
-    _Key = ntok(SHMName.c_str());
-
-#ifdef DEBUG
-std::cout << " Cle produite : " << _Key << std::endl ;
-#endif
-
-    _Id = 0 ;  
-}
-
-SHMSysV::SHMSysV(const std::string& SHMName, const int SHMSize)  : 
SHM(SHMName, SHMSize) { 
-     _Key = ntok(SHMName.c_str());
-
-#ifdef DEBUG
-std::cout << " Cle produite : " << _Key << std::endl ;
-#endif
-
-    _Id = 0 ;  
-}
-
-
-// ************************************************
-// Destructor
-// ************************************************
-SHMSysV::~SHMSysV() {}
-
-// ************************************************
-// Method : SHMSysV::Open()
-// ************************************************
-void SHMSysV::Open() {
-
-if ((_Id = shmget(_Key, (size_t)_Size, IPC_CREAT| 0666 )) < 0){  
-    perror("Error with shmget in SHMSysV::Open()"); 
-    exit(1);
-    } // End of if
-
-} // End of Open()
-
-// ************************************************
-// Method : SHMSysV::Attach()
-// ************************************************
-void SHMSysV::Attach() {
-
-if ( ( _Shm = shmat(_Id, NULL, 0) ) == (void*) -1){
-    perror("Error with shmat() in SHMSysV::Attach() "); 
-    exit(1);
-    } // End of if
-
-} // End of Attach(...)
-
-// ************************************************
-// Method : Close()
-// ************************************************
-void SHMSysV::Close() {
-
-// Close
-if(shmdt(_Shm)){
-        perror("Error with shmdt() in SHMSysV::Close()");
-        exit(1);
-      } // End of if(shmdt(_Shm))
-
-if(_IsCreator){
-// Destroy
-if(shmctl(_Id, IPC_RMID,0)){
-   perror("Error with shmctl() in SHMSysV::Close()");
-   exit(1);
-   } // End of if(shmctl(_Shm_Id, IPC_RMID,0))
-} // End of (_IsServer)
-
-} // End of Close()
-

Index: libCERTI/SHMWin32.cc
===================================================================
RCS file: libCERTI/SHMWin32.cc
diff -N libCERTI/SHMWin32.cc
--- libCERTI/SHMWin32.cc        23 Jan 2010 20:11:49 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-// SHM useful systems includes
-#include <windows.h>
-#include <conio.h>
-#include <tchar.h>
-
-// Others Systems includes
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <iostream>
-#include <string>
-
-#include "SHMWin32.hh"
-
-// ************************************************
-// Constructor with args
-// ************************************************
-SHMWin32::SHMWin32(const std::string& SHMName, const int SHMSize, const bool 
True)  : SHM(SHMName, SHMSize, True) {
-        _hMapFile = NULL ;
-        _pBuf = NULL ;
-}
-
-SHMWin32::SHMWin32(const std::string& SHMName, const int SHMSize)  : 
SHM(SHMName,SHMSize) {
-        _hMapFile = NULL ;
-        _pBuf = NULL ;
-}
-
-// ************************************************
-// Destructor
-SHMWin32::~SHMWin32() {}
-
-// ************************************************
-// Method : SHMWin32::Open()
-// ************************************************
-void SHMWin32::Open() throw(certi::SharedMemoryNotOpen) {
-
-int ret ;
-
-   _hMapFile = CreateFileMapping(
-                      INVALID_HANDLE_VALUE,                // use paging file
-                      NULL,                                // default security
-                      PAGE_READWRITE,                      // read/write access
-                      (DWORD)0,                                   // max. 
object size
-                      (DWORD)_Size,                        // buffer size
-                      (LPCTSTR)(_Name.c_str()));           // name of mapping 
object
-
-    if (_hMapFile == NULL) {
-        throw(certi::SharedMemoryNotOpen("CreateFileMapping() failed.")) ;
-        }
-
-#ifdef DEBUG
-std::cout <<  "Created shared memory object : " << _Name.c_str() << std::endl ;
-#endif
-
-} // End of Open()
-
-// ************************************************
-// Method : SHMWin32::Attach()
-// ************************************************
-void SHMWin32::Attach() throw(certi::SharedMemoryNotAttached) {
-
-BOOL WINAPI retcode ;
-
-_pBuf = (LPTSTR) MapViewOfFile(_hMapFile,
-                   FILE_MAP_ALL_ACCESS,      // read/write permission
-                   0,
-                   0,
-                   (SIZE_T)(GetSize()));
-
-    if (_pBuf == NULL) {
-        retcode=UnmapViewOfFile((PVOID)_pBuf);
-        CloseHandle(_hMapFile);
-        throw(certi::SharedMemoryNotAttached("MapViewOfFile() failed.")) ;
-    }
-
-    _Shm = (void *) _pBuf ;
-
-} // End of Attach()
-
-// ************************************************
-// Method : SHMWin32::Close()
-// ************************************************
-void SHMWin32::Close() throw(certi::SharedMemoryNotClosed,
-                             certi::HandleNotClosed) {
-
-BOOL WINAPI retcode ;
-
-// Unmap
-   retcode=UnmapViewOfFile((PVOID)_pBuf);
-
-if (retcode == 0) {
-    throw(certi::SharedMemoryNotClosed("UnMapViewOfFile() failed.")) ;
-    }
-
-#ifdef DEBUG
-std::cout <<  "Close SHM (UnmapViewOfFile) : " << _Name.c_str() << std::endl ;
-#endif
-
-// Close handle
-   retcode = CloseHandle(_hMapFile);
-
-if(retcode == 0){
-   throw(certi::HandleNotClosed("CloseHandle() failed.")) ;
-   } // End of if
-
-} // End of Close()
-

Index: libCERTI/SemaphorePosix.cc
===================================================================
RCS file: libCERTI/SemaphorePosix.cc
diff -N libCERTI/SemaphorePosix.cc
--- libCERTI/SemaphorePosix.cc  16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,111 +0,0 @@
-#include "SemaphorePosix.hh"
-
-// ************************************************
-// Constructor
-// ************************************************
-SemaphorePosix::SemaphorePosix(){
-_Sem = NULL ;
-}
-
-// ************************************************
-// Destructor
-// ************************************************
-SemaphorePosix::~SemaphorePosix() {
-if (_Sem!=NULL) {
-  Delete() ;
-}
-}
-
-// ************************************************
-// Method : SemaphorePosix::Create_Init(...)
-// ************************************************
-void SemaphorePosix::Create_Init(const int initval, const std::string& 
New_Semname) {
-
- _Semname.assign(New_Semname) ;
-sem_unlink(_Semname.c_str()) ;
-_Sem = sem_open( _Semname.c_str(), O_CREAT | O_EXCL , S_IRUSR | S_IWUSR 
,(int)initval) ;
-if(_Sem == SEM_FAILED) {
-     perror("Error with sem_open() in SemaphorePosix::Create_Init(...)") ; 
-     }
-
-#ifdef DEBUG
-int sem_val ;
-sem_getvalue(_Sem, &sem_val) ; 
-std::cout << "We create the semaphore identified by name : " << 
_Semname.c_str() << " with an init value : " <<  sem_val << std ::endl ; 
-#endif
-
-} // End of Create_Init(...)
-
-// ************************************************
-// Method : SemaphorePosix::Attach(...)
-// ************************************************
-void SemaphorePosix::Attach(const std::string& New_Semname) {
-
- _Semname.assign(New_Semname) ;
-_Sem = sem_open( New_Semname.c_str(), O_CREAT ) ;  
-if(_Sem == SEM_FAILED){
-   perror("Error with sem_open() in SemaphorePosix::Attach(...)") ; 
-   } 
-
-#ifdef DEBUG
-int sem_val ;
-sem_getvalue(_Sem, &sem_val) ; 
-std::cout << "We attach the semaphore identified by name : " << 
_Semname.c_str() << " which have the value : " <<  sem_val << std ::endl ; 
-#endif
-} // End of Attach(...)
-
-// ************************************************
-// Method : SemaphorePosix::P()
-// ************************************************
-// Decrement Semaphore Value SV=SV-1 
-
-void SemaphorePosix::P() {
-
-#ifdef DEBUG
-int sem_val ;
-sem_getvalue(_Sem, &sem_val) ; 
-std::cout << "Begin of Operation P for the semaphore identified by name : " << 
_Semname << " which have the value : " << sem_val << std::endl ;
-#endif
-
-sem_wait(_Sem) ;
-
-#ifdef DEBUG
-sem_getvalue(_Sem, &sem_val) ;
-std::cout << "End of Operation P for the semaphore identified by name : " << 
_Semname << " which have the value : " << sem_val << std::endl ; 
-#endif
-
-} // End of P()
-
-
-// ************************************************
-// Methode : SemaphorePosix::V()
-// ************************************************
-// Increment Semaphore Value SV=SV+1 
-
-void SemaphorePosix::V() {
-
-#ifdef DEBUG
-int sem_val ;
-sem_getvalue(_Sem, &sem_val) ; 
-std::cout << "Begin of Operation V for the semaphore identified by name <" << 
_Semname << "> which have the value : " << sem_val << std::endl ;
-#endif
-
-sem_post(_Sem) ;
-
-#ifdef DEBUG
-sem_getvalue(_Sem, &sem_val) ;
-std::cout << "End of Operation V for the semaphore identified by name <" << 
_Semname << "> which have the value : " << sem_val << std::endl ; 
-#endif
-
-} // End of V()
-
-// ************************************************
-// Methode : SemaphorePosix::Delete()
-// ************************************************
-void SemaphorePosix::Delete(){
-
-sem_close(_Sem) ;
-sem_destroy(_Sem) ;
-
-} // End of Delete()
-

Index: libCERTI/SemaphoreSysV.cc
===================================================================
RCS file: libCERTI/SemaphoreSysV.cc
diff -N libCERTI/SemaphoreSysV.cc
--- libCERTI/SemaphoreSysV.cc   7 Mar 2010 18:23:39 -0000       3.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,175 +0,0 @@
-#include "SemaphoreSysV.hh"
-#include "sha1.h"
-#include <cstring>
-#include <cstdio>
-
-key_t SemaphoreSysV::ntokUser(const char* name, int32_t user_specific_value) {
-
-key_t s_key ;
-int32_t retcode ;
-
-SHA1Context sha ;
- uint8_t Message_Digest[20] ;
-
-/* We use the first byte of a SHA1 hash of the BBname
- * unless the algorithm fail.
- * If SHA1 fail we go back to poor key generation method
- * using the name length.
- * In both case we must Xored the key with user_specific in order
- * to isolate different user from using the same key
- */
-         
-retcode  = SHA1Reset(&sha) ;
-retcode &= SHA1Input(&sha, (const unsigned char *) name,strlen(name)) ;
-retcode &= SHA1Result(&sha, Message_Digest);
-
-/* SHA 1 NOK back to old poor method */
-if (0 != retcode) {
-   s_key = ((strlen(name) << 16) & 0xFFFF0000) ^ (user_specific_value & 
0x0000FFFF);
-   } 
-else { s_key = (Message_Digest[0]        |
-       (Message_Digest[1] << 8) |
-       (Message_Digest[2] << 16)|
-       (Message_Digest[3] << 24)) ^
-        user_specific_value;
-       }
-       return s_key;
-}
-
-key_t SemaphoreSysV::ntok(const char* name) {
-       return SemaphoreSysV::ntokUser(name,getuid());
-        // return SemaphoreSysV::ntokUser(name,1);
-
-}
-// ************************************************
-// Constructor
-// ************************************************
-SemaphoreSysV::SemaphoreSysV(){
-_Sem_Id = 0 ;
-_Sem_Key = 0 ;
-}
-
-// ************************************************
-// Destructor
-// ************************************************
-SemaphoreSysV::~SemaphoreSysV() {}
-
-// ************************************************
-// Method : SemaphoreSysV::Create_Init(...)
-// ************************************************
-void SemaphoreSysV::Create_Init(const int initval, const std::string& 
New_Semname) {
-
- _Sem_Key = ntok(New_Semname.c_str()) ;
- _Sem_Id = semget(_Sem_Key,1,IPC_CREAT |0666);
- if (_Sem_Id == -1){
-      perror("Error with semget() in SemaphoreSysV::Create_Init(...)") ;
-      exit(1) ;
- }
- #ifdef DEBUG
- std::cout << "We create the semaphore identified by number : " << _Sem_Id << 
std::endl ;
- #endif
-
- union semun{
-     int val ;  
-   struct semid_ds *buf ; // Not use here
-   ushort *array; // Not use here       
- } arg_ctl ;
-
- // Initialize
- arg_ctl.val = initval ;
- if (semctl(_Sem_Id,0,SETVAL,arg_ctl) == -1){
-    perror("Error during semaphore initialization") ;
-    exit(1) ;
-        }
- #ifdef DEBUG
- std::cout <<"We init the semaphore with value : " << initval << std::endl ;
- #endif
-
-} // End of method : Create_Init(...)
-
-// ************************************************
-// Method : SemaphoreSysV::Attach(...)
-// ************************************************
-void SemaphoreSysV::Attach(const std::string& New_Semname) {
-
-_Sem_Key = ntok(New_Semname.c_str()) ;
-_Sem_Id = semget(_Sem_Key,1,0666) ;
-if (_Sem_Id == -1) {
-      perror("Error with semget() in SemaphoreSysV::Attach(...)") ;
-      exit(1) ;
-      }
- #ifdef DEBUG
- std::cout <<  "We attach the semaphore identified by number : " << _Sem_Id << 
std::endl ;
- #endif
-
-} // End of method : Attach(...)
-
-// ************************************************
-// Method : SemaphoreSysV::P
-// ************************************************
-// Decrement Semaphore Value SV=SV-1 
-
-void SemaphoreSysV::P() {
-
-#ifdef DEBUG
-std::cout << "Begin of Operation P for the semaphore identified by number : " 
<< _Sem_Id << std::endl ;
-#endif
-
-struct sembuf semparP ;
-  semparP.sem_num = 0 ;
-  semparP.sem_op = -1 ;
-  semparP.sem_flg = SEM_UNDO ;
-
- if (semop(_Sem_Id,&semparP,1) == -1) {
-    perror("Error with semop() in SemaphoreSysV::P()") ;
-    exit(1);
-    } 
-
-#ifdef DEBUG
-std::cout << "End of Operation P for the semaphore identified by number : " << 
_Sem_Id << std::endl  ;
-#endif
-
-} // End of P()
-
-
-// ************************************************
-// Method : SemaphoreSysV::V
-// ************************************************
-// Increment Semaphore Value SV=SV+1 
-
-void SemaphoreSysV::V() {
-
-#ifdef DEBUG
-std::cout << "Begin of Operation V for the semaphore identified by number : " 
<< _Sem_Id << std::endl ;
-#endif
-
-struct sembuf semparV ;
-  semparV.sem_num = 0 ;
-  semparV.sem_op = 1 ;
-  semparV.sem_flg = SEM_UNDO ;
-
-  if (semop(_Sem_Id,&semparV,1) ==-1) {
-    perror("Error with semop() in SemaphoreSysV::V() ") ;
-    exit(1);
-    } 
-
-#ifdef DEBUG
-std::cout << "End of Operation V for the semaphore identified by number : " << 
_Sem_Id << std::endl  ;
-#endif
-
-} // End of V()
-
-// ************************************************
-// Method : SemaphoreSysV::Delete
-// ************************************************
-void SemaphoreSysV::Delete(){
-
-#ifdef DEBUG
-std::cout << "Destroy the semaphore identified by number : " << _Sem_Id << 
std::endl ;
-#endif
-
-if(semctl(_Sem_Id,0,IPC_RMID,0) == -1)
-    perror("Error with semctl() in SemaphoreSysV::Delete()") ;
-
-} // End of Delete()
-

Index: libCERTI/SemaphoreWin32.cc
===================================================================
RCS file: libCERTI/SemaphoreWin32.cc
diff -N libCERTI/SemaphoreWin32.cc
--- libCERTI/SemaphoreWin32.cc  16 Jan 2010 20:17:14 -0000      3.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,142 +0,0 @@
-#include "SemaphoreWin32.hh"
-
-// ************************************************
-// Constructor
-// ************************************************
-SemaphoreWin32::SemaphoreWin32(){
-_hSemaphore = NULL ;
-}
-
-// ************************************************
-// Destructor
-// ************************************************
-SemaphoreWin32::~SemaphoreWin32() {}
-
-// ************************************************
-// Method : SemaphoreWin32::Create_Init(...)
-// ************************************************
-void SemaphoreWin32::Create_Init(const int initval, const std::string& 
New_Semname)
-                                 throw(certi::SemaphoreNotCreated) {
-
-_hSemaphore = CreateSemaphore(
-                      (LPSECURITY_ATTRIBUTES)NULL,             // security 
attributes
-                      (LONG)(initval),                         // initial count
-                      (LONG)(1),                               // maximum count
-                      (LPCTSTR)(New_Semname.c_str()));         // named 
semaphore
-
- if (_hSemaphore == NULL){
-      throw(certi::SemaphoreNotCreated("CreateSemaphore() failed.")) ;
- }
- #ifdef DEBUG
- std::cout << "We create the semaphore identified by handle : " << _hSemaphore 
<< " and name : " << New_Semname << std::endl ;
- #endif
-
-} // End of method : Create_Init(...)
-
-// ************************************************
-// Method : SemaphoreWin32::Attach(...)
-// ************************************************
-void SemaphoreWin32::Attach(const std::string& New_Semname)
-                            throw(certi::SemaphoreNotOpen){
-
-// Open the semaphore
-
-   _hSemaphore = OpenSemaphore(
-                      SEMAPHORE_ALL_ACCESS,             // security attributes
-                      FALSE,                            // Inherit Handle
-                      (LPCTSTR)(New_Semname.c_str()));                        
// named semaphore
-
-#ifdef DEBUG
-  std::cout << "We try to attach the semaphore identified by handle : " << 
_hSemaphore << " and name : " << New_Semname << std::endl ;
-#endif
-
-   if (_hSemaphore == NULL)
-   {
-        throw(certi::SemaphoreNotOpen("OpenSemaphore() failed.")) ;
-   }
-
-} // End of method : Attach(...)
-
-// ************************************************
-// Method : SemaphoreWin32::P
-// ************************************************
-
-void SemaphoreWin32::P()
-                    throw(certi::SemaphoreHandlingError) {
-
-#ifdef DEBUG
-std::cout << "Begin of Operation P for the semaphore identified by handle : " 
<< _hSemaphore << std::endl ;
-#endif
-
-DWORD  WINAPI dwRetCode;
-
-dwRetCode = WaitForSingleObject(
-                   (HANDLE)_hSemaphore,  // handle to semaphore
-                   INFINITE);    // if we want to have P blocked
-
-switch (dwRetCode)
-      {
-    // The semaphore object was signaled.
-          case WAIT_OBJECT_0:
-    // Semaphore is signaled
-    // go ahead and continue the work
-             break;
-
-          default:
-             // Handle errors
-             throw(certi::SemaphoreHandlingError("WaitForSingleObject() 
failed.")) ;
-      }
-
-#ifdef DEBUG
-std::cout << "End of Operation P for the semaphore identified by handle : " << 
_hSemaphore << std::endl  ;
-#endif
-
-} // End of P()
-
-
-// ************************************************
-// Method : SemaphoreWin32::V
-// ************************************************
-
-void SemaphoreWin32::V()
-                    throw(certi::SemaphoreHandlingError) {
-
-#ifdef DEBUG
-std::cout << "Begin of Operation V for the semaphore identified by handle : " 
<< _hSemaphore << std::endl ;
-#endif
-
-BOOL WINAPI retcode ;
-
-  retcode = ReleaseSemaphore(
-        _hSemaphore,  // handle to semaphore
-        1,            // increase count by one
-        NULL) ;       // not interested in previous count
-
-  if (retcode == 0) {
-      throw(certi::SemaphoreHandlingError("ReleaseSemaphore() failed.")) ;
-    }
-
-#ifdef DEBUG
-std::cout << "End of Operation V for the semaphore identified by handle : " << 
_hSemaphore << std::endl  ;
-#endif
-
-} // End of V()
-
-// ************************************************
-// Method : SemaphoreWin32::Delete
-// ************************************************
-void SemaphoreWin32::Delete()
-                    throw(certi::HandleNotClosed) {
-
-BOOL WINAPI retcode ;
-
-#ifdef DEBUG
-std::cout << "Destroy the semaphore identified by handle : " << _hSemaphore << 
std::endl ;
-#endif
-
-retcode = CloseHandle(_hSemaphore);
-
-if(retcode == 0)
-   throw(certi::HandleNotClosed("CloseHandle() failed.")) ;
-} // End of Delete()
-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]