Key.hpp

Go to the documentation of this file.
00001 #ifndef wali_KEY_GUARD
00002 #define wali_KEY_GUARD 1
00003 
00004 /**
00005  * @author Nicholas Kidd
00006  */
00007 
00008 /**
00009  * @file Key.hpp
00010  *
00011  * This file defines the interface to the WALi KeySpace and methods
00012  * for acting on Keys
00013  */
00014 #include <string>
00015 #include <set>
00016 #include "wali/ref_ptr.hpp"
00017 
00018 namespace wali
00019 {
00020   /**
00021    * @typedef Key
00022    *
00023    * For now a Key is just an unsigned int
00024    */
00025   typedef size_t Key;
00026 
00027   /**
00028    * Defined in KeySource.hpp
00029    */
00030   class KeySource;
00031   typedef ref_ptr<KeySource> key_src_t;
00032 
00033   /**
00034    * Defined in KeySpace.hpp
00035    */
00036   class KeySpace;
00037 
00038   /**
00039    * This class defines the wali keyspace
00040    */
00041   KeySpace* getKeySpace();
00042 
00043   void clearKeyspace();
00044 
00045   /**
00046    * Wrapper functions.
00047    * Call same method of class KeySpace using
00048    * the wali::KeySpace object.
00049    */
00050   Key getKey( key_src_t ks );
00051   Key getKey( const std::string& s );
00052   Key getKey( const char* s );
00053   Key getKey( int i );
00054   Key getKey( Key k1, Key k2 );
00055   // @author Amanda Burton
00056   Key getKey( std::set<Key> ks );
00057 
00058   /**
00059    * Return KeySource associated with the key k
00060    */
00061   key_src_t getKeySource( Key k );
00062 
00063   /*!
00064    * Prints key k to std::ostream o
00065    * Essentially performs the lookup from Key to KeySource and calls
00066    * KeySource::print
00067    *
00068    * If abbreviate is true and the string representation of the
00069    * key being printed is greater than 20 characters, then the
00070    * actual numeric key is printed instead.
00071    *
00072    */
00073   std::ostream& printKey( std::ostream& o, Key k, bool abbreviate=false );
00074 
00075   /**
00076    * Returns string representation of the key
00077    * Essentially performs the lookup from Key to KeySource and calls
00078    * KeySource::to_string
00079    */
00080   std::string key2str( Key k );
00081 
00082 } // namespace wali
00083 
00084 #endif  // wali_KEY_GUARD
00085