Changeset 895 in Sophya


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
Files:
2 added
12 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 {
  • trunk/SophyaLib/SUtils/datacards.cc

    r754 r895  
    1 // $Id: datacards.cc,v 1.1 2000-03-02 16:10:58 ansari Exp $
     1// $Id: datacards.cc,v 1.2 2000-04-12 17:49:42 ansari Exp $
    22//
    33// Datacards, acquisition EROS II
     
    1818//++
    1919// Class        DataCards
    20 // Lib          Outils++
     20// Lib          SysTools
    2121// include      datacards.h
    2222//
     
    2424//      de mot-cle (lecture d'un fichier par exemple)
    2525//--
     26
    2627
    2728//++
     
    3536//--
    3637
     38/*!
     39    \class SOPHYA::DataCards
     40    This class can be used for decoding program parameters from an ascii
     41    file. Each line of the ascii contains a keyword starting with \b @ .
     42    Lines with any other character in the first column are treated as comments.
     43    Keywords can be followed by 0 or more parameters.
     44    Processing functions (\b ProcCard) can automatically be called for
     45    keywords matching a given pattern. (see \b AddProcF )
     46*/
     47
     48/* Default constructor */
    3749DataCards::DataCards()
    3850{
    3951}
    4052
     53/*! constructor with the specification of a parameter file */
    4154DataCards::DataCards(string const& fn)
    4255{
     
    6376//--
    6477
     78/*!
     79    Adds a new processing function for all keywords matching the
     80    specified pattern.
     81    \param mtch : The pattern - can contain *
     82*/
    6583void
    6684DataCards::AddProcF(ProcCard f, string const& mtch)
     
    85103}
    86104
    87 void
    88 DataCards::Clear()
     105/*! Resets the objects - Suppresses all cards  */
     106void DataCards::Clear()
    89107{
    90108cards.erase(cards.begin(), cards.end());
    91109}
    92110
     111/*! Reads the file named \b fn. if fn=="" the value of \b SOPHYA_DATACARDS is used */
    93112void
    94113DataCards::ReadFile(string const& fn)
     
    96115  string file = fn;
    97116  if (file == "") {
    98     char * efn = getenv("PEIDA_DATACARDS");
     117    char * efn = getenv("SOPHYA_DATACARDS");
    99118    if (efn != NULL)    file = efn; 
    100119  }
     
    104123    DoReadFile(file);
    105124  } catch(...) {
    106     char* wdp = getenv("PEIDA_WORK");
     125    char* wdp = getenv("SOPHYA_WORK");
    107126    if (wdp) {
    108       cerr << "DataCards::ReadFile() Error reading file " << fn << " (Trying with PEIDA_WORK) \n";
     127      cerr << "DataCards::ReadFile() Error reading file " << fn << " (Trying with SOPHYA_WORK) \n";
    109128      file = wdp + file;
    110129      DoReadFile(file);
     
    115134}
    116135
     136/*! Appends a card, represented by the string \b crd to the list of cards */
    117137void
    118138DataCards::AppendCard(string const& crd)
     
    145165}
    146166
    147 void
    148 DataCards::DoReadFile(string const& fn)
    149 {
    150 char line_buff[512];
    151 FILE *fip;
    152 
    153 if ( (fip = fopen(fn.c_str(),"r")) == NULL ) 
    154   throw IOExc("DataCards::DoReadFile() fopen Error ") ;
    155 while (fgets(line_buff,511,fip) != NULL)
    156   {
    157   line_buff[strlen(line_buff)-1] = '\0';   /*  LF/CR de la fin */
    158   string line(line_buff);
    159   AppendCard(line);
    160   }
    161 }
    162 
    163 int
    164 DataCards::ApplyPF(CrdPF & cpf, string const& key, string const& toks)
    165 {
    166 int l,lk;
    167 int rc = 0;
    168 // On verifie si le "pattern" correspond
    169 bool mtch = false;
    170 l = cpf.patt.length();
    171 if (cpf.patt == "*")  mtch = true;
    172 else if (cpf.patt[0] == '*')   
    173   {
    174   lk = key.length();
    175   if (cpf.patt[l-1] != '*')
    176     {
    177     if (strcmp(key.c_str()+(lk-l+1), cpf.patt.c_str()+1) == 0)   mtch = true;
    178     }
    179   else if  (key.find(cpf.patt.substr(1,l-2)) < lk)  mtch = true;
    180   }
    181 else if (cpf.patt[l-1] == '*')
    182   {
    183   if ( strncmp(key.c_str(), cpf.patt.c_str(),l-1) == 0)  mtch = true;
    184   }
    185 else if (key == cpf.patt)  mtch = true;
    186 
    187 // Si oui, on appelle la fonction correspondante
    188 if (mtch)  rc = cpf.pf(key, toks);
    189 
    190 return(rc);
    191 }
    192 
    193 
    194 int
    195 DataCards::ApplyPFL(string const& key, string const& toks)
    196 {
    197 int rc = 0;
    198 CrdPFList::iterator icf;
    199 for(icf = cpfs.begin(); icf != cpfs.end(); icf++)
    200   rc += ApplyPF((*icf), key, toks);
    201 return(rc);
    202 }
    203 
    204 void 
    205 DataCards::RemoveCard(string const& key)
    206 {
    207 CardList::iterator i;
    208 for(i=cards.begin(); i != cards.end(); i++)
    209   if ((*i).kw == key) { cards.erase(i);  break;  }
    210 }
    211 
    212 DataCards::Card *
    213 DataCards::FindKey(string const& key)
    214 {
    215 /*
    216   CardList::iterator i = find_if(cards.begin(), cards.end(), bind2nd(KeyEq(),key));
    217   if (i == cards.end() ) return NULL;
    218 */
    219   CardList::iterator i;
    220   for(i=cards.begin(); i != cards.end(); i++)
    221     if ((*i).kw == key) return &*i;
    222 
    223   return NULL;
    224 }
    225167
    226168//++
     
    246188
    247189
     190/*! Returns true if \b key is present in the list */
    248191bool
    249192DataCards::HasKey(string const& key)
     
    252195}
    253196
     197//! Returns the total number of cards
    254198int
    255199DataCards::NbCards()
     
    258202}
    259203
     204/*! Returns the number of parameters for card \b key. (-1) if \b key not present  */
    260205int
    261206DataCards::NbParam(string const& key)
     
    266211}
    267212
     213/*! Returns the parameter number \b numero for card \b key */
    268214string
    269215DataCards::SParam(string const& key, int numero, string def)
     
    275221}
    276222
     223/*! Returns the parameter number \b numero for card \b key, converted to type long */
    277224long
    278225DataCards::IParam(string const& key, int numero, long def)
     
    286233}
    287234
     235/*! Returns the parameter number \b numero for card \b key, converted to type double */
    288236double
    289237DataCards::DParam(string const& key, int numero, double def)
     
    298246
    299247   
    300 ostream& operator << (ostream& s, DataCards c)
    301 {
    302   for (DataCards::CardList::iterator i = c.cards.begin(); i != c.cards.end(); i++) {
     248/*! Prints the list of cards on the output stream \b s */
     249void
     250DataCards::Print(ostream& s) const
     251{
     252  for (CardList::const_iterator i = cards.begin(); i != cards.end(); i++) {
    303253    s << setw(10) << (*i).kw << " ";
    304     for (vector<string>::iterator j = (*i).tokens.begin(); j != (*i).tokens.end(); j++)
     254    for (vector<string>::const_iterator j = (*i).tokens.begin(); j != (*i).tokens.end(); j++)
    305255      s << (*j) << " ";
    306256    s << endl;
    307257  }
    308   return s;
    309 }
    310 
    311 
    312 
     258}
     259
     260/*! Reads the file named \b fn. */
     261void
     262DataCards::DoReadFile(string const& fn)
     263{
     264char line_buff[512];
     265FILE *fip;
     266
     267if ( (fip = fopen(fn.c_str(),"r")) == NULL ) 
     268  throw IOExc("DataCards::DoReadFile() fopen Error ") ;
     269while (fgets(line_buff,511,fip) != NULL)
     270  {
     271  line_buff[strlen(line_buff)-1] = '\0';   /*  LF/CR de la fin */
     272  string line(line_buff);
     273  AppendCard(line);
     274  }
     275}
     276
     277int
     278DataCards::ApplyPF(CrdPF & cpf, string const& key, string const& toks)
     279{
     280int l,lk;
     281int rc = 0;
     282// On verifie si le "pattern" correspond
     283bool mtch = false;
     284l = cpf.patt.length();
     285if (cpf.patt == "*")  mtch = true;
     286else if (cpf.patt[0] == '*')   
     287  {
     288  lk = key.length();
     289  if (cpf.patt[l-1] != '*')
     290    {
     291    if (strcmp(key.c_str()+(lk-l+1), cpf.patt.c_str()+1) == 0)   mtch = true;
     292    }
     293  else if  (key.find(cpf.patt.substr(1,l-2)) < lk)  mtch = true;
     294  }
     295else if (cpf.patt[l-1] == '*')
     296  {
     297  if ( strncmp(key.c_str(), cpf.patt.c_str(),l-1) == 0)  mtch = true;
     298  }
     299else if (key == cpf.patt)  mtch = true;
     300
     301// Si oui, on appelle la fonction correspondante
     302if (mtch)  rc = cpf.pf(key, toks);
     303
     304return(rc);
     305}
     306
     307
     308int
     309DataCards::ApplyPFL(string const& key, string const& toks)
     310{
     311int rc = 0;
     312CrdPFList::iterator icf;
     313for(icf = cpfs.begin(); icf != cpfs.end(); icf++)
     314  rc += ApplyPF((*icf), key, toks);
     315return(rc);
     316}
     317
     318void 
     319DataCards::RemoveCard(string const& key)
     320{
     321CardList::iterator i;
     322for(i=cards.begin(); i != cards.end(); i++)
     323  if ((*i).kw == key) { cards.erase(i);  break;  }
     324}
     325
     326DataCards::Card *
     327DataCards::FindKey(string const& key)
     328{
     329/*
     330  CardList::iterator i = find_if(cards.begin(), cards.end(), bind2nd(KeyEq(),key));
     331  if (i == cards.end() ) return NULL;
     332*/
     333  CardList::iterator i;
     334  for(i=cards.begin(); i != cards.end(); i++)
     335    if ((*i).kw == key) return &*i;
     336
     337  return NULL;
     338}
     339
     340
     341
  • trunk/SophyaLib/SUtils/datacards.h

    r754 r895  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: datacards.h,v 1.1 2000-03-02 16:10:59 ansari Exp $
     3// $Id: datacards.h,v 1.2 2000-04-12 17:49:43 ansari Exp $
    44//
    55// Datacards, acquisition EROS II
     
    1414#define DATACARDS_SEEN
    1515
     16#include "machdefs.h"
    1617#include <string.h>
    1718#include <string>
     
    1920#include <list>
    2021#include <vector>
    21 #include <string>
    2222
    23 #include "peida.h"
     23
     24namespace SOPHYA { 
    2425
    2526typedef int (*ProcCard)(string const& key, string const& toks);
    2627 
    27 class DataCards EXC_AWARE {
     28//! Class for decoding parameters from  an ascii file.
     29   
     30class DataCards  {
    2831public:
     32
    2933   DataCards();                 
    3034   DataCards(string const& fn);
    3135
    32            // nom dans variable d'environnement PEIDA_DATACARDS
    33            // par defaut, peida.datacards                       
     36           // nom dans variable d'environnement SOPHYA_DATACARDS
     37           // par defaut, sophya.datacards                       
    3438           // Si pas chemin complet, on tente dans repertoire
    35            // en cours, puis dans PEIDA_WORK
     39           // en cours, puis dans SOPHYA_WORK
    3640
    3741   virtual ~DataCards() {}
     
    5054   double  DParam(string const& key, int numero = 0, double def = 0);
    5155   
    52    friend ostream& operator << (ostream& s, DataCards c);
     56   void    Print(ostream& s) const;
    5357
    54 public:
     58protected:
    5559   struct Card {
    5660     string kw;
    5761     vector<string> tokens;
    58          STRUCTCOMPF(Card,kw)
     62     bool operator == (Card const & b) const { return(kw == b.kw); }
     63     bool operator < (Card const & b) const { return(kw < b.kw); }
    5964   };
    60    typedef list<Card> CardList;
    6165   struct CrdPF {
    6266     ProcCard pf;
    6367     string  patt;
    64          STRUCTCOMPF(CrdPF,pf)
     68     bool operator == (CrdPF const & b) const { return(pf == b.pf); }
     69     bool operator < (CrdPF const & b) const { return(pf == b.pf); }
    6570   };
    66    typedef list<CrdPF> CrdPFList;
    67 protected:
    68    CardList cards;
    69    CrdPFList cpfs;
    7071
    7172   void  DoReadFile(string const& fn);
     
    7778   
    7879   Card* FindKey(string const& key);
     80
     81   typedef list<Card> CardList;
     82   typedef list<CrdPF> CrdPFList;
     83   CardList cards;
     84   CrdPFList cpfs;
     85
    7986   struct KeyEq : binary_function<Card, string, bool> {
    8087    bool operator()(const Card& x, const string& y) const { return x.kw == y; }
    8188   };
    8289};
     90
     91//! operator << overloading - calls Print()
     92inline ostream& operator << (ostream& s, DataCards c)
     93{ c.Print(s); return s; }
     94
     95} // namespace SOPHYA
     96
    8397#endif
  • trunk/SophyaLib/SysTools/ctimer.cc

    r241 r895  
    11//
    2 // $Id: ctimer.cc,v 1.2 1999-04-21 13:11:59 ansari Exp $
     2// $Id: ctimer.cc,v 1.3 2000-04-12 17:49:40 ansari Exp $
    33//
    44
     
    88//++
    99// Class        Timer
    10 // Lib          Outils++
     10// Lib          SysTools
    1111// include      ctimer.h
    1212//
     
    3737//--
    3838
     39/*!
     40  \class SOPHYA::Timer
     41  This class implements a simple chronometer which can be used for
     42  measuring the CPU and elapsed time in functions. The constructor
     43  keeps the start time (and CPU time) and an optional message.
     44  The \b Split method displays the partial time, and destructor
     45  displays the total CPU and elapsed time since timer creation.
     46  The macro \b  TIMEF create a timer object with the function name.
     47  The macro \b  SPLITTIME calls the split methode for the timer created
     48  by TIMEF. A named timer can be created using the macro \b TIMEN(nom)
     49*/
     50
     51/*! Constructor with the specification of a optional name or message */
    3952Timer::Timer(const char* name)
    4053: timerName(name)
     
    5366//--
    5467
    55 
     68/*! Method which displays the partial CPU and elapsed time
     69    An optional message can be passed to be used instead of the
     70    timer name
     71*/
    5672void Timer::Split(const char* comm)
    5773{
     
    6581  int etmt = elapse - elapse0;
    6682
    67   cout << "***Timing " << (comm ? comm : timerName) << endl;
     83  cout << "***Timing " << (comm ? comm : timerName.c_str()) << endl;
    6884
    6985// Pour des formats comme ca, la syntaxe printf est plus agreable.
  • trunk/SophyaLib/SysTools/ctimer.h

    r241 r895  
    11// This may look like C code, but it is really -*- C++ -*-
    22//
    3 // $Id: ctimer.h,v 1.2 1999-04-21 13:12:00 ansari Exp $
     3// $Id: ctimer.h,v 1.3 2000-04-12 17:49:41 ansari Exp $
    44//
    55
     
    88#define CTIMER_SEEN
    99
     10#include "machdefs.h"
    1011#include <sys/types.h>
    1112#include <time.h>
    1213#include <iostream.h>
    1314#include <stdio.h>
    14 #include "machdefs.h"
     15#include <string>
    1516
    1617// <summary> Permet de chronometrer des fonctions. </summary>
     
    2223
    2324// La macro SPLITTIME lui permet d'afficher des temps partiels.
     25namespace SOPHYA {
     26
     27//! Simple chronometer class
    2428class Timer  {
    2529public:
     
    3539
    3640  // Sert a eviter que GNU ne pretende qu'on utilise pas l'objet...
     41  /*! To avoid not used object compiler warnings */
    3742  void Nop() {}
    3843
     
    4045  clock_t cpu0, cpuSplit;
    4146  time_t  elapse0, elapseSplit;
    42   const char* timerName;
     47  string timerName;
    4348};
     49
     50} // namespace SOPHYA
    4451
    4552#define TIMEN(x)  Timer timer(x); timer.Nop();
  • trunk/SophyaLib/SysTools/pdlmgr.cc

    r480 r895  
    1818string*  PDynLinkMgr::tmpDir = NULL;
    1919
     20/*!
     21  \class SOPHYA::PDynLinkMgr
     22  This classes handles the run-time operations related to using shared
     23  libraries. The present version has been adapted for different Unix
     24  flavours (Linux, Compaq/Digital Unix, SGI IRIX, IBM AIX, Sun Solaris).
     25*/
     26
    2027/* --Methode-Static-- */
     28/*! Sets the path for a temporary space where shared libraries are copied.
     29    The path is appended to \b LD_LIBRARY_PATH
     30*/
    2131void PDynLinkMgr::SetTmpDir(string const & path)
    2232{
     
    6373
    6474/* --Methode-Static-- */
     75/*! Returns the temporary space path */
    6576string& PDynLinkMgr::GetTmpDir()
    6677{
     
    6879  tmpDir = new string("");
    6980  char* varenv;
    70   if ( (varenv=getenv("PEIDA_TMP")) != NULL )  *tmpDir = varenv;
     81  if ( (varenv=getenv("SOPHYA_TMP")) != NULL )  *tmpDir = varenv;
    7182  else if ( (varenv=getenv("TMPDIR")) != NULL )  *tmpDir = varenv;
    7283  }
     
    7586
    7687/* --Methode-Static-- */
     88/*! Compiles the C source file named \b fname and creates the
     89    corresponding shared library linking against the standard
     90    C library (-lc) and the math library (-lm).
     91    Returns a pointer to the created PDynLinkMgr object (by new).
     92    Returns the NULL pointer in case of errors.
     93*/
    7794PDynLinkMgr* PDynLinkMgr::BuildFromCFile(string const & fname)
    7895{
     
    131148
    132149/* --Methode-- */
     150/*! The constructor.
     151    \param soname : Name of the shared library. ".so" is appended
     152    to the name if no dot "." is found in the name.
     153    \param cp : if true, copies the shared library in the temporary space.
     154*/
    133155PDynLinkMgr::PDynLinkMgr(string& soname, bool cp)
    134156{
     
    181203
    182204/* --Methode-- */
     205/*! Destructor. Closes the shared library. Removes the file if it had been
     206    copied in the temporary space, or generated by \b BuildFromCFile */
    183207PDynLinkMgr::~PDynLinkMgr()
    184208{
     
    196220
    197221/* --Methode-- */
     222/*! Returns a handle to the function named \b funcname.
     223    Returns the NULL pointer in case of error          */
    198224DlFunction PDynLinkMgr::GetFunction(string const & funcname)
    199225{
  • trunk/SophyaLib/SysTools/pdlmgr.h

    r480 r895  
    1616#endif
    1717
     18namespace SOPHYA {
     19
    1820typedef void (* DlFunction) (void);
    1921
     22//! Dynamic Link Manager.
    2023class PDynLinkMgr {
    2124public:
     
    4548};
    4649
     50} // namespace SOPHYA
     51
    4752#endif
  • trunk/SophyaLib/SysTools/periodic.h

    r480 r895  
    77#include <list>
    88
     9namespace SOPHYA {
     10
    911class Periodic;
    1012typedef list<Periodic*> PeriodicList;
     
    1214typedef void (* UsPeriodicAction) (void *);
    1315
     16//! Class for the execution of a periodic action
    1417class Periodic
    1518{
     
    2326  virtual void SetIntervalms(int dtms);
    2427
     28/*! Returns the time interval in seconds >= 1 sec */
    2529  inline int Interval() { return(mDt); }
     30/*! Returns the time interval in milli-second */
    2631  inline int Intervalms() { return(mDtms); }
    2732
     
    4146};
    4247
     48} // namespace SOPHYA
    4349
    4450#endif
Note: See TracChangeset for help on using the changeset viewer.