Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

d_Dictionary.h

Go to the documentation of this file.
00001 
00002 #ifndef d_Dictionary_h
00003 #define d_Dictionary_h 1
00004 
00005 //------------------------------------------------------------------------------
00006 #include "d_Collection.h"
00007 
00008 //------------------------------------------------------------------------------
00009 template <class K, class V> class _ODLL d_Association;
00010 template <class T> class _ODLL d_Iterator;
00011 //------------------------------------------------------------------------------
00012 
00013 /**
00014  * It's an unordered collection of associations.
00015  * 
00016  * An association is compound of the couple key and value. Key and value can be
00017  * of any types. It's like to the C++ STL map<> container, but the collection is
00018  * transparently persistent.
00019  * 
00020  * This collection type is useful when items in the collection can be associated
00021  * with keys. This collection offers methods to retrieve an item by a key.
00022  *
00023  * LOCATION:
00024  * d_Dictionary.h
00025  *
00026  * USAGE:
00027  * d_Dictionary< <key_type>, <value-type> >     <property-name>;
00028  * 
00029  * Where:
00030  * 
00031  * <key-type >:           Key type. Can be a literal or a user type
00032  * <value-type >:               Value type. Can be a literal or a user type
00033  * <PROPERTY-NAME>:     NAME OF PROPERTY
00034  * 
00035  * <key-type> must be an ODMG literal or a user type but with the definition of
00036  *            operator<.
00037  *
00038  * EXAMPLES:
00039  *  * DEFINITION OF A DICTIONARY OF CODE/PRODUCT
00040  * d_Dictionary< d_String, d_Ref<Product> >     Code_Products;
00041  * 
00042  * ...
00043  * 
00044  *  * INSERT A PRODUCT WITH ASSOCIATED ITS CODE
00045  *
00046  * Code_Products.bind( "10345", product );
00047  * 
00048  * ...
00049  * 
00050  *  * LOOKUP OF A PRODUUCT BY CODE
00051  * d_Ref<Product>       product = Code_Products.lookup( "10345" );
00052  *
00053  * SEE ALSO:
00054  * d_Association, d_Collection, d_Iterator
00055  *
00056  * ODMG:
00057  * Compliant 
00058  */
00059 
00060 template <class K, class V>
00061 class _ODLL d_Dictionary : public d_Collection< d_Association<K,V> >
00062 {
00063   public:
00064 
00065     /**
00066      * Default Constructor.
00067      *
00068      * ODMG    :        Compliant 
00069      */
00070     d_Dictionary ();
00071 
00072     /**
00073      * Destructor.
00074      *
00075      * ODMG    :        Compliant 
00076      */
00077     ~d_Dictionary();
00078 
00079     /**
00080      * Insert a new association in the dictionary.
00081      *
00082      * Creates a new association between <iKey> and <iValue> and insert it in
00083      * the dictionary. If an association with key <iKey> is already present in
00084      * the dictionary, the old value is replaced with the new value <iValue>.
00085      *
00086      * SEE ALSO:        unbind(), lookup()
00087      * ODMG    :        Compliant 
00088      */
00089     void bind (const K& iKey, const V& iValue);
00090 
00091     /**
00092      * Remove an association by the dictionary.
00093      *
00094      * If the dictionary contains an association with the key <iKey>, it is
00095      * removed from the dictionary.
00096      *
00097      * SEE ALSO:        bind()
00098      * ODMG    :        Compliant 
00099      */
00100     void unbind (const K& iKey);
00101 
00102     /**
00103      * Retrieve an association by key.
00104      *
00105      * Searches, in the dictionary, the association with key <iKey>. If found
00106      * returns the value of the association, otherwise a
00107      * d_Error_ElementNotFound exception is thrown.
00108      *
00109      * SEE ALSO:        contains_key()
00110      * ODMG    :        Compliant 
00111      */
00112     V lookup (const K& iKey);
00113 
00114     /**
00115      * Check if an association is present in the dictionary.
00116      *
00117      * Searches, in the dictionary, the association with key <iKey>. If found
00118      * returns true, otherwise false.
00119      *
00120      * SEE ALSO:        lookup()
00121      * ODMG    :        Compliant 
00122      */
00123     d_Boolean contains_key (const K& iKey);
00124 
00125     /**
00126      * Returns always false.
00127      *
00128      * ODMG    :  Compliant 
00129      */
00130     virtual d_Boolean allows_duplicates () const;
00131 
00132     /**
00133      * Returns always false.
00134      *
00135      * ODMG    :  Compliant 
00136      */
00137     virtual d_Boolean is_ordered () const;
00138 
00139     /**
00140      * Returns an iterator that points to the first element.
00141      *
00142      * SEE ALSO:  begin()
00143      * ODMG    :  Compliant
00144      */
00145     d_Iterator< d_Association<K,V> > create_iterator();
00146 
00147     /**
00148      * Returns an iterator that points to the first element.
00149      *
00150      * Permits to handle the container by STL classes.
00151      *
00152      * SEE ALSO:  create_iterator()
00153      * ODMG    :  Compliant
00154      */
00155     d_Iterator< d_Association<K,V> > begin();
00156 
00157     /**
00158      * Returns an iterator that points to the last element.
00159      *
00160      * Permits to handle the container by STL classes.
00161      *
00162      * SEE ALSO:  begin()
00163      * ODMG    :  Compliant
00164      */
00165     d_Iterator< d_Association<K,V> > end();
00166     
00167     // INTERNAL CONSTRUCTOR
00168     d_Dictionary( d_Object::DynaFactoryConstructor* iObj ){;}
00169 
00170     d_Iterator< d_Association<K,V> > iter;
00171 };
00172 
00173 //------------------------------------------------------------------------------
00174 #include "d_Dictionary.cti"
00175 
00176 //------------------------------------------------------------------------------
00177 //------------------------------------------------------------------------------
00178 
00179 #endif

Generated on Fri Nov 29 17:12:13 2002 for Orient ODBMS Just Edition v. 2.0e by doxygen1.3-rc1