source: Sophya/trunk/SophyaLib/BaseTools/ppfnametag.h

Last change on this file was 2805, checked in by ansari, 20 years ago

MAJ commentaires pour documentation doxygen - Reza 9 Juin 2005

File size: 2.1 KB
Line 
1// This may look like C code, but it is really -*- C++ -*-
2// Classe PPFNameTag - R. Ansari - Nov 2003
3// To ease manipulation of nametags in PPF streams
4
5#ifndef PPFNAMETAG_H_SEEN
6#define PPFNAMETAG_H_SEEN
7
8#include "ppersist.h"
9/*!
10 \class SOPHYA::PPFNameTag
11 \ingroup BaseTools
12 A simple class which can be used in conjuction with << and >> operators
13 to write nametags in POutPersist streams or position an input PInPersist
14 stream at a given nametag.
15 Nametags are strings which can be used to identify objects for further
16 retrieval in PPF streams.
17 Pushing a PPFNameTag(tname) to an output stream \b os corresponds to
18 so.WriteNameTag(tname). Extracting a PPFNameTag(tname) from an input stream
19 \b is corresponds to is.GotoNameTag(tname).
20
21 \code
22 {
23 // Writing a name tag and an object to a stream
24 NDataBlock<int_4> idb(16);
25 idb = 16;
26 POutPersist so("myfile.ppf");
27 so << PPFNameTag("MyIDB") << idb ;
28 }
29 //...
30 {
31 // Positioning and Reading from a PPF stream
32 PInPersist si("myfile.ppf");
33 NDataBlock<int_4> idb;
34 si >> PPFNameTag("MyIDB") >> idb;
35 }
36 \endcode
37*/
38//----------------------------------------------------------------------
39namespace SOPHYA {
40//! A simple class to ease manipulation of nametags in PPF streams
41
42class PPFNameTag {
43public:
44 PPFNameTag(PPFNameTag const & ptn) { _tname = ptn._tname; }
45 PPFNameTag(string const & tn) { _tname = tn; }
46 PPFNameTag(const char * tn) { _tname = tn; }
47 ~PPFNameTag() { }
48 inline bool GotoNameTag(PInPersist& pi) const
49 { return pi.GotoNameTag(_tname); }
50 inline void WriteTag(POutPersist& po) const
51 { po.WriteNameTag(_tname); return; }
52 inline char* operator= (char* s) { _tname = s; return s; }
53 inline string const & operator= (string const & s) { _tname = s; return s; }
54 inline operator string() const { return _tname; }
55protected:
56 string _tname;
57};
58
59inline PInPersist& operator >> (PInPersist& si, PPFNameTag const & pnt)
60{ pnt.GotoNameTag(si); return(si); }
61
62inline POutPersist& operator << (POutPersist& so, PPFNameTag const & pnt)
63{ pnt.WriteTag(so); return(so); }
64
65} // namespace SOPHYA
66
67#endif /* PPFNAMETAG_H_SEEN */
Note: See TracBrowser for help on using the repository browser.