Changeset 895 in Sophya for trunk/SophyaLib/BaseTools


Ignore:
Timestamp:
Apr 12, 2000, 7:49:54 PM (25 years ago)
Author:
ansari
Message:

Documentation de fichiers - Reza 12/4/2000

Location:
trunk/SophyaLib/BaseTools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/anydataobj.h

    r552 r895  
    1010namespace SOPHYA {
    1111
     12//! Ancestor class for all data objects (for RTTI).
     13
    1214class AnyDataObj {
    1315public:
  • trunk/SophyaLib/BaseTools/dvlist.cc

    r827 r895  
    1212//++
    1313// Class        DVList
    14 // Lib          Outils++
     14// Lib          SysTools
    1515// include      dvlist.h
    1616//
     
    4242static MuTyV ddvdum(-9.e19);
    4343
     44/*!
     45   \class SOPHYA::DVList
     46   This class can be used to construct list of values associated with names.
     47   Variables names should not contain space characters and is limited to 64
     48   characters. The DVList class uses \b SOPHYA::MuTyV objects to hold values
     49   of type string, integer (\b int_8) or float (\b r_8). A comment string
     50   can be associated with each variable name. A global comment string
     51   can be attached to the DVList object. DVList objects can conveniently be
     52   used to represent FITS headers. The class \b SOPHYA::ObjFileIO<DVList>
     53   handles serialisation for DVList. (See SOPHYA::PPersist ).
     54   An
     55   \code
     56   //  ------- Using MuTyV objects -------
     57   MuTyV mvu;         // MuTyV variable declaration
     58   mvu = 60;          // mvu contains the integer value 60
     59   mvu = 66.6;        // and now the double value 66.6
     60   string ds = mvu;   // ds contains the string "66.6"
     61   MuTyV mvi(14);     // New MuTyV variable containing integer value 14
     62   r_4 x = mvi;       // x has the value 14.0
     63   MuTyV mvs("Bonjour !");  // mvs contains the string "Bonjour !"
     64   string s = mvs;          // s vaut "Bonjour, Ca va ?" 
     65   //  ------- Using DVList objects ------
     66   DVList  dvl;
     67   dvl("toto") = 14;      // Integer type value (=14) named toto
     68   dvl("titi") = 25.5;    // float type value (=25.5) named titi
     69   dvl("tata") = "Bonjour !"; // string type value (="Bonjour !") named tata
     70   // Upper and lower case letters are distinguished
     71   dvl("hello") = 88;
     72   dvl("Hello") = 77.77;   
     73   dvl.Comment() = "DVList test object, with values named hello, Hello ";
     74   // Saving the dvl object into a PPF file
     75   POutStream os("dvl.ppf");
     76   os << dvl;
     77   //  later on ...
     78   DVList dvlr;
     79   PInStream is("dvl.ppf");
     80   is << dvlr;
     81   int k = dvlr["toto"] ;     //  k = 14
     82   r_8 b = dvlr["titi"] ;     //  b = 25.5
     83   string s =  dvlr["tata"] ; //  s = "Bonjour !"
     84   int m =  dvlr["hello"] ;   //  m = 88
     85
     86   \endcode
     87*/
    4488
    4589//++
     
    58102
    59103/* --Methode-- */
     104/*! Default constructor */
    60105DVList::DVList()
    61106{
     
    64109
    65110/* --Methode-- */
     111/*! copy constructor */
    66112DVList::DVList(const DVList& dvl)
    67113{
     
    70116
    71117/* --Methode-- */
     118/*! Copy constructor - Object initialized using the PPF file \b flnm */
    72119DVList::DVList(char *flnm)
    73120{
     
    97144
    98145/* --Methode-- */
     146/*! Copy operator - Replaces the variables list with the list from \b dvl */
    99147DVList&     DVList::operator= (const DVList& dvl)
    100148{
     
    105153
    106154/* --Methode-- */
     155/*! Resets the object and clears the variable list and global comment */
    107156void        DVList::Clear()
    108157{
     
    112161
    113162/* --Methode-- */
     163/*! Appends the values from the object \b dvl to the objects list */
    114164DVList&     DVList::Merge(const DVList& dvl)
    115165{
     
    149199
    150200/* --Methode-- */
     201/*! Returns the value corresponding to name \b key, converted to integer
     202    Default value \b def is returned if name \b key not found */
    151203int_8       DVList::GetI(string const& key, int_8 def)
    152204{
     
    158210
    159211/* --Methode-- */
     212/*! Returns the value corresponding to name \b key, converted to double
     213    Default value \b def is returned if name \b key not found */
    160214r_8      DVList::GetD(string const& key, r_8 def)
    161215{
     
    167221
    168222/* --Methode-- */
     223/*! Returns the value corresponding to name \b key, converted to string
     224    Default value \b def is returned if name \b key not found */
    169225string      DVList::GetS(string const& key, char* def)
    170226{
     
    176232
    177233/* --Methode-- */
     234/*! Returns the comment associated with name \b key */
    178235string      DVList::GetComment(string const& key)
    179236{
     
    200257
    201258/* --Methode-- */
     259/*! Appends or sets the integer value \b val in the list with name \b key */
    202260void        DVList::SetI(string const& key, int_8 val)
    203261{
     
    207265/* --Methode-- */
    208266void        DVList::SetD(string const& key, r_8 val)
     267/*! Appends or sets the double value \b val in the list with name \b key */
    209268{
    210269Get(key) = (r_8)val;
     
    212271
    213272/* --Methode-- */
     273/*! Appends or sets the string value \b val in the list with name \b key */
    214274void        DVList::SetS(string const& key, char const* val)
    215275{
     
    219279
    220280/* --Methode-- */
     281/*! Appends or sets the string value \b val in the list with name \b key */
    221282void        DVList::SetS(string const& key, string val)
    222283{
     
    226287
    227288/* --Methode-- */
     289/*! Assigns the comment \b comm with the name \b key .
     290    Does nothing if the entry with name is not present in the list   */
    228291void        DVList::SetComment(string const& key, string const& comm)
    229292{
     
    246309
    247310/* --Methode-- */
     311/*!  Return the MuTyV value associated with name \b key .
     312     Adds an entry of type integer in the list if \b key is not present in the list   */
    248313MuTyV&      DVList::Get(string const& key)
    249314{
     
    272337//--
    273338
    274 
    275 /* --Methode-- */
     339/* --Methode-- */
     340/*! Prints a brief description of object on on the output stream \b os */
     341void        DVList::Show(ostream& os) const
     342{
     343os << "DVList::Show() - NVar= " << (int)mvlist.size() << "\n";
     344os << comment << endl;
     345}
     346
     347/* --Methode-- */
     348/*! Prints the list of variables on the output stream \b os */
    276349void        DVList::Print(ostream& os) const
    277350{
  • trunk/SophyaLib/BaseTools/dvlist.h

    r827 r895  
    7070//  Classe liste de variables  Dynamic Variable List 
    7171
     72//! Dynamic Variable List class.
    7273class DVList : public AnyDataObj {
    7374public:
     
    9798
    9899  MuTyV&            Get(string const& key);
     100/*! Returns the value associated with the name \b key */
    99101  inline MuTyV&     operator()  (string const& key)  { return Get(key); }
     102/*! Returns the value associated with the name \b key */
    100103  inline MuTyV&     operator[]  (string const& key)  { return Get(key); }
     104/*! Returns the global comment string associated with the object */
    101105  inline string&    Comment() { return(comment); }
    102106
    103   inline void       Print() const  { Print(cout); } 
     107/*! Prints a brief description of object on \b cout */
     108  inline  void      Show() const { Show(cout); }
     109  virtual void      Show(ostream& os)  const;
     110/*! Prints the list of variables on \b cout */
     111  inline  void      Print() const  { Print(cout); } 
    104112  virtual void      Print(ostream& os)  const;
    105113
     
    111119  struct dvlElement {MuTyV elval; string elcomm; } ;
    112120  typedef map<string, dvlElement, less<string> >  ValList;
     121/*! Returns an iterator pointing on the first variable in the list */
    113122  inline ValList::const_iterator Begin() { return(mvlist.begin()); }
     123/*! Returns the iterator end value */
    114124  inline ValList::const_iterator End() { return(mvlist.end()); }
    115125 
     
    121131};
    122132
     133/*! operator << overloading - Prints the list on the stream \b s */
    123134inline ostream& operator << (ostream& s, DVList const & dvl)
    124135  {  dvl.Print(s);  return(s);  }
    125136
     137/*! Writes the object in the POutPersist stream \b os */
    126138inline POutPersist& operator << (POutPersist& os, DVList & obj)
    127139{ ObjFileIO<DVList> fio(&obj);  fio.Write(os);  return(os); }
     140/*! Reads the object from the PInPersist stream \b is */
    128141inline PInPersist& operator >> (PInPersist& is, DVList & obj)
    129142{ ObjFileIO<DVList> fio(&obj);  fio.Read(is);  return(is); }
  • trunk/SophyaLib/BaseTools/pexceptions.h

    r773 r895  
    1414namespace SOPHYA {
    1515
    16   // Utiliatire pour accoler un nom de fichier et numero de ligne au message
     16//! Utility function for appending a file name and line number to a message
    1717  string BuildLongExceptionMessage(const char * s, const char *file, int line);
    1818
    19   // Ancestor for PError and PException
    20   // It has a message, and an id to give more
    21   // information on the exception.
     19//! Base exception class in Sophya.
     20/*! Ancestor for PError and PException
     21    It has a message, and an id to give more
     22    information on the exception.
     23*/
    2224  class PThrowable {
    2325  public:
     26    //! Constructor with the message and error-id (optional) specification
    2427    explicit PThrowable(const string& m, int ident=0)
    2528      : msg(m), id(ident) {}
    2629    virtual ~PThrowable() { }
     30    //! Returns the associated message string
    2731    virtual string const& Msg() const  {return msg;}
     32    //! Returns the associated error-id
     33    virtual int Id() const {return id; }
    2834  private:
    2935    string msg;
    3036    int    id;
    3137  };
    32  
    33   // A PError is a serious logic error. Usually not caught...
     38
     39//  PThrowable
     40//      PError
     41//      PException
     42 
     43//! A PError is a serious logic error. Usually not caught...
    3444  class PError : public PThrowable {
    3545  public:
     
    3747  };
    3848 
    39   // A PException is not as serious... Can be caught.
     49//! A PException is not as serious... Can be caught.
    4050  class PException : public PThrowable {
    4151  public:
     
    4353  };
    4454 
    45   // Errors
    46   // Memory allocation failure
     55//  ----   Errors ----
     56//  PError
     57//     AllocationError
     58//     NullPtrError
     59//     ForbiddenError
     60//     AssertionFailedError
     61
     62//! Memory allocation failure
    4763  class AllocationError : public PError {
    4864  public:
     
    5066  };
    5167 
    52   // Null pointer error
     68//! Null pointer error
    5369  class NullPtrError : public PError {
    5470  public:
     
    5672  };
    5773 
    58   // Size mismatch between objects
    59   class SzMismatchError : public PError {
    60   public:
    61     explicit SzMismatchError(const string& m, int id=0) : PError(m,id) {}
    62   };
    63  
    64   // Out of bounds for array, matrix, etc.
    65   class RangeCheckError : public PError {
    66   public:
    67     explicit RangeCheckError(const string& m, int id=0) : PError(m,id) {}
    68   };
    69  
    70   // Invalid parameter to method/constructor...
    71   class ParmError : public PError {
    72   public:
    73     explicit ParmError(const string& m, int id=0) : PError(m,id) {}
    74   };
    75  
    76   // Calling a forbidden method, trying a forbidden operation
     74 
     75//! Calling a forbidden method, trying a forbidden operation
    7776  class ForbiddenError : public PError {
    7877  public:
     
    8079  };
    8180
    82   // Calling a non available / not implemented method
    83   class NotAvailableOperation : public PException {
    84   public:
    85     explicit NotAvailableOperation(const string& m, int id=0) : PException(m,id) {}
    86   };
    87  
    88   // ASSERT macro failure. The message is the assertion...
     81 
     82//! ASSERT macro failure. The message is the assertion...
    8983  class AssertionFailedError : public PError {
    9084  public:
     
    9791  //   IOExc
    9892  //     FileFormatExc
     93  //   SzMismatchError
     94  //   RangeCheckError
     95  //   ParmError
    9996  //   TypeMismatchExc
     97  //   MathExc
     98  //     SingMatxExc
    10099  //   DuplicateIdExc
    101100  //   NotFoundExc
    102   //   MathExc
    103   //     SingMatxExc
    104  
    105   // generic IO Exception
     101  //   CaughtSignalExc
     102 
     103  //! Generic IO Exception.
    106104  class IOExc : public PException {
    107105  public:
     
    109107  };
    110108
    111   // Bad type -> keep ?
     109  //! Bad file format.
     110  class FileFormatExc : public IOExc {
     111  public:
     112    explicit FileFormatExc(const string& m, int id=0) : IOExc(m,id) {}
     113  };
     114
     115  //! Size mismatch between objects.
     116  class SzMismatchError : public PException {
     117  public:
     118    explicit SzMismatchError(const string& m, int id=0) : PException(m,id) {}
     119  };
     120 
     121  //! Out of bounds for array, matrix, etc.
     122  class RangeCheckError : public PException {
     123  public:
     124    explicit RangeCheckError(const string& m, int id=0) : PException(m,id) {}
     125  };
     126 
     127  //! Invalid parameter to method/constructor...
     128  class ParmError : public PException {
     129  public:
     130    explicit ParmError(const string& m, int id=0) : PException(m,id) {}
     131  };
     132
     133  //! Calling a non available / not implemented method
     134  class NotAvailableOperation : public PException {
     135  public:
     136    explicit NotAvailableOperation(const string& m, int id=0) : PException(m,id) {}
     137  };
     138
     139  //! Bad data type -> keep ?
    112140  class TypeMismatchExc : public PException {
    113141  public:
    114142    explicit TypeMismatchExc(const string& m, int id=0) : PException(m,id) {}
    115143  };
    116  
     144
     145  //! Math operation exception
    117146  class MathExc : public PException {
    118147  public:
     
    120149  };
    121150 
     151  //! Singular matrix
     152  class SingMatrixExc : public MathExc {
     153  public:
     154    explicit SingMatrixExc(const string& m, int id=0) : MathExc(m,id) {}
     155  };
     156
     157  //! Duplicate identifier during registration
    122158  class DuplicateIdExc : public PException {
    123159  public:
     
    125161  };
    126162 
     163  //! Not found identifier
    127164  class NotFoundExc : public PException {
    128165  public:
     
    130167  };
    131168 
     169  //! Generated exception when processing a signal
    132170  class CaughtSignalExc : public PException {
    133171  public:
    134172    explicit CaughtSignalExc(const string& m, int id=0) : PException(m,id) {}
    135173  };
    136 
    137   // Bad file format
    138   class FileFormatExc : public IOExc {
    139   public:
    140     explicit FileFormatExc(const string& m, int id=0) : IOExc(m,id) {}
    141   };
    142  
    143   class SingMatrixExc : public MathExc {
    144   public:
    145     explicit SingMatrixExc(const string& m, int id=0) : MathExc(m,id) {}
    146   };
    147  
    148  
    149 }
     174   
     175} // namespace SOPHYA
    150176
    151177
  • trunk/SophyaLib/BaseTools/ppersist.h

    r821 r895  
    3434  class PPersist;
    3535
    36   /* Persistant (delegate or mixin) object */
    37 
     36//! Persistent (delegate or mixin) base class
    3837  class PPersist  {
    3938  public:
     
    6968
    7069
    71   // Ancestor for PInPersist and POutPersist
    72   // Handles (statically) the registration of classes.
     70//! Ancestor for PInPersist and POutPersist PPF streams.
     71// Handles (statically) the registration of classes.
    7372
    7473  class PIOPersist {
     
    137136  // TBD : use hash tables instead of maps. Check hashtbl status in STL.
    138137
     138//! Input stream for PPersit objects.
    139139  class PInPersist : public PIOPersist {
    140140  public:
     
    236236  };
    237237
     238//! Output stream for PPersit objects.
    238239  class POutPersist : public PIOPersist {
    239240  public:
     
    370371  //   - compute the class ID from a MD5 hash of the class name
    371372  //   - register classes with PIOPersist, through PPRegister macro
    372  
     373
     374//! template class for handling the PPersist registration mechanism.
    373375  template <class T>
    374376    class PPersistRegistrar {
Note: See TracChangeset for help on using the changeset viewer.