certi-cvs
[Top][All Lists]
Advanced

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

[certi-cvs] certi libCERTI/Exception.cc libCERTI/Exception.... [br_CERTI


From: certi-cvs
Subject: [certi-cvs] certi libCERTI/Exception.cc libCERTI/Exception.... [br_CERTI_SHM_NEWGEN_dev]
Date: Wed, 21 Oct 2009 09:28:21 +0000

CVSROOT:        /sources/certi
Module name:    certi
Branch:         br_CERTI_SHM_NEWGEN_dev
Changes by:     Adelantado <adele>      09/10/21 09:28:21

Modified files:
        libCERTI       : Exception.cc Exception.hh RingBuffer.cc 
                         RingBuffer.hh Semaphore.hh SemaphoreWin32.cc 
                         SemaphoreWin32.hh SocketSHM.cc SocketSHM.hh 
        test/utility   : Main_SocketSHM.cc 

Log message:
        RingBuffer to emulate socket operations through shared memory

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Exception.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=3.17&r2=3.17.8.1
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Exception.hh?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=3.8&r2=3.8.8.1
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/RingBuffer.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/RingBuffer.hh?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Semaphore.hh?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.5&r2=1.1.2.6
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SemaphoreWin32.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SemaphoreWin32.hh?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHM.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.4.4&r2=1.1.4.5
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketSHM.hh?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.4.4&r2=1.1.4.5
http://cvs.savannah.gnu.org/viewcvs/certi/test/utility/Main_SocketSHM.cc?cvsroot=certi&only_with_tag=br_CERTI_SHM_NEWGEN_dev&r1=1.1.2.4&r2=1.1.2.5

Patches:
Index: libCERTI/Exception.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Exception.cc,v
retrieving revision 3.17
retrieving revision 3.17.8.1
diff -u -b -r3.17 -r3.17.8.1
--- libCERTI/Exception.cc       7 Dec 2008 20:16:12 -0000       3.17
+++ libCERTI/Exception.cc       21 Oct 2009 09:28:20 -0000      3.17.8.1
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: Exception.cc,v 3.17 2008/12/07 20:16:12 gotthardp Exp $
+// $Id: Exception.cc,v 3.17.8.1 2009/10/21 09:28:20 adele Exp $
 // ----------------------------------------------------------------------------
 
 #include "Exception.hh"
@@ -133,6 +133,27 @@
 long certi::UnknownLabel::_type = certi::e_UnknownLabel ;
 long certi::NetworkError::_type = certi::e_NetworkError ;
 long certi::NetworkSignal::_type = certi::e_NetworkSignal ;
+long certi::SharedMemoryNotOpen::_type = certi::e_SharedMemoryNotOpen ;
+long certi::SharedMemoryNotAttached::_type = certi::e_SharedMemoryNotAttached ;
+long certi::SharedMemoryNotClosed::_type = certi::e_SharedMemoryNotClosed ;
+long certi::HandleNotClosed::_type = certi::e_HandleNotClosed ;
+long certi::SemaphoreNotCreated::_type = certi::e_SemaphoreNotCreated ;
+long certi::SemaphoreNotOpen::_type = certi::e_SemaphoreNotOpen ;
+long certi::SemaphoreHandlingError::_type = certi::e_SemaphoreHandlingError ;
+long certi::SocketNotConnected::_type = certi::e_SocketNotConnected ;
+long certi::MessageNotSent::_type = certi::e_MessageNotSent ;
+long certi::MessageNotReceived::_type = certi::e_MessageNotReceived ;
+long certi::SocketNotClosed::_type = certi::e_SocketNotClosed ;
+long certi::RingBufferNotCreated::_type = certi::e_RingBufferNotCreated ;
+long certi::RingBufferNotClosed::_type = certi::e_RingBufferNotClosed ;
+long certi::RingBufferNotDeleted::_type = certi::e_RingBufferNotDeleted ;
+long certi::RingBufferNotAttached::_type = certi::e_RingBufferNotAttached ;
+long certi::MessageTooLong::_type = certi::e_MessageTooLong ;
+long certi::BufferFull::_type = certi::e_BufferFull ;
+long certi::BufferEmpty::_type = certi::e_BufferEmpty ;
+long certi::SocketSHMNotCreated::_type = certi::e_SocketSHMNotCreated ;
+long certi::SocketSHMNotOpen::_type = certi::e_SocketSHMNotOpen ;
+long certi::SocketSHMNotDeleted::_type = certi::e_SocketSHMNotDeleted ;
 
 static PrettyDebug PD_Exception("CERTI_EXCEPTION",__FILE__);
 
@@ -158,4 +179,4 @@
     PD_Exception[pdExcept] << msg.str().c_str();
     return msg.str();
 }
-// $Id: Exception.cc,v 3.17 2008/12/07 20:16:12 gotthardp Exp $
+// $Id: Exception.cc,v 3.17.8.1 2009/10/21 09:28:20 adele Exp $

Index: libCERTI/Exception.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Exception.hh,v
retrieving revision 3.8
retrieving revision 3.8.8.1
diff -u -b -r3.8 -r3.8.8.1
--- libCERTI/Exception.hh       7 Dec 2008 20:16:13 -0000       3.8
+++ libCERTI/Exception.hh       21 Oct 2009 09:28:20 -0000      3.8.8.1
@@ -20,7 +20,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: Exception.hh,v 3.8 2008/12/07 20:16:13 gotthardp Exp $
+// $Id: Exception.hh,v 3.8.8.1 2009/10/21 09:28:20 adele Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_EXCEPTION_HH
@@ -105,6 +105,27 @@
     e_SaveInProgress,
     e_SaveNotInitiated,
     e_SecurityError,
+    e_SharedMemoryNotOpen,
+    e_SharedMemoryNotAttached,
+    e_SharedMemoryNotClosed,
+    e_SemaphoreNotCreated,
+    e_SemaphoreNotOpen,
+    e_SemaphoreHandlingError,
+    e_HandleNotClosed,
+    e_SocketNotConnected,
+    e_MessageNotSent,
+    e_MessageNotReceived,
+    e_SocketNotClosed,
+    e_RingBufferNotCreated,
+    e_RingBufferNotClosed,
+    e_RingBufferNotDeleted,
+    e_RingBufferNotAttached,
+    e_MessageTooLong,
+    e_BufferFull,
+    e_BufferEmpty,
+    e_SocketSHMNotCreated,
+    e_SocketSHMNotOpen,
+    e_SocketSHMNotDeleted,
     e_SpecifiedSaveLabelDoesNotExist,
     e_TimeAdvanceAlreadyInProgress,
     e_TimeAdvanceWasNotInProgress,
@@ -266,9 +287,30 @@
 CERTI_EXCEPTION(UnknownLabel)
 CERTI_EXCEPTION(NetworkSignal)
 CERTI_EXCEPTION(NetworkError)
+CERTI_EXCEPTION(SharedMemoryNotOpen)
+CERTI_EXCEPTION(SharedMemoryNotAttached)
+CERTI_EXCEPTION(SharedMemoryNotClosed)
+CERTI_EXCEPTION(SemaphoreNotOpen)
+CERTI_EXCEPTION(SemaphoreHandlingError)
+CERTI_EXCEPTION(SemaphoreNotCreated)
+CERTI_EXCEPTION(SocketNotConnected)
+CERTI_EXCEPTION(MessageNotSent)
+CERTI_EXCEPTION(MessageNotReceived)
+CERTI_EXCEPTION(SocketNotClosed)
+CERTI_EXCEPTION(HandleNotClosed)
+CERTI_EXCEPTION(RingBufferNotCreated)
+CERTI_EXCEPTION(RingBufferNotClosed)
+CERTI_EXCEPTION(RingBufferNotDeleted)
+CERTI_EXCEPTION(RingBufferNotAttached)
+CERTI_EXCEPTION(MessageTooLong)
+CERTI_EXCEPTION(BufferEmpty)
+CERTI_EXCEPTION(BufferFull)
+CERTI_EXCEPTION(SocketSHMNotCreated)
+CERTI_EXCEPTION(SocketSHMNotOpen)
+CERTI_EXCEPTION(SocketSHMNotDeleted)
 
 } // namespace certi
 
 #endif // _CERTI_EXCEPTION_HH
 
-// $Id: Exception.hh,v 3.8 2008/12/07 20:16:13 gotthardp Exp $
+// $Id: Exception.hh,v 3.8.8.1 2009/10/21 09:28:20 adele Exp $

Index: libCERTI/RingBuffer.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/RingBuffer.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- libCERTI/RingBuffer.cc      12 Oct 2009 12:02:43 -0000      1.1.2.1
+++ libCERTI/RingBuffer.cc      21 Oct 2009 09:28:20 -0000      1.1.2.2
@@ -40,7 +40,8 @@
 RingBuffer::RingBuffer(const std::string& RingBuffer_Name,
                       const BUFFER_SIDE_t& RingBuffer_Side,
                        const int RingBuffer_Size,
-                       const std::string& Shm_Sem_Type ) {
+                       const std::string& Shm_Sem_Type )
+                       throw (certi::RingBufferNotCreated) {
 
 #ifdef DEBUG
 std::cout << "-----------------------------------------------------------" << 
std::endl ;
@@ -82,11 +83,25 @@
 
 
 if(_Side == BUFFER_SC){
+    try {
   _Sem_SC->Create_Init(1, 
Semaphore::buildSemName(RingBuffer_Name+"_BUFFER_SC")) ;
   }
+    catch(certi::SemaphoreNotCreated& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+  }
 else{
+    try {
   _Sem_CS->Create_Init(1, 
Semaphore::buildSemName(RingBuffer_Name+"_BUFFER_CS")) ;
   }
+    catch(certi::SemaphoreNotCreated& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+  }
 
 
 if(_Side == BUFFER_SC){
@@ -135,10 +150,39 @@
 }
 
 if(_Side == BUFFER_SC){
+    try {
      _Shm_SC->Open() ;
+    }
+    catch(certi::SharedMemoryNotOpen& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+    try {
      _Shm_SC->Attach() ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+    try {
      _Pw_Pr_SC->Open() ;
+    }
+    catch(certi::SharedMemoryNotOpen& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+    try {
      _Pw_Pr_SC->Attach() ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+
     #ifdef DEBUG
     std::cout << " The SHMs for RingBuffer from SERVER to CUSTOMER Exchange 
are Created and Attached " << std::endl ;
     std::cout << " -----> Adresse : _Shm_SC->GetShm() = " << _Shm_SC->GetShm() 
<< std::endl ;
@@ -146,50 +190,154 @@
     #endif
      }
 else{
+    try {
      _Shm_CS->Open() ;
+    }
+    catch(certi::SharedMemoryNotOpen& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+    try {
      _Shm_CS->Attach() ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+    try {
      _Pw_Pr_CS->Open() ;
+    }
+    catch(certi::SharedMemoryNotOpen& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+    try {
      _Pw_Pr_CS->Attach() ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "RingBuffer::RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotCreated("RingBuffer() failed.")) ;;
+    }
+
      #ifdef DEBUG
      std::cout << " The SHMs for RingBuffer from CUSTOMER to SERVER Exchanges 
are Created and Attached" << std::endl ;
      std::cout << "  -----> Adresse : _Shm_CS->GetShm() = " << 
_Shm_CS->GetShm() << std::endl ;
      std::cout << "  -----> Adresse : _Pw_Pr_CS->GetShm() = " << 
_Pw_Pr_CS->GetShm() << std::endl ;
      #endif
+
      }
 }  // End of RingBuffer Constructor
 // ************************************************
 // Method : RingBuffer::Attach()
 // ************************************************
-void RingBuffer::Attach() {
+void RingBuffer::Attach() throw(certi::RingBufferNotAttached) {
 
 if(_Side == BUFFER_CS){
+    try {
   _Sem_SC->Attach(Semaphore::buildSemName(_Name+"_BUFFER_SC")) ;
   }
+    catch(certi::SemaphoreNotOpen& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+  }
 else{
+    try {
   _Sem_CS->Attach(Semaphore::buildSemName(_Name+"_BUFFER_CS")) ;
   }
+    catch(certi::SemaphoreNotOpen& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+  }
 
 if(_Side == BUFFER_CS){
+    try {
      _Shm_SC->Open() ;
+    }
+    catch(certi::SharedMemoryNotOpen& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+    try {
      _Shm_SC->Attach() ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+    try {
      _Pw_Pr_SC->Open() ;
+    }
+    catch(certi::SharedMemoryNotOpen& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+    try {
      _Pw_Pr_SC->Attach() ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+
      #ifdef DEBUG
      std::cout << " The SHMs for RingBuffer from SERVER to CUSTOMER Exchanges 
are Identified and Attached " << std::endl ;
      std::cout << " Adresse : _Shm_SC->GetShm() = " << _Shm_SC->GetShm() << 
std::endl ;
      std::cout << " Adresse : _Pw_Pr_SC->GetShm() = " << _Pw_Pr_SC->GetShm() 
<< std::endl ;
      #endif
+
      }
 else{
+    try {
      _Shm_CS->Open() ;
+    }
+    catch(certi::SharedMemoryNotOpen& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+    try {
      _Shm_CS->Attach() ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+    try {
      _Pw_Pr_CS->Open() ;
+    }
+    catch(certi::SharedMemoryNotOpen& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+    try {
      _Pw_Pr_CS->Attach() ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotAttached("Attach() failed.")) ;;
+    }
+
      #ifdef DEBUG
      std::cout << " The SHMs for RingBuffer from CUSTOMER to SERVER Exchanges 
are Identified and Attached " << std::endl ;
      std::cout << " Adresse : _Shm_CS->GetShm() = " << _Shm_CS->GetShm() << 
std::endl ;
      std::cout << " Adresse : _Pw_Pr_CS->GetShm() = " << _Pw_Pr_CS->GetShm() 
<< std::endl ;
      #endif
+
      }
 
 if(_Side == BUFFER_CS){
@@ -204,13 +352,27 @@
 // ************************************************
 // Destructor
 // ************************************************
-RingBuffer ::~RingBuffer (){
+RingBuffer ::~RingBuffer () throw(certi::RingBufferNotDeleted) {
 if(_Side == BUFFER_SC){
+    try {
    _Sem_SC->Delete() ;
    }
+    catch(certi::HandleNotClosed& e)
+    {
+        std::cout << "RingBuffer::~RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotDeleted("~RingBuffer() failed.")) ;;
+    }
+   }
 else{
+    try {
    _Sem_CS->Delete() ;
    }
+    catch(certi::HandleNotClosed& e)
+    {
+        std::cout << "RingBuffer::~RingBuffer() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::RingBufferNotDeleted("~RingBuffer() failed.")) ;;
+    }
+   }
 
 delete _Sem_SC  ;
 delete _Sem_CS  ;
@@ -223,20 +385,29 @@
 // ************************************************
 // Method : RingBuffer::Send(...)
 // ************************************************
-void RingBuffer::Send(void *Buffer, size_t Size) {
+void RingBuffer::Send(void *Buffer, size_t Size)
+                      throw (certi::MessageNotSent,
+                             certi::MessageTooLong,
+                             certi::BufferFull) {
 
 #ifdef DEBUG
 std::cout << "RingBuffer --> Try to Send..." << std::endl ;
 #endif
 
 if (Size > _Size) {
-   perror("RingBuffer::Send(...) : Size too big !! ") ;
-   exit(1);
+   throw(certi::MessageTooLong("RingBuffer::Send() failed.")) ;
    }
 
 if(_Side == BUFFER_SC){
-
+   try {
     _Sem_SC->P() ;
+   }
+   catch(certi::SemaphoreHandlingError& e)
+   {
+        std::cout << "RingBuffer::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::MessageNotSent("RingBuffer::Send() failed.")) ;;
+   }
+
     memcpy(_Tab_SC, _Pw_Pr_SC->GetShm(), 3 * sizeof(int) ) ;
 
     #ifdef DEBUG
@@ -244,8 +415,15 @@
     #endif
 
     if (Size > _Tab_SC[0]) { // Test si il y a assez de place disponible dans 
le buffer (Exeption à envoyer)
-    perror("Probleme !! ") ;
-    exit(1);
+       try {
+        _Sem_SC->V() ;
+       }
+       catch(certi::SemaphoreHandlingError& e)
+       {
+          std::cout << "RingBuffer::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+          throw (certi::MessageNotSent("RingBuffer::Send() failed.")) ;;
+       }
+       throw(certi::BufferFull("RingBuffer::Send() failed.")) ;
     }
 
     if ( (_Tab_SC[2] > _Tab_SC[1]) || ((_Tab_SC[1] >= _Tab_SC[2]) && (Size + 
_Tab_SC[1] <= _Size)) ) {
@@ -259,7 +437,6 @@
         memcpy((void *)((char *)(_Shm_SC->GetShm())+ (sizeof(void *) * 
_Tab_SC[1])) , Buffer, Size) ;
 
         _Tab_SC[0] -= Size ;
-        // _Tab_SC[1] += Size ;
         _Tab_SC[1] = (_Tab_SC[1] + Size) % _Size ;
         }
    else {
@@ -270,11 +447,11 @@
         int Rest_byte_in_SHM =  _Size - _Tab_SC[1] ;
 
         memcpy((void *)((char *)(_Shm_SC->GetShm())+ (sizeof(void *) * 
_Tab_SC[1])), Buffer, Rest_byte_in_SHM ) ;
+
         memcpy(_Shm_SC->GetShm(), (void *)((char *)(Buffer) + (sizeof(void *) 
* Rest_byte_in_SHM)), Size - Rest_byte_in_SHM ) ;
 
         _Tab_SC[1] = (_Tab_SC[1] + Size) % _Size ;
         _Tab_SC[0] -= Size ;
-        // _Tab_SC[0] = _Tab_SC[2] - _Tab_SC[1]  ;
 
         } // Fin du if ((_Tab_SC[2] >= _Tab_SC[1]) ...) /else
 
@@ -284,11 +461,25 @@
 
      memcpy(_Pw_Pr_SC->GetShm(), _Tab_SC, 3 * sizeof(int) ) ;
 
+     try {
      _Sem_SC->V() ;
      }
+     catch(certi::SemaphoreHandlingError& e)
+     {
+        std::cout << "RingBuffer::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::MessageNotSent("RingBuffer::Send() failed.")) ;;
+     }
+     }
 else{
-
+    try {
     _Sem_CS->P() ;
+    }
+    catch(certi::SemaphoreHandlingError& e)
+    {
+       std::cout << "RingBuffer::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotSent("RingBuffer::Send() failed.")) ;;
+    }
+
     memcpy(_Tab_CS, _Pw_Pr_CS->GetShm(), 3 * sizeof(int) ) ;
 
     #ifdef DEBUG
@@ -296,8 +487,15 @@
     #endif
 
     if (Size > _Tab_CS[0]) { // Test si il y a assez de place disponible dans 
le buffer
-    perror("Probleme !! ") ;
-    exit(1);
+       try {
+          _Sem_CS->V() ;
+       }
+       catch(certi::SemaphoreHandlingError& e)
+       {
+          std::cout << "RingBuffer::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+          throw (certi::MessageNotSent("RingBuffer::Send() failed.")) ;;
+       }
+       throw(certi::BufferFull("RingBuffer::Send() failed.")) ;
     }
 
     if ( (_Tab_CS[2] > _Tab_CS[1]) || ((_Tab_CS[1] >= _Tab_CS[2]) && (Size + 
_Tab_CS[1] <= _Size)) ) {
@@ -309,8 +507,8 @@
         #endif
 
         memcpy((void *)((char *)(_Shm_CS->GetShm())+ (sizeof(void *) * 
_Tab_CS[1])) , Buffer, Size) ;
+
         _Tab_CS[0] -= Size ;
-       // _Tab_CS[1] += Size ;
        _Tab_CS[1] = (_Tab_CS[1] + Size) % _Size ;
         }
    else {
@@ -319,11 +517,13 @@
         #endif
 
         int Rest_byte_in_SHM =  _Size - _Tab_CS[1] ;
+
         memcpy((void *)((char *)(_Shm_CS->GetShm())+ (sizeof(void *) * 
_Tab_CS[1])), Buffer, Rest_byte_in_SHM ) ;
+
         memcpy(_Shm_CS->GetShm(), (void *)((char *)(Buffer) + (sizeof(void *) 
* Rest_byte_in_SHM)), Size - Rest_byte_in_SHM ) ;
 
          _Tab_CS[1] = (_Tab_CS[1] + Size) % _Size ;
-         // _Tab_CS[0] = _Tab_CS[2] - _Tab_CS[1]  ;
+
          _Tab_CS[0] -= Size ;
 
        }
@@ -334,40 +534,67 @@
 
      memcpy(_Pw_Pr_CS->GetShm(), _Tab_CS, 3 * sizeof(int) ) ;
 
+     try {
      _Sem_CS->V() ;
      }
+     catch(certi::SemaphoreHandlingError& e)
+     {
+        std::cout << "RingBuffer::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::MessageNotSent("RingBuffer::Send() failed.")) ;;
+     }
+     }
 
 #ifdef DEBUG
 std::cout << "RingBuffer --> Send Complete !!" << std::endl ;
 #endif
+
 } // End of RingBuffer::Send(...)
 
 // ************************************************
 // Method : RingBuffer::Receive(...)
 // ************************************************
-void RingBuffer::Receive(void *Buffer, size_t Size) {
+void RingBuffer::Receive(void *Buffer, size_t Size)
+                         throw (certi::MessageNotReceived,
+                                certi::MessageTooLong,
+                                certi::BufferEmpty) {
 
 #ifdef DEBUG
 std::cout << "RingBuffer -->  Try to Receive..." << std::endl ;
 #endif
 
 if (Size > _Size) {
-    perror("RingBuffer::Receive(...) : Size too big !! ") ;
-    exit(1);
+   throw(certi::MessageTooLong("RingBuffer::Receive() failed.")) ;
     }
 
 if(_Side == BUFFER_SC){
-
+    try {
     _Sem_CS->P() ;
+    }
+    catch(certi::SemaphoreHandlingError& e)
+    {
+       std::cout << "RingBuffer::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotReceived("RingBuffer::Receive() failed.")) ;;
+    }
 
     memcpy(_Tab_CS, _Pw_Pr_CS->GetShm(), 3 * sizeof(int) ) ;
 
     if (_Tab_CS[0] == _Size ) { // Test si il y a assez de place disponible 
dans le buffer (Exeption à envoyer)
+       try {
+          _Sem_CS->V() ;
+       }
+       catch(certi::SemaphoreHandlingError& e)
+       {
+          std::cout << "RingBuffer::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+          throw (certi::MessageNotReceived("RingBuffer::Receive() failed.")) ;;
+       }
+       throw(certi::BufferEmpty("RingBuffer::Receive() failed.")) ;
+
        #ifdef DEBUG
-       std::cout << "RingBuffer::Receive(...) --> Nothing to Read on _Shm_SC 
!!"<< std::endl ;
+       std::cout << "lllll RingBuffer::Receive(...) --> Nothing to Read on 
_Shm_SC !!"<< std::endl ;
        #endif
     }
     else {
+
           #ifdef DEBUG
          std::cout << "RingBuffer::Receive(...) --> BEGIN Algorithm : Count_CS 
= " << _Tab_CS[0] << " | Write_CS = " << _Tab_CS[1] << "| Read_CS = " << 
_Tab_CS[2] << std::endl ;
          #endif
@@ -383,16 +610,18 @@
             memcpy(Buffer, (void *)((char *)(_Shm_CS->GetShm())+ (sizeof(void 
*) * _Tab_CS[2])) ,Size) ;
 
              _Tab_CS[0] += Size ;
-            // _Tab_CS[0] = (_Tab_CS[0] + Size) % _Size ;
             _Tab_CS[2] += Size ;
             }
        else {
+
             #ifdef DEBUG
             std::cout << "RingBuffer::Receive(...) --> Utilisation memcpy 
Double " << std::endl ;
             #endif
 
             int Rest_byte_in_SHM =  _Size - _Tab_CS[2] ;
+
             memcpy( Buffer, (void *)((char *)(_Shm_CS->GetShm())+ (sizeof(void 
*) * _Tab_CS[2])), Rest_byte_in_SHM ) ;
+
             memcpy( (void *)((char *)(Buffer) + (sizeof(void *) * 
Rest_byte_in_SHM)), _Shm_CS->GetShm(), Size - Rest_byte_in_SHM ) ;
 
            _Tab_CS[2] = (_Tab_CS[2] + Size) % _Size ;
@@ -401,25 +630,56 @@
 
         #ifdef DEBUG
         std::cout << "RingBuffer::Receive(...) --> END Algorithm : Count_CS = 
" << _Tab_CS[0] << " | Write_CS = " << _Tab_CS[1] << "| Read_CS = " << 
_Tab_CS[2] << std::endl ;
-        #endif
         std::cout << "AVANT  memcpy(_Pw_Pr_CS->GetShm(), _Tab_CS, 3 * 
sizeof(int) ) ; !! " << std::endl ;
+        #endif
+
         memcpy(_Pw_Pr_CS->GetShm(), _Tab_CS, 3 * sizeof(int) ) ;
+
+        #ifdef DEBUG
         std::cout << "APRES  memcpy(_Pw_Pr_CS->GetShm(), _Tab_CS, 3 * 
sizeof(int) ) ; !! " << std::endl ;
+        #endif
+
         } // Fin du else for if (_Tab_SC[0] == _Size )
 
+     try {
      _Sem_CS->V() ;
      }
+     catch(certi::SemaphoreHandlingError& e)
+     {
+       std::cout << "RingBuffer::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotReceived("RingBuffer::Receive() failed.")) ;;
+     }
+     }
 else{
-
+    try {
     _Sem_SC->P() ;
+    }
+    catch(certi::SemaphoreHandlingError& e)
+    {
+       std::cout << "RingBuffer::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotReceived("RingBuffer::Receive() failed.")) ;;
+    }
+
        memcpy(_Tab_SC, _Pw_Pr_SC->GetShm(), 3 * sizeof(int) ) ;
 
     if (_Tab_SC[0] == _Size ) { // Test si il y a assez de place disponible 
dans le buffer (Exeption à envoyer)
+       try {
+         _Sem_SC->V() ;
+       }
+       catch(certi::SemaphoreHandlingError& e)
+       {
+          std::cout << "RingBuffer::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+          throw (certi::MessageNotReceived("RingBuffer::Receive() failed.")) ;
+       }
+       throw(certi::BufferEmpty("RingBuffer::Receive() failed.")) ;
+
          #ifdef DEBUG
          std::cout << "RingBuffer::Receive(...) --> Nothing to Read on _Shm_CS 
!!"<< std::endl ;
          #endif
+
          }
     else {
+
          #ifdef DEBUG
          std::cout << "RingBuffer::Receive(...) --> Adresse _Tab_SC = " << 
_Tab_SC << " Adresse _Pw_Pr_SC = " << _Pw_Pr_SC << std::endl ;
          std::cout << "RingBuffer::Receive(...) --> Begin of Algorithm : 
Count_SC = " << _Tab_SC[0] << " | Write_SC = " << _Tab_SC[1] << "| Read_SC = " 
<< _Tab_SC[2] << std::endl ;
@@ -436,20 +696,21 @@
             memcpy( Buffer, (void *)((char *)(_Shm_SC->GetShm())+ (sizeof(void 
*) * _Tab_SC[2])) , Size) ;
 
             _Tab_SC[0] += Size ;
-           //  _Tab_SC[0] = (_Tab_SC[0] + Size) % _Size ;
             _Tab_SC[2] += Size ;
             }
        else {
+
             #ifdef DEBUG
             std::cout << "RingBuffer::Receive(...) --> Utilisation memcpy 
Double " << std::endl ;
             #endif
 
             int Rest_byte_in_SHM =  _Size - _Tab_SC[2] ;
+
             memcpy(Buffer, (void *)((char *)(_Shm_SC->GetShm())+ (sizeof(void 
*) * _Tab_SC[2])), Rest_byte_in_SHM ) ;
+
             memcpy((void *)((char *)(Buffer) + (sizeof(void *) * 
Rest_byte_in_SHM)), _Shm_SC->GetShm(), Size - Rest_byte_in_SHM ) ;
 
             _Tab_SC[2] = (_Tab_SC[2] + Size) % _Size ;
-            // _Tab_CS[0] = _Tab_CS[2] - _Tab_CS[1]  ;
             _Tab_SC[0] += Size ;
             }
 
@@ -458,25 +719,81 @@
          #endif
 
          memcpy(_Pw_Pr_SC->GetShm(), _Tab_SC, 3 * sizeof(int) ) ;
-         }  // Fin du else for if (_Tab_CS[0] == _Size )
 
+         }  // Fin du else for if (_Tab_CS[0] == _Size )
+     try {
      _Sem_SC->V() ;
      }
+     catch(certi::SemaphoreHandlingError& e)
+     {
+       std::cout << "RingBuffer::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotReceived("RingBuffer::Receive() failed.")) ;;
+     }
+     }
 
 #ifdef DEBUG
 std::cout << "RingBuffer --> Receive complete!!!" << std::endl ;
 #endif
+
 } // End of RingBuffer::Receive(...)
 
 // ************************************************
 // Method : RingBuffer::Close()
 // ************************************************
-void RingBuffer::Close() {
-
-_Shm_SC->Close() ;
-_Shm_CS->Close() ;
-_Pw_Pr_SC->Close() ;
-_Pw_Pr_CS->Close() ;
+void RingBuffer::Close()
+                throw (certi::RingBufferNotClosed) {
+try {
+   _Shm_SC->Close() ;
+}
+catch(certi::SharedMemoryNotClosed& e)
+{
+    std::cout << "RingBuffer::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::RingBufferNotClosed("RingBuffer::Close() failed.")) ;;
+}
+catch(certi::HandleNotClosed& e)
+{
+    std::cout << "RingBuffer::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::RingBufferNotClosed("RingBuffer::Close() failed.")) ;;
+}
+try {
+   _Shm_CS->Close() ;
+}
+catch(certi::SharedMemoryNotClosed& e)
+{
+    std::cout << "RingBuffer::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::RingBufferNotClosed("RingBuffer::Close() failed.")) ;;
+}
+catch(certi::HandleNotClosed& e)
+{
+    std::cout << "RingBuffer::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::RingBufferNotClosed("RingBuffer::Close() failed.")) ;;
+}
+try {
+   _Pw_Pr_SC->Close() ;
+}
+catch(certi::SharedMemoryNotClosed& e)
+{
+    std::cout << "RingBuffer::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::RingBufferNotClosed("RingBuffer::Close() failed.")) ;;
+}
+catch(certi::HandleNotClosed& e)
+{
+    std::cout << "RingBuffer::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::RingBufferNotClosed("RingBuffer::Close() failed.")) ;;
+}
+try {
+   _Pw_Pr_CS->Close() ;
+}
+catch(certi::SharedMemoryNotClosed& e)
+{
+    std::cout << "RingBuffer::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::RingBufferNotClosed("RingBuffer::Close() failed.")) ;;
+}
+catch(certi::HandleNotClosed& e)
+{
+    std::cout << "RingBuffer::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::RingBufferNotClosed("RingBuffer::Close() failed.")) ;;
+}
 
 } // End of RingBuffer::Close()
 

Index: libCERTI/RingBuffer.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/RingBuffer.hh,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- libCERTI/RingBuffer.hh      12 Oct 2009 12:02:43 -0000      1.1.2.1
+++ libCERTI/RingBuffer.hh      21 Oct 2009 09:28:20 -0000      1.1.2.2
@@ -35,16 +35,24 @@
     RingBuffer(const std::string& RingBuffer_Name,
                const BUFFER_SIDE_t& RingBuffer_Side,
                const int RingBuffer_Size,
-               const std::string& SHM_Sem_Type ) ; // SHM_Sem_Type = 
Posix,SysV ou Win32
+               const std::string& SHM_Sem_Type ) // SHM_Sem_Type = Posix,SysV 
ou Win32
+               throw(certi::RingBufferNotCreated) ;
     // Destructor
-    ~RingBuffer ();
+    ~RingBuffer () throw(certi::RingBufferNotDeleted) ;
 
-    void Attach() ;
+    void Attach() throw(certi::RingBufferNotAttached) ;
 
-    void Send(void *Buffer, size_t Size) ; // To send Data on a memory segment
-    void Receive(void *Buffer, size_t Size) ; // To receive Data on a memory 
segment
+    void Send(void *Buffer, size_t Size)      // To send Data on a memory 
segment
+              throw (certi::MessageNotSent,
+                     certi::MessageTooLong,
+                     certi::BufferFull) ;
 
-    void Close(); // To Close the two SHMs
+    void Receive(void *Buffer, size_t Size)   // To receive Data on a memory 
segment
+              throw (certi::MessageNotReceived,
+                     certi::MessageTooLong,
+                     certi::BufferEmpty) ;
+
+    void Close() throw (certi::RingBufferNotClosed) ; // To Close the two SHMs
 
 protected :
     std::string _Name ;

Index: libCERTI/Semaphore.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/Semaphore.hh,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -b -r1.1.2.5 -r1.1.2.6
--- libCERTI/Semaphore.hh       22 Sep 2009 09:56:45 -0000      1.1.2.5
+++ libCERTI/Semaphore.hh       21 Oct 2009 09:28:20 -0000      1.1.2.6
@@ -2,6 +2,7 @@
 #define SEMAPHORE_H
 
 #include "certi.hh"
+#include "Exception.hh"
 // Systems includes
 #include <string>
 

Index: libCERTI/SemaphoreWin32.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SemaphoreWin32.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- libCERTI/SemaphoreWin32.cc  12 Oct 2009 12:02:43 -0000      1.1.2.1
+++ libCERTI/SemaphoreWin32.cc  21 Oct 2009 09:28:20 -0000      1.1.2.2
@@ -15,7 +15,8 @@
 // ************************************************
 // Method : SemaphoreWin32::Create_Init(...)
 // ************************************************
-void SemaphoreWin32::Create_Init(const int initval, const std::string& 
New_Semname) {
+void SemaphoreWin32::Create_Init(const int initval, const std::string& 
New_Semname)
+                                 throw(certi::SemaphoreNotCreated) {
 
 _hSemaphore = CreateSemaphore(
                       (LPSECURITY_ATTRIBUTES)NULL,             // security 
attributes
@@ -24,9 +25,7 @@
                       (LPCTSTR)(New_Semname.c_str()));         // named 
semaphore
 
  if (_hSemaphore == NULL){
-      _tprintf(TEXT("CreateSemaphore() in SemaphoreWin32::Create_Init(...) 
(%d).n"),
-             GetLastError());
-      exit(1) ;
+      throw(certi::SemaphoreNotCreated("CreateSemaphore() failed.")) ;
  }
  #ifdef DEBUG
  std::cout << "We create the semaphore identified by handle : " << _hSemaphore 
<< " and name : " << New_Semname << std::endl ;
@@ -37,9 +36,8 @@
 // ************************************************
 // Method : SemaphoreWin32::Attach(...)
 // ************************************************
-void SemaphoreWin32::Attach(const std::string& New_Semname) {
-
-
+void SemaphoreWin32::Attach(const std::string& New_Semname)
+                            throw(certi::SemaphoreNotOpen){
 
 // Open the semaphore
 
@@ -54,9 +52,7 @@
 
    if (_hSemaphore == NULL)
    {
-      _tprintf(TEXT("Could not open semaphore object (%d).n"),
-             GetLastError());
-      exit (1);
+        throw(certi::SemaphoreNotOpen("OpenSemaphore() failed.")) ;
    }
 
 } // End of method : Attach(...)
@@ -65,7 +61,8 @@
 // Method : SemaphoreWin32::P
 // ************************************************
 
-void 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 ;
@@ -87,9 +84,7 @@
 
           default:
              // Handle errors
-             _tprintf(TEXT("Error with WaitForSingleObject() in 
SemaphoreWin32::P() (%d).n"),
-             GetLastError());
-             exit(1);
+             throw(certi::SemaphoreHandlingError("WaitForSingleObject() 
failed.")) ;
       }
 
 #ifdef DEBUG
@@ -103,7 +98,8 @@
 // Method : SemaphoreWin32::V
 // ************************************************
 
-void 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 ;
@@ -117,9 +113,7 @@
         NULL) ;       // not interested in previous count
 
   if (retcode == 0) {
-    _tprintf(TEXT("Error with ReleaseSemaphore() in SemaphoreWin32::V() 
(%d).n"),
-             GetLastError());
-    exit(1);
+      throw(certi::SemaphoreHandlingError("ReleaseSemaphore() failed.")) ;
     }
 
 #ifdef DEBUG
@@ -131,7 +125,8 @@
 // ************************************************
 // Method : SemaphoreWin32::Delete
 // ************************************************
-void SemaphoreWin32::Delete(){
+void SemaphoreWin32::Delete()
+                    throw(certi::HandleNotClosed) {
 
 BOOL WINAPI retcode ;
 
@@ -142,7 +137,6 @@
 retcode = CloseHandle(_hSemaphore);
 
 if(retcode == 0)
-    _tprintf(TEXT("Error with CloseHandle() in SemaphoreWin32::Delete() 
(%d).n"),
-             GetLastError());
+   throw(certi::HandleNotClosed("CloseHandle() failed.")) ;
 } // End of Delete()
 

Index: libCERTI/SemaphoreWin32.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SemaphoreWin32.hh,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- libCERTI/SemaphoreWin32.hh  12 Oct 2009 12:02:43 -0000      1.1.2.1
+++ libCERTI/SemaphoreWin32.hh  21 Oct 2009 09:28:20 -0000      1.1.2.2
@@ -24,11 +24,16 @@
     public :
     SemaphoreWin32() ;
     virtual ~SemaphoreWin32() ;
-    void Create_Init(const int initval, const std::string& New_Semname) ;
-    void Attach(const std::string& New_Semname ) ;
-    void P() ;
-    void V() ;
-    void Delete() ;
+    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) ;
 
 } ;
 

Index: libCERTI/SocketSHM.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SocketSHM.cc,v
retrieving revision 1.1.4.4
retrieving revision 1.1.4.5
diff -u -b -r1.1.4.4 -r1.1.4.5
--- libCERTI/SocketSHM.cc       4 Sep 2009 15:57:43 -0000       1.1.4.4
+++ libCERTI/SocketSHM.cc       21 Oct 2009 09:28:20 -0000      1.1.4.5
@@ -9,38 +9,102 @@
 // ************************************************
 // Method : SocketSHM::Connect()
 // ************************************************
-void SocketSHM::Connect() {
+void SocketSHM::Connect() throw (certi::SocketNotConnected) {
+
+#ifdef DEBUG
+std::cout << "Try to Connect..." << std::endl ;
+#endif
 
 if(_Side == SHM_CS){
+    try {
   _Sem_full_SC->Attach(Semaphore::buildSemName(_Name+"_FULL_SC")) ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "SocketSHM::Connect() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::SocketNotConnected("Connect() failed."));
+    }
+    try {
   _Sem_empty_SC->Attach(Semaphore::buildSemName(_Name+"_EMPTY_SC")) ;
   }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "SocketSHM::Connect() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::SocketNotConnected("Connect() failed."));
+    }
+  }
 else{
+    try {
   _Sem_full_CS->Attach(Semaphore::buildSemName(_Name+"_FULL_CS")) ;
+    }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "SocketSHM::Connect() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::SocketNotConnected("Connect() failed."));
+    }
+    try {
   _Sem_empty_CS->Attach(Semaphore::buildSemName(_Name+"_EMPTY_CS")) ;
   }
+    catch(certi::SharedMemoryNotAttached& e)
+    {
+        std::cout << "SocketSHM::Connect() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::SocketNotConnected("Connect() failed."));
+    }
+  }
 
 }
 
 // ************************************************
 // Method : SocketSHM::Send(...)
 // ************************************************
-void SocketSHM::Send(void *Buffer) {
+void SocketSHM::Send(void *Buffer) throw (certi::MessageNotSent) {
 
 #ifdef DEBUG
 std::cout << "Try to Send..." << std::endl ;
 #endif
 
 if(_Side == SHM_SC){
+    try {
      _Sem_empty_SC->P() ;     
+    }
+    catch(certi::SemaphoreHandlingError& e)
+    {
+        std::cout << "SocketSHM::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::MessageNotSent("Send() failed.")) ;
+    }
+
     memcpy(_Shm_SC->GetShm(), Buffer, _Shm_SC->GetSize());
+
+    try {
      _Sem_full_SC->V() ;
      } 
+    catch(certi::SemaphoreHandlingError& e)
+    {
+        std::cout << "SocketSHM::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::MessageNotSent("Send() failed.")) ;
+    }
+    }
 else{
+    try {
      _Sem_empty_CS->P() ;  
+    }
+    catch(certi::SemaphoreHandlingError& e)
+    {
+        std::cout << "SocketSHM::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::MessageNotSent("Send() failed.")) ;
+    }
+
      memcpy(_Shm_CS->GetShm(), Buffer, _Shm_CS->GetSize());
+
+     try {
      _Sem_full_CS->V() ;
      } 
+     catch(certi::SemaphoreHandlingError& e)
+     {
+        std::cout << "SocketSHM::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+        throw (certi::MessageNotSent("Send() failed.")) ;
+     }
+    }
 
 #ifdef DEBUG
 std::cout << "Send Complete !!" << std::endl ;
@@ -51,22 +115,54 @@
 // ************************************************
 // Method : SocketSHMS::Receive(...)
 // ************************************************
-void SocketSHM::Receive(void *Buffer) {
+void SocketSHM::Receive(void *Buffer) throw (certi::MessageNotReceived) {
 
 #ifdef DEBUG
 std::cout << "Try to Receive..." << std::endl ;
 #endif
 
 if(_Side == SHM_SC){
+    try {
      _Sem_full_CS->P() ; 
+    }
+    catch(certi::SemaphoreHandlingError& e)
+    {
+       std::cout << "SocketSHM::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotReceived("Receive() failed.")) ;
+    }
+
     memcpy(Buffer, _Shm_CS->GetShm(), _Shm_CS->GetSize());
+
+    try {
      _Sem_empty_CS->V() ;
      } 
+    catch(certi::SemaphoreHandlingError& e)
+    {
+       std::cout << "SocketSHM::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotReceived("Receive() failed.")) ;
+    }
+    }
 else{
+    try {
      _Sem_full_SC->P() ;  
+    }
+    catch(certi::SemaphoreHandlingError& e)
+    {
+       std::cout << "SocketSHM::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotReceived("Receive() failed.")) ;
+    }
+
      memcpy( Buffer, _Shm_SC->GetShm(), _Shm_SC->GetSize());
+
+    try {
     _Sem_empty_SC->V() ;
      } 
+    catch(certi::SemaphoreHandlingError& e)
+    {
+       std::cout << "SocketSHM::Receive() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+       throw (certi::MessageNotReceived("Receive() failed.")) ;
+    }
+    }
 
 #ifdef DEBUG
 std::cout << "Receive complete!!!" << std::endl ;
@@ -77,10 +173,38 @@
 // ************************************************
 // Method : SocketSHM::Close()
 // ************************************************
-void SocketSHM::Close() {
+void SocketSHM::Close() throw(certi::SocketNotClosed) {
+
+#ifdef DEBUG
+std::cout << "Try to Close..." << std::endl ;
+#endif
 
-_Shm_SC->Close() ;
-_Shm_CS->Close() ;
+try {
+   _Shm_SC->Close() ;
+}
+catch (certi::SharedMemoryNotClosed& e)
+{
+    std::cout << "SocketSHM::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::SocketNotClosed("Close() failed.")) ;
+}
+catch (certi::HandleNotClosed& e)
+{
+    std::cout << "SocketSHM::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::SocketNotClosed("Close() failed.")) ;
+}
+try {
+   _Shm_CS->Close() ;
+}
+catch (certi::SharedMemoryNotClosed& e)
+{
+    std::cout << "SocketSHM::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::SocketNotClosed("Close() failed.")) ;
+}
+catch (certi::HandleNotClosed& e)
+{
+    std::cout << "SocketSHM::Close() Exception. " <<  "Name is : " << e._name 
<< " Reason is : " << e._reason << std::endl ;
+    throw (certi::SocketNotClosed("Close() failed.")) ;
+}
 
 } // End of --> SocketSHM::Close()
 

Index: libCERTI/SocketSHM.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/Attic/SocketSHM.hh,v
retrieving revision 1.1.4.4
retrieving revision 1.1.4.5
diff -u -b -r1.1.4.4 -r1.1.4.5
--- libCERTI/SocketSHM.hh       22 Sep 2009 09:56:45 -0000      1.1.4.4
+++ libCERTI/SocketSHM.hh       21 Oct 2009 09:28:20 -0000      1.1.4.5
@@ -18,14 +18,17 @@
                const SHM_SIDE_t& Socket_Side,
                const int Socket_Size ) { _Name = Socket_Name ; _Side = 
Socket_Side ; _Size_Side = Socket_Size ; }
     // Destructor
-    virtual ~SocketSHM ();
+    virtual ~SocketSHM () ;
 
-    virtual void Connect() ;
+    virtual void Connect() throw (certi::SocketNotConnected) ;
 
-    virtual void Send(void *Buffer) ; // To send Data on a memory segment
-    virtual void Receive(void *Buffer) ; // To receive Data on a memory segment
+    virtual void Send(void *Buffer)
+                      throw (certi::MessageNotSent) ; // To send Data on a 
memory segment
+    virtual void Receive(void *Buffer)
+                      throw (certi::MessageNotReceived) ; // To receive Data 
on a memory segment
 
-    virtual void Close(); // To Close the two SHMs
+    virtual void Close()
+                throw(certi::SocketNotClosed) ; // To Close the two SHMs
 
 protected :
     std::string _Name ;

Index: test/utility/Main_SocketSHM.cc
===================================================================
RCS file: /sources/certi/certi/test/utility/Attic/Main_SocketSHM.cc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -b -r1.1.2.4 -r1.1.2.5
--- test/utility/Main_SocketSHM.cc      12 Oct 2009 09:08:45 -0000      1.1.2.4
+++ test/utility/Main_SocketSHM.cc      21 Oct 2009 09:28:21 -0000      1.1.2.5
@@ -94,6 +94,7 @@
                              Size) ;
 #endif
 // RingBuffer Socket SHM
+
 RingBuffer RingBuffer_AB(NAME_AB,
                          Buffer_Side,
                          MAX_SIZE,
@@ -112,12 +113,27 @@
 std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
 
 #ifdef _WIN32
-Socket_Win32_AB.Connect();
+try {
+   Socket_Win32_AB.Connect();
+}
+catch (certi::SocketNotConnected& e)
+{
+    std::cout << "Catch Exception SocketNotConnected" << std::endl ;
+    std::cout << "SocketSHM::Connect() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+}
 #else
 Socket_Posix_AB.Connect() ; // Connect to created Semaphores
 Socket_SysV_AB.Connect() ; // Connect to created Semaphores
 #endif
-RingBuffer_AB.Attach() ;
+
+try {
+    RingBuffer_AB.Attach() ;
+}
+catch (certi::RingBufferNotAttached& e)
+{
+    std::cout << "Catch Exception RingBufferNotAttached" << std::endl ;
+    std::cout << "RingBuffer::Attach() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+}
 
 // ****************************
 // Wainting for User Command n2
@@ -142,7 +158,17 @@
 
 // Open the Socket
 #ifdef _WIN32
-if (command=="Win32") Socket_Win32_AB.Open() ;
+if (command=="Win32")
+{
+    try {
+       Socket_Win32_AB.Open() ;
+    }
+    catch (certi::SocketSHMNotOpen& e)
+    {
+        std::cout << "Catch Exception SocketSHMNotOpen" << std::endl ;
+        std::cout << "SocketSHMWin32::Open() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+    }
+}
 #else
 if (command=="Posix") Socket_Posix_AB.Open() ;
 if (command=="SysV") Socket_SysV_AB.Open() ;
@@ -180,6 +206,7 @@
      std::cin >> command_RB ;
      std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
      if (command_RB=="S"){
+         try {
          RingBuffer_AB.Send(&Data_Write_RB,Size) ;
          std::cout << " ******** SEND ********" << std ::endl ;
          #ifdef SIDE_SC
@@ -190,10 +217,24 @@
          std::cout << "Processus B :: DataWrite_RB.Body = " << 
Data_Write_RB.Body << std ::endl ;
          #endif
          std::cout << " ************************ " <<  std ::endl ;
+         }
+         catch (certi::BufferFull& e)
+         {
+            std::cout << "Catch Exception BufferFull" << std::endl ;
+            std::cout << "RingBuffer::Send() Exception. " <<  "Name is : " << 
e._name << " Reason is : " << e._reason << std::endl ;
+         }
          i++ ;
          }
      else if (command_RB=="R"){
+         try {
          RingBuffer_AB.Receive(&Data_Read_RB,Size) ;
+         }
+         catch(certi::BufferEmpty& e)
+         {
+             std::cout << "Catch Exception BufferEmpty" << std::endl ;
+             std::cout << "RingBuffer::Receive() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+         }
+
          std::cout << " ****** RECEIVE ******" << std ::endl ;
          #ifdef SIDE_SC
          std::cout << "Processus A :: DataRead_RB.Header = " << 
Data_Read_RB.Header << std ::endl ;
@@ -213,7 +254,17 @@
     // Send to B For the First Time (INITIALIZE)
     // Send to B
         #ifdef _WIN32
-        if (command=="Win32") Socket_Win32_AB.Send(&Data_Write) ;
+        if (command=="Win32")
+        {
+            try {
+                Socket_Win32_AB.Send(&Data_Write) ;
+            }
+            catch (certi::MessageNotSent& e)
+            {
+               std::cout << "Catch Exception MessageNotSent" << std::endl ;
+               std::cout << "SocketSHM::Send() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+            }
+        }
         #else
         if (command=="Posix") Socket_Posix_AB.Send(&Data_Write) ;
         if (command=="SysV") Socket_SysV_AB.Send(&Data_Write) ;
@@ -230,7 +281,17 @@
        /**************************************/
        // Read from B
        #ifdef _WIN32
-       if (command=="Win32") Socket_Win32_AB.Receive(&Data_Read) ;
+       if (command=="Win32")
+       {
+           try {
+              Socket_Win32_AB.Receive(&Data_Read) ;
+           }
+           catch (certi::MessageNotReceived& e)
+           {
+               std::cout << "Catch Exception MessageNotReceived" << std::endl ;
+               std::cout << "SocketSHM::Receive() Exception. " <<  "Name is : 
" << e._name << " Reason is : " << e._reason << std::endl ;
+           }
+       }
        #else
        if (command=="Posix") Socket_Posix_AB.Receive(&Data_Read) ;
        if (command=="SysV") Socket_SysV_AB.Receive(&Data_Read) ;
@@ -270,7 +331,17 @@
        /**************************************/
        // Send to B
        #ifdef _WIN32
-       if (command=="Win32") Socket_Win32_AB.Send(&Data_Write) ;
+       if (command=="Win32")
+       {
+           try {
+               Socket_Win32_AB.Send(&Data_Write) ;
+           }
+           catch (certi::MessageNotSent& e)
+           {
+               std::cout << "Catch Exception MessageNotSent" << std::endl ;
+               std::cout << "SocketSHM::Send() Exception. " <<  "Name is : " 
<< e._name << " Reason is : " << e._reason << std::endl ;
+           }
+       }
        #else
        if (command=="Posix") Socket_Posix_AB.Send(&Data_Write) ;
        if (command=="SysV") Socket_SysV_AB.Send(&Data_Write) ;




reply via email to

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