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

Last change on this file since 1080 was 1080, checked in by ansari, 25 years ago

Classe MuTyV separe et etendu pour support complexe - Reza 24/7/2000

File size: 3.4 KB
Line 
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
13#include "mutyv.h"
14#include <list>
15#include <map>
16
17namespace SOPHYA {
18
19// Classe liste de variables Dynamic Variable List
20
21//! Dynamic Variable List class.
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
36 int_8 GetI(string const& key, int_8 def=-1);
37 r_8 GetD(string const& key, r_8 def=-9.e19);
38 complex<r_8> GetZ(string const& key, complex<r_8> def=-9.e19);
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);
44 void SetZ(string const& key, complex<r_8> val);
45 void SetS(string const& key, char const* val);
46 void SetS(string const& key, string const& val);
47 void SetComment(string const& key, string const& comm);
48
49 MuTyV& Get(string const& key);
50/*! Returns the value associated with the name \b key */
51 inline MuTyV& operator() (string const& key) { return Get(key); }
52/*! Returns the value associated with the name \b key */
53 inline MuTyV& operator[] (string const& key) { return Get(key); }
54/*! Returns the global comment string associated with the object */
55 inline string& Comment() { return(comment); }
56
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); }
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;
71/*! Returns an iterator pointing on the first variable in the list */
72 inline ValList::const_iterator Begin() { return(mvlist.begin()); }
73/*! Returns the iterator end value */
74 inline ValList::const_iterator End() { return(mvlist.end()); }
75
76
77private:
78
79 ValList mvlist;
80 string comment;
81};
82
83/*! operator << overloading - Prints the list on the stream \b s */
84inline ostream& operator << (ostream& s, DVList const & dvl)
85 { dvl.Print(s); return(s); }
86
87/*! Writes the object in the POutPersist stream \b os */
88inline POutPersist& operator << (POutPersist& os, DVList & obj)
89{ ObjFileIO<DVList> fio(&obj); fio.Write(os); return(os); }
90/*! Reads the object from the PInPersist stream \b is */
91inline 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
Note: See TracBrowser for help on using the repository browser.