Index: /trunk/ArchTOIPipe/Kernel/piotoirdr.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/piotoirdr.cc	(revision 2385)
+++ /trunk/ArchTOIPipe/Kernel/piotoirdr.cc	(revision 2386)
@@ -3,5 +3,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: piotoirdr.cc,v 1.5 2003-05-16 13:40:09 aubourg Exp $
+// $Id: piotoirdr.cc,v 1.6 2003-05-20 10:10:08 aubourg Exp $
 
 #include "piotoirdr.h"
@@ -110,5 +110,5 @@
       }
       flags = new uint_8[nf];
-      for (int i=0; i<nf; i++) flags[i] = pioflags[i];
+      for (int i=0; i<nf; i++) flags[i] = (uint_8)pioflags[i];
       PIODeleteFLG(pioflags, pioGroup);
     }
Index: /trunk/ArchTOIPipe/Kernel/ringpipe.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/ringpipe.cc	(revision 2385)
+++ /trunk/ArchTOIPipe/Kernel/ringpipe.cc	(revision 2386)
@@ -3,5 +3,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: ringpipe.cc,v 1.1 2003-05-19 23:31:29 aubourg Exp $
+// $Id: ringpipe.cc,v 1.2 2003-05-20 10:10:08 aubourg Exp $
 
 #include "ringpipe.h"
@@ -15,6 +15,7 @@
 #endif
 
-RingPipe::RingPipe() {
+RingPipe::RingPipe(int ws) {
   i0 = -1;
+  winSize = ws;
   producer = NULL;
   pthread_cond_init(&ringReady, NULL);
@@ -38,4 +39,5 @@
 void RingPipe::putRing(int i, Ring const* ring) {
   lock();
+  waitForRoom(i);
   if (i0 == -1) {
     data.insert(data.begin(), 1, (Ring const*) NULL);
@@ -50,4 +52,10 @@
   notify();
   unlock();
+}
+
+void RingPipe::waitForRoom(int j) {
+  while (j-i0 >= winSize) {
+    wait();
+  }
 }
 
@@ -91,4 +99,5 @@
     data.erase(data.begin(), data.begin()+(i-i0));
     i0=i;
+    notify();
   }
   unlock();
Index: /trunk/ArchTOIPipe/Kernel/ringpipe.h
===================================================================
--- /trunk/ArchTOIPipe/Kernel/ringpipe.h	(revision 2385)
+++ /trunk/ArchTOIPipe/Kernel/ringpipe.h	(revision 2386)
@@ -5,5 +5,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: ringpipe.h,v 1.1 2003-05-19 23:31:29 aubourg Exp $
+// $Id: ringpipe.h,v 1.2 2003-05-20 10:10:09 aubourg Exp $
 
 #ifndef RINGPIPE_H
@@ -21,5 +21,5 @@
 class RingPipe {
 public:
-  RingPipe();
+  RingPipe(int winSize=100);
   virtual ~RingPipe();
 
@@ -28,4 +28,5 @@
 
   virtual void wontNeedRingBefore(int i);
+  virtual void setWinSize(int n) {winSize = n;}
 
 protected:
@@ -47,4 +48,5 @@
   void notify() {pthread_cond_broadcast(&ringReady);}
 
+  int winSize;
   vector<Ring const*> data;
   int i0;
@@ -53,4 +55,5 @@
 
   virtual void waitForRing(int i); // should be locked before
+  virtual void waitForRoom(int i); // should be locked before
   virtual DataStatus isRingAvail(int i);  // should be locked before
 
Index: /trunk/ArchTOIPipe/Kernel/ringprocessor.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/ringprocessor.cc	(revision 2385)
+++ /trunk/ArchTOIPipe/Kernel/ringprocessor.cc	(revision 2386)
@@ -3,8 +3,9 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: ringprocessor.cc,v 1.1 2003-05-19 23:31:29 aubourg Exp $
+// $Id: ringprocessor.cc,v 1.2 2003-05-20 10:10:09 aubourg Exp $
 
 #include "ringprocessor.h"
 #include "ringpipe.h"
+#include "toimanager.h"
 
 #include <iostream>
@@ -37,4 +38,8 @@
 
   wontNeedRing = -1;
+  neededRingHistory = 3;
+  lastAWNR = -1;
+
+  TOIManager::getManager()->registerProcessor(this);
 }
 
@@ -57,5 +62,7 @@
 }
 
-
+void RingProcessor::setNeededRingHistory(int nr) {
+  neededRingHistory = nr;
+}
 
 int RingProcessor::declareRingInput(string ring) {
@@ -147,4 +154,16 @@
 }
 
+RingPipe* RingProcessor::getOutRing(string out)
+{
+  // recherche du nom de la sortie et verification si le toi existe deja
+  map<string, int>::iterator i = outRingIx.find(out);
+  if (i == outRingIx.end()) {
+    return NULL;
+  } else {
+    return outRings[(*i).second];
+  }
+}
+
+
 
 Ring const* RingProcessor::getRing(int index, int i) {
@@ -169,4 +188,11 @@
 }
 
+void RingProcessor::autoWontNeedRing(int iCur) {
+  if (neededRingHistory <=0) return;
+  if (iCur <= lastAWNR + neededRingHistory/10) return;
+  lastAWNR = iCur;
+  wontNeedRingBefore(iCur-neededRingHistory);
+}
+
 
 void RingProcessor::getRingRange(int& min, int&max) {
Index: /trunk/ArchTOIPipe/Kernel/ringprocessor.h
===================================================================
--- /trunk/ArchTOIPipe/Kernel/ringprocessor.h	(revision 2385)
+++ /trunk/ArchTOIPipe/Kernel/ringprocessor.h	(revision 2386)
@@ -5,5 +5,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: ringprocessor.h,v 1.1 2003-05-19 23:31:29 aubourg Exp $
+// $Id: ringprocessor.h,v 1.2 2003-05-20 10:10:09 aubourg Exp $
 
 
@@ -52,4 +52,5 @@
   virtual int getWontNeedBefore() {return wontNeedRing;}
 
+  virtual void setNeededRingHistory(int nrings); // -1 : disable
   
 protected:
@@ -60,6 +61,8 @@
   RingPipe*        getInputRing(int index);
   RingPipe*        getOutputRing(int index);
+  RingPipe*        getOutRing(string out);
   virtual void wontNeedRingBefore(int i);  
   friend class RingPipe;
+  friend class TOIManager;
   virtual void getRingRange(int& min, int& max);
 
@@ -68,4 +71,8 @@
   int ringEnd;
   int wontNeedRing;
+  int neededRingHistory;
+
+  void autoWontNeedRing(int iCur);
+  int lastAWNR;
 
   map<string, int> inRingIx;
Index: /trunk/ArchTOIPipe/Kernel/toimanager.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/toimanager.cc	(revision 2385)
+++ /trunk/ArchTOIPipe/Kernel/toimanager.cc	(revision 2386)
@@ -3,5 +3,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: toimanager.cc,v 1.21 2003-05-19 23:31:29 aubourg Exp $
+// $Id: toimanager.cc,v 1.22 2003-05-20 10:10:09 aubourg Exp $
 
 #include "toimanager.h"
@@ -42,4 +42,11 @@
   cout << "Adding processor to TOIManager for group execution" << endl;
   processors.push_back(proc);
+  
+}
+
+void TOIManager::registerProcessor(RingProcessor* proc) {
+  
+  cout << "Adding processor to TOIManager for group execution" << endl;
+  ringProcessors.push_back(proc);
   
 }
@@ -80,5 +87,27 @@
     cout << "processor started " << endl;
   }
+
+  for (vector<RingProcessor*>::iterator i = ringProcessors.begin();
+       i != ringProcessors.end(); i++) {
+    RingProcessor* proc = *i;
+    cout << "**********************" <<  endl;
+    cout << "starting processor " <<  endl;
+    proc->start();
+    cout << "processor started " << endl;
+  }
   cout << "**********************" << endl;
+}
+
+void TOIManager::checkRingLimits() 
+{
+  int min=0;
+  int max = MAXINT;
+  for (int pass=0; pass<2; pass++) {
+    for (vector<RingProcessor*>::iterator i = ringProcessors.begin();
+	 i != ringProcessors.end(); i++) {
+      RingProcessor* proc = *i;
+      proc->getRingRange(min, max);
+    }
+  }
 }
 
@@ -162,4 +191,18 @@
 } 
 
+RingPipe& TOIManager::connect(RingProcessor& pout, string out,
+			      RingProcessor& pin, string in) {
+  RingPipe* pipe;
+  char buff[128];
+  sprintf(buff, "Ring_[%s-%s]",  in.c_str(), out.c_str());
+  if ((pipe = pout.getOutRing(out)) == NULL) {
+    pipe = new RingPipe();
+    pout.addRingOutput(out, pipe);
+  }
+
+  pin.addRingInput(in, pipe);
+  return(*pipe);
+}
+
 // methode connect de cgt simplifiee et corrigee
 TOI& TOIManager::connect(TOIProcessor& prout, string out, 
@@ -169,5 +212,5 @@
   if (nom.length() < 1) {
     char buff[128];
-    sprintf(buff, "TOI%s_[%s-%s]", nom, in, out);
+    sprintf(buff, "TOI%s_[%s-%s]", nom.c_str(), in.c_str(), out.c_str());
     nom = buff;
   }
@@ -230,5 +273,5 @@
   int nbmax_dns_print = 2;
 
-  TOIManager* mgr = TOIManager::getManager();
+  //  TOIManager* mgr = TOIManager::getManager();
   
   //  istart = mgr->getRequestedBegin();
@@ -263,5 +306,5 @@
       nb_dns_print++;
       fracperc = (double)processed_samples*100./(double)total_sample_count;
-      fperc = fracperc*100;
+      fperc = (int)(fracperc*100);
       cout << ">>> " << _msg << ": ProcessedSampleCount()= " << last_sample_count 
            << " Frac done = " << (double)fperc/100. << " %" << endl;
@@ -271,5 +314,5 @@
     else if ((nb_sleep+1)%5 == 0) {
       fracperc = (double)processed_samples*100./(double)total_sample_count;
-      fperc = fracperc*100;
+      fperc = (int)(fracperc*100);
       cout << "> " << _msg << ": ProcSamples()= " <<  processed_samples 
            << " Done = " << " %" << (double)fperc/100.
Index: /trunk/ArchTOIPipe/Kernel/toimanager.h
===================================================================
--- /trunk/ArchTOIPipe/Kernel/toimanager.h	(revision 2385)
+++ /trunk/ArchTOIPipe/Kernel/toimanager.h	(revision 2386)
@@ -5,5 +5,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: toimanager.h,v 1.17 2002-10-23 21:57:40 aubourg Exp $
+// $Id: toimanager.h,v 1.18 2003-05-20 10:10:09 aubourg Exp $
 
 
@@ -16,9 +16,9 @@
 
 #include "toiprocessor.h"
+#include "ringprocessor.h"
 
 
-// -----------ajout cgt vf 19/08/2002
-
 #include "toi.h"
+#include "ringpipe.h"
 
 #include <typeinfo>
@@ -34,5 +34,5 @@
 
 #include <pthread.h>
-// ----------fin ajout cgt
+
 
 
@@ -51,4 +51,5 @@
   void startAll();
   bool checkSamplesLimits(int pass);
+  void checkRingLimits();
 
   void waitForAll();
@@ -71,5 +72,6 @@
   // fin ajout cgt
 
-
+  virtual RingPipe& connect(RingProcessor& pout, string out,
+			    RingProcessor& pint, string in);
 
 
@@ -87,6 +89,9 @@
   vector<TOIProcessor*> processors;
   void registerProcessor(TOIProcessor* proc);
+  vector<RingProcessor*> ringProcessors;
+  void registerProcessor(RingProcessor* proc);
 
   friend class TOIProcessor;
+  friend class RingProcessor;
 
   // ajout cgt vf 19/08/2002
Index: /trunk/ArchTOIPipe/TestPipes/tstringpipe.cc
===================================================================
--- /trunk/ArchTOIPipe/TestPipes/tstringpipe.cc	(revision 2386)
+++ /trunk/ArchTOIPipe/TestPipes/tstringpipe.cc	(revision 2386)
@@ -0,0 +1,10 @@
+#include "ring.h"
+#include "ringpipe.h"
+#include "ringprocessor.h"
+
+class RingMaker : public RingProcessor {
+  
+
+
+};
+
