[754] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Classe DVList : Liste dynamique de variables (valeurs)
|
---|
| 3 | // identifiees par un nom Reza Ansari - Dec 96
|
---|
| 4 |
|
---|
| 5 | #ifndef DVLIST_H_SEEN
|
---|
| 6 | #define DVLIST_H_SEEN
|
---|
| 7 |
|
---|
| 8 | #include "objfio.h"
|
---|
| 9 |
|
---|
| 10 | #include <stdio.h>
|
---|
| 11 | #include <iostream.h>
|
---|
| 12 |
|
---|
[1080] | 13 | #include "mutyv.h"
|
---|
[754] | 14 | #include <list>
|
---|
| 15 | #include <map>
|
---|
| 16 |
|
---|
| 17 | namespace SOPHYA {
|
---|
| 18 |
|
---|
| 19 | // Classe liste de variables Dynamic Variable List
|
---|
| 20 |
|
---|
[895] | 21 | //! Dynamic Variable List class.
|
---|
[754] | 22 | class DVList : public AnyDataObj {
|
---|
| 23 | public:
|
---|
| 24 |
|
---|
| 25 | DVList();
|
---|
| 26 | DVList(const DVList&);
|
---|
| 27 | DVList(char *flnm);
|
---|
| 28 |
|
---|
| 29 | virtual ~DVList();
|
---|
| 30 |
|
---|
| 31 | DVList& operator= (const DVList&);
|
---|
| 32 |
|
---|
| 33 | void Clear();
|
---|
| 34 | DVList& Merge(const DVList&);
|
---|
| 35 |
|
---|
| 36 | int_8 GetI(string const& key, int_8 def=-1);
|
---|
| 37 | r_8 GetD(string const& key, r_8 def=-9.e19);
|
---|
[1080] | 38 | complex<r_8> GetZ(string const& key, complex<r_8> def=-9.e19);
|
---|
[754] | 39 | string GetS(string const& key, char* def="");
|
---|
| 40 | string GetComment(string const& key);
|
---|
| 41 |
|
---|
| 42 | void SetI(string const& key, int_8 val);
|
---|
| 43 | void SetD(string const& key, r_8 val);
|
---|
[1080] | 44 | void SetZ(string const& key, complex<r_8> val);
|
---|
[754] | 45 | void SetS(string const& key, char const* val);
|
---|
[1080] | 46 | void SetS(string const& key, string const& val);
|
---|
[754] | 47 | void SetComment(string const& key, string const& comm);
|
---|
| 48 |
|
---|
| 49 | MuTyV& Get(string const& key);
|
---|
[895] | 50 | /*! Returns the value associated with the name \b key */
|
---|
[754] | 51 | inline MuTyV& operator() (string const& key) { return Get(key); }
|
---|
[895] | 52 | /*! Returns the value associated with the name \b key */
|
---|
[754] | 53 | inline MuTyV& operator[] (string const& key) { return Get(key); }
|
---|
[895] | 54 | /*! Returns the global comment string associated with the object */
|
---|
[754] | 55 | inline string& Comment() { return(comment); }
|
---|
| 56 |
|
---|
[895] | 57 | /*! Prints a brief description of object on \b cout */
|
---|
| 58 | inline void Show() const { Show(cout); }
|
---|
| 59 | virtual void Show(ostream& os) const;
|
---|
| 60 | /*! Prints the list of variables on \b cout */
|
---|
| 61 | inline void Print() const { Print(cout); }
|
---|
[754] | 62 | virtual void Print(ostream& os) const;
|
---|
| 63 |
|
---|
| 64 | // Chaque element dans un DVList est constitue desormais d'un MuTyV
|
---|
| 65 | // et d'une chaine de caracteres (commentaire) regroupe dans la structure
|
---|
| 66 | // dvlElement. Ces elements sont associes aux noms de variables dans un
|
---|
| 67 | // map<...> ValList. Reza 02/2000
|
---|
| 68 |
|
---|
| 69 | struct dvlElement {MuTyV elval; string elcomm; } ;
|
---|
| 70 | typedef map<string, dvlElement, less<string> > ValList;
|
---|
[895] | 71 | /*! Returns an iterator pointing on the first variable in the list */
|
---|
[754] | 72 | inline ValList::const_iterator Begin() { return(mvlist.begin()); }
|
---|
[895] | 73 | /*! Returns the iterator end value */
|
---|
[754] | 74 | inline ValList::const_iterator End() { return(mvlist.end()); }
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 | private:
|
---|
| 78 |
|
---|
| 79 | ValList mvlist;
|
---|
| 80 | string comment;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
[895] | 83 | /*! operator << overloading - Prints the list on the stream \b s */
|
---|
[754] | 84 | inline ostream& operator << (ostream& s, DVList const & dvl)
|
---|
| 85 | { dvl.Print(s); return(s); }
|
---|
| 86 |
|
---|
[895] | 87 | /*! Writes the object in the POutPersist stream \b os */
|
---|
[754] | 88 | inline POutPersist& operator << (POutPersist& os, DVList & obj)
|
---|
| 89 | { ObjFileIO<DVList> fio(&obj); fio.Write(os); return(os); }
|
---|
[895] | 90 | /*! Reads the object from the PInPersist stream \b is */
|
---|
[754] | 91 | inline PInPersist& operator >> (PInPersist& is, DVList & obj)
|
---|
| 92 | { ObjFileIO<DVList> fio(&obj); fio.Read(is); return(is); }
|
---|
| 93 |
|
---|
| 94 | // Classe pour la gestion de persistance
|
---|
| 95 | // ObjFileIO<DVList>
|
---|
| 96 |
|
---|
| 97 | } // namespace SOPHYA
|
---|
| 98 |
|
---|
| 99 | #endif /* DVLIST_H__SEEN */
|
---|
| 100 |
|
---|
| 101 |
|
---|