source: Sophya/trunk/SophyaLib/BaseTools/dvlist.h@ 2763

Last change on this file since 2763 was 2477, checked in by ansari, 22 years ago

Suite et presque fin de l'extension des fonctionalites de la persistence PPF - fonctionalite pour le swap en particulier - Reza 7 Dec 2003

File size: 4.2 KB
RevLine 
[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>
[2322]11#include <iostream>
[754]12
[1080]13#include "mutyv.h"
[754]14#include <list>
15#include <map>
16
17namespace SOPHYA {
18
19// Classe liste de variables Dynamic Variable List
20
[895]21//! Dynamic Variable List class.
[754]22class DVList : public AnyDataObj {
23public:
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
[1310]36 //! Returns the number of elements (variables) in DVList object
37 inline int Size() { return(mvlist.size()); }
38 //! Returns the number of elements (variables) in DVList object
39 inline int NVar() { return(mvlist.size()); }
40
[1157]41 int_8 GetI(string const& key, int_8 def=-1) const;
42 r_8 GetD(string const& key, r_8 def=-9.e19) const;
43 complex<r_8> GetZ(string const& key, complex<r_8> def=-9.e19) const;
44 string GetS(string const& key, char* def="") const;
45 string GetComment(string const& key) const;
[754]46
[1157]47 bool DeleteKey(string const& key);
48 bool HasKey(string const& key) const;
49
[754]50 void SetI(string const& key, int_8 val);
51 void SetD(string const& key, r_8 val);
[1080]52 void SetZ(string const& key, complex<r_8> val);
[754]53 void SetS(string const& key, char const* val);
[1080]54 void SetS(string const& key, string const& val);
[754]55 void SetComment(string const& key, string const& comm);
56
[1157]57 MuTyV Get(string const& key) const ;
[754]58 MuTyV& Get(string const& key);
[895]59/*! Returns the value associated with the name \b key */
[1157]60 inline MuTyV operator() (string const& key) const { return Get(key); }
61/*! Returns the value associated with the name \b key */
62 inline MuTyV operator[] (string const& key) const { return Get(key); }
63/*! Returns the global comment string associated with the object */
64 inline string Comment() const { return(comment); }
65/*! Returns the value associated with the name \b key */
[754]66 inline MuTyV& operator() (string const& key) { return Get(key); }
[895]67/*! Returns the value associated with the name \b key */
[754]68 inline MuTyV& operator[] (string const& key) { return Get(key); }
[895]69/*! Returns the global comment string associated with the object */
[754]70 inline string& Comment() { return(comment); }
71
[895]72/*! Prints a brief description of object on \b cout */
73 inline void Show() const { Show(cout); }
74 virtual void Show(ostream& os) const;
75/*! Prints the list of variables on \b cout */
76 inline void Print() const { Print(cout); }
[754]77 virtual void Print(ostream& os) const;
78
79// Chaque element dans un DVList est constitue desormais d'un MuTyV
80// et d'une chaine de caracteres (commentaire) regroupe dans la structure
81// dvlElement. Ces elements sont associes aux noms de variables dans un
82// map<...> ValList. Reza 02/2000
83
84 struct dvlElement {MuTyV elval; string elcomm; } ;
85 typedef map<string, dvlElement, less<string> > ValList;
[895]86/*! Returns an iterator pointing on the first variable in the list */
[754]87 inline ValList::const_iterator Begin() { return(mvlist.begin()); }
[895]88/*! Returns the iterator end value */
[754]89 inline ValList::const_iterator End() { return(mvlist.end()); }
90
91
92private:
93
94 ValList mvlist;
95 string comment;
96};
97
[895]98/*! operator << overloading - Prints the list on the stream \b s */
[754]99inline ostream& operator << (ostream& s, DVList const & dvl)
100 { dvl.Print(s); return(s); }
101
[895]102/*! Writes the object in the POutPersist stream \b os */
[754]103inline POutPersist& operator << (POutPersist& os, DVList & obj)
104{ ObjFileIO<DVList> fio(&obj); fio.Write(os); return(os); }
[895]105/*! Reads the object from the PInPersist stream \b is */
[754]106inline PInPersist& operator >> (PInPersist& is, DVList & obj)
[2477]107{ ObjFileIO<DVList> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
[754]108
109// Classe pour la gestion de persistance
110// ObjFileIO<DVList>
111
112} // namespace SOPHYA
113
114#endif /* DVLIST_H__SEEN */
115
116
Note: See TracBrowser for help on using the repository browser.