ometah-devel
[Top][All Lists]
Advanced

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

[oMetah-devel] ometah/common itsSet.hpp itsSet.cpp


From: Johann
Subject: [oMetah-devel] ometah/common itsSet.hpp itsSet.cpp
Date: Thu, 10 Mar 2005 12:58:17 -0500

CVSROOT:        /cvsroot/ometah
Module name:    ometah
Branch:         
Changes by:     Johann <address@hidden> 05/03/10 17:58:17

Modified files:
        common         : itsSet.hpp 
Added files:
        common         : itsSet.cpp 

Log message:
        * add the source file for itsSet
        * some tries about the template
        * including the hash_map type, with retrocompatibility header
        -> one should try with gcc-2.4 if the std header is present

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/itsSet.cpp?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/itsSet.hpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: ometah/common/itsSet.hpp
diff -u ometah/common/itsSet.hpp:1.3 ometah/common/itsSet.hpp:1.4
--- ometah/common/itsSet.hpp:1.3        Mon Feb 28 14:30:04 2005
+++ ometah/common/itsSet.hpp    Thu Mar 10 17:58:16 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- * $Id: itsSet.hpp,v 1.3 2005/02/28 14:30:04 nojhan Exp $
+ * $Id: itsSet.hpp,v 1.4 2005/03/10 17:58:16 nojhan Exp $
  * Author: Walid TFAILI <address@hidden>
  ****************************************************************************/
 
@@ -21,35 +21,73 @@
  
 #ifndef ITSSET
 #define ITSSET
+
+#include <string>
+#include <hash_map.h>
+
  
 //! A common class for all sets of objects
 /*!
   It uses templates to permit any kind of instanciation
 */ 
-template <class T>
+template <class T, class string>
 class itsSet
 {
 protected:
 
+    //! The hash_map key equality function
+    /*! 
+      A binary predicate that determines whether two keys are equal.
+    */
+    /*
+    struct eqstr
+    {
+      bool operator()(string s1, string s2) const
+      {
+        return strcmp(s1, s2) == 0;
+      }
+    };
+*/
+    struct eqstr
+    {
+      bool operator()(const char* s1, const char* s2) const
+      {
+        return strcmp(s1, s2) == 0;
+      }
+    };
+
   //! The collection of instance
   /*! 
-    The collection hash map contains T classes 
+    The collection hash map contains T classes.
+    It associate a string to an object.
+    The string is the name of the object (from instance.getName())
   */
-  vector<T> collection;
+  hash_map< const char*, T, hash<const char*>, eqstr > collection;
+
+  //! The current choice 
+  string currentItem;
   
 public:
   //! Add an object
   /*!  
     Add a T in the collection hash map, which is of the form
     [<string> => <object>]
+    It use the "name" method to get the key associated to the object.
   */
-  void add(T);
+  void add(T item);
   
   //! Remove an object
   /*! 
     Remove a T member from the collection hash map, specifying its key
   */
-  void remove(string);
+  void remove(string name);
+
+  //! Change the current choice
+  void choose(string name);
+
+  //! Return a pointer on the current object
+  T * item();
+  
 }
 
-#endif ITSSET
+#endif




reply via email to

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