From 3b87474d33876ad9b6926dcd3952a041f816ec11 Mon Sep 17 00:00:00 2001
From: stasse <olivier.stasse@aist.go.jp>
Date: Mon, 28 Jun 2010 23:03:29 +0900
Subject: [PATCH] Reinforce the dependant->dependent policy. Merge the florent
 branch. Makes the test_depend.cpp test works.

---
 include/dynamic-graph/signal-base.h         |  2 +-
 include/dynamic-graph/time-dependency.h     | 34 +++++-----
 include/dynamic-graph/time-dependency.t.cpp | 70 ++++++++++-----------
 src/dgraph/entity.cpp                       |  2 +-
 unitTesting/test_depend.cpp                 | 15 ++---
 5 files changed, 62 insertions(+), 61 deletions(-)

diff --git a/include/dynamic-graph/signal-base.h b/include/dynamic-graph/signal-base.h
index 09b2c40..a2a99a9 100644
--- a/include/dynamic-graph/signal-base.h
+++ b/include/dynamic-graph/signal-base.h
@@ -76,7 +76,7 @@ class SignalBase : public boost::noncopyable
       }
 
   virtual std::ostream& 
-      displayDependancies( std::ostream& os,const int depth=-1,
+      displayDependencies( std::ostream& os,const int depth=-1,
 			   std::string space="",
 			   std::string next1="",std::string next2="" ) const
       {
diff --git a/include/dynamic-graph/time-dependency.h b/include/dynamic-graph/time-dependency.h
index 21608fe..52b1398 100644
--- a/include/dynamic-graph/time-dependency.h
+++ b/include/dynamic-graph/time-dependency.h
@@ -20,8 +20,8 @@
 
 
 
-#ifndef __TIME_DEPENDANCY_HH
-#define __TIME_DEPENDANCY_HH
+#ifndef __TIME_DEPENDENCY_HH
+#define __TIME_DEPENDENCY_HH
 
 #include <list>
 #include <iostream> 
@@ -36,10 +36,10 @@ template< class Time >
 class TimeDependency
 {
  public:
-  enum DependancyType
+  enum DependencyType
     {
-      TIME_DEPENDANT, 
-      BOOL_DEPENDANT,
+      TIME_DEPENDENT, 
+      BOOL_DEPENDENT,
       ALWAYS_READY
     };
 
@@ -50,14 +50,14 @@ class TimeDependency
 
   SignalBase< Time >& leader;
 
-  typedef std::list< const SignalBase<Time> * > Dependancies;
-  static const DependancyType DEPENDANCY_TYPE_DEFAULT = TIME_DEPENDANT;
+  typedef std::list< const SignalBase<Time> * > Dependencies;
+  static const DependencyType DEPENDENCY_TYPE_DEFAULT = TIME_DEPENDENT;
 
-  Dependancies dependancies;
+  Dependencies dependencies;
   bool updateFromAllChildren;
   static const bool ALL_READY_DEFAULT = false;
 
-  DependancyType dependancyType;
+  DependencyType dependencyType;
 
   Time periodTime;
   static const Time PERIOD_TIME_DEFAULT = 1;
@@ -65,25 +65,25 @@ class TimeDependency
  public:
 
   TimeDependency( SignalBase<Time>* sig,
-		     const DependancyType dep = DEPENDANCY_TYPE_DEFAULT );
+		     const DependencyType dep = DEPENDENCY_TYPE_DEFAULT );
   TimeDependency( SignalBase<Time>* sig,
 		     const SignalArray_const<Time>& arr, 
-		     const DependancyType dep = DEPENDANCY_TYPE_DEFAULT );
+		     const DependencyType dep = DEPENDENCY_TYPE_DEFAULT );
   ~TimeDependency( void ) {}
 
-  void addDependancy( const SignalBase<Time>& sig );
-  void removeDependancy( const SignalBase<Time>& sig );
-  void clearDependancy( void );
+  void addDependency( const SignalBase<Time>& sig );
+  void removeDependency( const SignalBase<Time>& sig );
+  void clearDependency( void );
   
 
   virtual std::ostream & writeGraph(std::ostream &os) const;
-  std::ostream& displayDependancies( std::ostream& os,const int depth=-1,
+  std::ostream& displayDependencies( std::ostream& os,const int depth=-1,
 				     std::string space="",
 				     std::string next1="",std::string next2="" ) const;
   
   bool needUpdate( const Time& t1 ) const;
 
-  void setDependancyType( DependancyType dep ) { dependancyType = dep; }
+  void setDependencyType( DependencyType dep ) { dependencyType = dep; }
   
   void setNeedUpdateFromAllChildren( const bool b = true ){ updateFromAllChildren=b; }
   bool getNeedUpdateFromAllChildren( void ) const { return updateFromAllChildren; } 
@@ -98,4 +98,4 @@ class TimeDependency
 
 #include <dynamic-graph/time-dependency.t.cpp>
 
-#endif /* #ifndef __TIME_DEPENDANCY_HH */
+#endif /* #ifndef __TIME_DEPENDENCY_HH */
diff --git a/include/dynamic-graph/time-dependency.t.cpp b/include/dynamic-graph/time-dependency.t.cpp
index c9f220f..825d68a 100644
--- a/include/dynamic-graph/time-dependency.t.cpp
+++ b/include/dynamic-graph/time-dependency.t.cpp
@@ -20,8 +20,8 @@
 
 
 
-#ifndef __TIME_DEPENDANCY_TCPP
-#define __TIME_DEPENDANCY_TCPP
+#ifndef __TIME_DEPENDENCY_TCPP
+#define __TIME_DEPENDENCY_TCPP
 
 #include <dynamic-graph/time-dependency.h>
 
@@ -31,30 +31,30 @@ namespace dynamicgraph {
 #define VP_TEMPLATE_DEBUG_MODE 0
 #include <dynamic-graph/debug.h>
 
-#define __TIME_DEPENDANCY_INIT(sig,dep)     \
+#define __TIME_DEPENDENCY_INIT(sig,dep)     \
     leader(*sig)                                \
-    ,dependancies()                             \
+    ,dependencies()                             \
     ,updateFromAllChildren(ALL_READY_DEFAULT)   \
-    ,dependancyType(dep)                        \
+    ,dependencyType(dep)                        \
     ,periodTime(PERIOD_TIME_DEFAULT)
                          
 
 template< class Time >
 TimeDependency<Time>::
 TimeDependency( SignalBase<Time> *sig
-		   ,const DependancyType dep )
-  :__TIME_DEPENDANCY_INIT(sig,dep)
+		   ,const DependencyType dep )
+  :__TIME_DEPENDENCY_INIT(sig,dep)
 {}
 
 template< class Time >
 TimeDependency<Time>::
 TimeDependency( SignalBase<Time> * sig
 		   ,const SignalArray_const<Time>& ar
-		   ,const DependancyType dep )
-  :__TIME_DEPENDANCY_INIT(sig,dep)
+		   ,const DependencyType dep )
+  :__TIME_DEPENDENCY_INIT(sig,dep)
 {
   for( unsigned int i=0;i<ar.getSize();++i ) 
-    {addDependancy( ar[i] );  }
+    {addDependency( ar[i] );  }
   
   return ;
 }
@@ -62,22 +62,22 @@ TimeDependency( SignalBase<Time> * sig
 /* -------------------------------------------------------------------------- */
 template< class Time >
 void TimeDependency<Time>::
-addDependancy( const SignalBase<Time>& sig )
+addDependency( const SignalBase<Time>& sig )
 {
-  dependancies.push_front(&sig); 
+  dependencies.push_front(&sig); 
 }
 
 template< class Time >
 void TimeDependency<Time>::
-removeDependancy( const SignalBase<Time>& sig )
+removeDependency( const SignalBase<Time>& sig )
 {
-  dependancies.remove(&sig); 
+  dependencies.remove(&sig); 
 }
 template< class Time >
 void TimeDependency<Time>::
-clearDependancy( void )
+clearDependency( void )
 {
-  dependancies.clear(); 
+  dependencies.clear(); 
 }
 
 template< class Time >
@@ -90,12 +90,12 @@ needUpdate( const Time& t1 ) const
   if( leader.getReady() ) { dgTDEBUGOUT(15);return true; }
   if( lastAskForUpdate ) { dgTDEBUGOUT(15);return true; }
 
-  switch( dependancyType )
+  switch( dependencyType )
     {
     case ALWAYS_READY: 
       { dgTDEBUGOUT(15);return true; }
-    case BOOL_DEPENDANT:  break;
-    case TIME_DEPENDANT: 
+    case BOOL_DEPENDENT:  break;
+    case TIME_DEPENDENT: 
       {
 	if( t1<leader.getTime()+periodTime ) 
 	  { dgTDEBUGOUT(15);return false; }
@@ -104,8 +104,8 @@ needUpdate( const Time& t1 ) const
     };
 
   bool res = updateFromAllChildren;
-  const typename Dependancies::const_iterator itend=dependancies.end();
-  for( typename Dependancies::const_iterator it=dependancies.begin();it!=itend;++it )
+  const typename Dependencies::const_iterator itend=dependencies.end();
+  for( typename Dependencies::const_iterator it=dependencies.begin();it!=itend;++it )
     {
       const SignalBase<Time> &sig = **it;
       dgTDEBUG(15)<< "Ask update for "<< sig <<std::endl;
@@ -128,10 +128,10 @@ writeGraph(  std::ostream & os) const
   std::string LeaderLocalName;
   std::string LeaderNodeName;
   leader.ExtractNodeAndLocalNames(LeaderLocalName,LeaderNodeName);
-  if (dependancies.size()!=0)
+  if (dependencies.size()!=0)
     {
-      const typename Dependancies::const_iterator itend=dependancies.end();
-      for( typename Dependancies::const_iterator it=dependancies.begin();it!=itend;++it )
+      const typename Dependencies::const_iterator itend=dependencies.end();
+      for( typename Dependencies::const_iterator it=dependencies.begin();it!=itend;++it )
 	{
 	  std::string itLocalName,itNodeName;
 	  (*it)->ExtractNodeAndLocalNames(itLocalName,itNodeName);
@@ -144,31 +144,31 @@ writeGraph(  std::ostream & os) const
 
 template< class Time >
 std::ostream& TimeDependency<Time>::
-displayDependancies( std::ostream& os,const int depth,
+displayDependencies( std::ostream& os,const int depth,
 		     std::string space,
 		     std::string next1,std::string next2 ) const
 {
-  leader.SignalBase<Time>::displayDependancies(os,depth,space,next1,next2)<<" (";
-  switch( dependancyType )
+  leader.SignalBase<Time>::displayDependencies(os,depth,space,next1,next2)<<" (";
+  switch( dependencyType )
     {
     case ALWAYS_READY: os<<"A"; break;
-    case BOOL_DEPENDANT: os << "ready=" << ((leader.getReady())?"TRUE":"FALSE"); break;
-    case TIME_DEPENDANT:  
+    case BOOL_DEPENDENT: os << "ready=" << ((leader.getReady())?"TRUE":"FALSE"); break;
+    case TIME_DEPENDENT:  
       os  <<"t="<<leader.getTime() <<" (/"<<periodTime<<") " ; 
       break;
     };
   os<<")"; //<<std::endl;
     {
-      const typename Dependancies::const_iterator itend=dependancies.end();
-      for( typename Dependancies::const_iterator it=dependancies.begin();it!=itend;++it )
+      const typename Dependencies::const_iterator itend=dependencies.end();
+      for( typename Dependencies::const_iterator it=dependencies.begin();it!=itend;++it )
 	if( depth!=0 )
 	  {
 	    os<<std::endl;
 	    std::string ajout = "|";
 	    std::string ajout2 = "|";
-	    typename Dependancies::const_iterator it2=it; it2++;
-	    if( it2==dependancies.end() ) { ajout = "`"; ajout2= " "; }
-	    (*it)->displayDependancies( os,depth-1,space+next2+"   ",ajout,ajout2 );
+	    typename Dependencies::const_iterator it2=it; it2++;
+	    if( it2==dependencies.end() ) { ajout = "`"; ajout2= " "; }
+	    (*it)->displayDependencies( os,depth-1,space+next2+"   ",ajout,ajout2 );
 	  }
 	else 
 	  { os<<std::endl<<space<<"   `-- ..."; break; }
@@ -178,6 +178,6 @@ displayDependancies( std::ostream& os,const int depth,
 
 } // namespace dynamicgraph
 
-#endif /* #ifndef __TIME_DEPENDANCY_TCPP */
+#endif /* #ifndef __TIME_DEPENDENCY_TCPP */
 
 
diff --git a/src/dgraph/entity.cpp b/src/dgraph/entity.cpp
index a2c27f4..ea63104 100644
--- a/src/dgraph/entity.cpp
+++ b/src/dgraph/entity.cpp
@@ -238,7 +238,7 @@ commandLine( const std::string& cmdLine,std::istringstream& cmdArgs,std::ostream
       string sig; cmdArgs>>sig; 
       cmdArgs >>  ws; int depth=-1; 
       if( cmdArgs.good() ) { cmdArgs >> depth; }
-      getSignal(sig) .displayDependancies( os,depth ); os<<endl;
+      getSignal(sig) .displayDependencies( os,depth ); os<<endl;
     }
   else 
     {
diff --git a/unitTesting/test_depend.cpp b/unitTesting/test_depend.cpp
index 61ee7be..ef1e1e3 100644
--- a/unitTesting/test_depend.cpp
+++ b/unitTesting/test_depend.cpp
@@ -133,23 +133,24 @@ int main( void )
    pro3.add(sig5);
    pro3.add(sig6);
    
-   sig5.setDependancyType(TimeDependency<int>::ALWAYS_READY);
-   sig6.setDependancyType(TimeDependency<int>::BOOL_DEPENDANT);
+   sig5.setDependencyType(TimeDependency<int>::ALWAYS_READY);
+   sig6.setDependencyType(TimeDependency<int>::BOOL_DEPENDENT);
 
    sig6.setReady();
 
-   sig1.displayDependancies(cout)<<endl;
+   sig1.displayDependencies(cout)<<endl;
  
-   cout << "Needs update?"<< endl <<  sig1.needUpdate(2) << endl;
+   cout << "Needs update?"    << endl 
+	<< sig1.needUpdate(2) << endl;
    dgDEBUG(1) << "Access sig1(2) "<<endl;
    sig1.access(2);
-   sig1.displayDependancies(cout)<<endl;
+   sig1.displayDependencies(cout) << endl;
    dgDEBUG(1) << "Access sig2(4) "<<endl;
    sig2.access(4);
-   sig1.displayDependancies(cout)<<endl;
+   sig1.displayDependencies(cout)<<endl;
    dgDEBUG(1) << "Access sig1(4) "<<endl;
    sig1.access(4);
-   sig1.displayDependancies(cout)<<endl;
+   sig1.displayDependencies(cout)<<endl;
 
    sig1.needUpdate(6);
    sig1.needUpdate(6);
-- 
GitLab