Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

cmt_branch.cxx

Go to the documentation of this file.
00001 //-----------------------------------------------------------
00002 // Copyright Christian Arnault LAL-Orsay CNRS
00003 // arnault@lal.in2p3.fr
00004 // See the complete license in cmt_license.txt "http://www.cecill.info". 
00005 //-----------------------------------------------------------
00006 
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <string.h>
00010 #include <ctype.h>
00011 
00012 #include "cmt_branch.h"
00013 #include "cmt_database.h"
00014 
00015 /*----------------------------------------------------------*/
00016 /*                                                          */
00017 /*  Operations on Branches                                  */
00018 /*                                                          */
00019 /*----------------------------------------------------------*/
00020 
00021 /*----------------------------------------------------------*/
00022 void Branch::action (const CmtSystem::cmt_string_vector& words)
00023 /*----------------------------------------------------------*/
00024 {
00025   for (int i = 1; i < words.size (); i++)
00026     {
00027       const cmt_string& name = words[i];
00028       if (name == "") return;
00029 
00030       add (name);
00031     }
00032 }
00033 
00034 /*----------------------------------------------------------*/
00035 Branch* Branch::find (const cmt_string& name)
00036 /*----------------------------------------------------------*/
00037 {
00038   static BranchVector& Branches = branches ();
00039 
00040   int branch_index;
00041 
00042   if (Branches.size () == 0) return (0);
00043 
00044   for (branch_index = 0;
00045        branch_index < Branches.size ();
00046        branch_index++)
00047     {
00048       Branch& branch = Branches[branch_index];
00049 
00050       if (branch.name () == name)
00051         {
00052           return (&branch);
00053         }
00054     }
00055 
00056   return (0);
00057 }
00058 
00059 /*----------------------------------------------------------*/
00060 void Branch::add (const cmt_string& name)
00061 /*----------------------------------------------------------*/
00062 {
00063   static BranchVector& Branches = branches ();
00064 
00065   {
00066     Branch* branch;
00067 
00068     branch = find (name);
00069     if (branch != 0) return;
00070   }
00071 
00072   Branch& branch = Branches.add ();
00073 
00074   branch.m_name = name;
00075 }
00076 
00077 /*----------------------------------------------------------*/
00078 void Branch::print_all (PrintMode mode)
00079 /*----------------------------------------------------------*/
00080 {
00081   static BranchVector& Branches = branches ();
00082 
00083   int number;
00084 
00085   for (number = 0; number < Branches.size (); number++)
00086     {
00087       if (number > 0) cout << " ";
00088       Branches[number].print (mode);
00089     }
00090   if (number > 0) cout << endl;
00091 }
00092 
00093 /*----------------------------------------------------------*/
00094 void Branch::clear_all ()
00095 /*----------------------------------------------------------*/
00096 {
00097   static BranchVector& Branches = branches ();
00098 
00099   int number;
00100 
00101   for (number = 0; number < Branches.size (); number++)
00102     {
00103       Branch& b = Branches[number];
00104 
00105       b.m_name = "";
00106     }
00107 
00108   Branches.clear ();
00109 }
00110 
00111 /*----------------------------------------------------------*/
00112 Branch::BranchVector& Branch::branches ()
00113 /*----------------------------------------------------------*/
00114 {
00115   static Database& db = Database::instance ();
00116   static BranchVector& Branches = db.branches ();
00117 
00118   return (Branches);
00119 }
00120 
00121 /*----------------------------------------------------------*/
00122 Branch::Branch ()
00123 /*----------------------------------------------------------*/
00124 {
00125 }
00126 
00127 /*----------------------------------------------------------*/
00128 Branch::~Branch ()
00129 /*----------------------------------------------------------*/
00130 {
00131 }
00132 
00133 /*----------------------------------------------------------*/
00134 const cmt_string& Branch::name () const
00135 /*----------------------------------------------------------*/
00136 {
00137   return (m_name);
00138 }
00139 
00140 /*----------------------------------------------------------*/
00141 void Branch::print (PrintMode mode) const
00142 /*----------------------------------------------------------*/
00143 {
00144   cout << m_name;
00145 }
00146 

Generated on Mon May 2 10:25:04 2005 for CMT by doxygen 1.3.5