Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

H_Naming_Factory.cpp

Go to the documentation of this file.
00001 #include "HTL/H_Naming_Factory.h"
00002 #include "HepODBMS/naming/HepNamingTree.h"
00003 
00004 void H_Naming_Factory::goHome () {
00005   dbApp->naming().changeDirectory(dbApp->userHomePath());
00006 }
00007 
00008 int H_Naming_Factory::init (HepDbApplication *app, char *path, char *dbname,
00009                             char *contname) {
00010   int retval = 0;
00011   HepAnyRef cNode;
00012   app->naming().getCurrentNode(cNode);
00013   if (cNode != 0)   {
00014     if (dbname == 0) { 
00015       /* Retrieve the user database name from the naming tree */
00016       HepRef(ooDBObj) db_h = 0;
00017       db_h = (cNode.containedIn()).containedIn();
00018     }
00019   }  else
00020     HTL_ERR("No database specified and no naming information" )
00021 
00022   if  ( dbname != 0 ) {
00023     retval = H_Factory::init(app,dbname,contname);
00024     goHome();
00025     if (path != 0) {
00026       if (!dbApp->naming().changeDirectory(path)) {
00027         dbApp->naming().createDirectory(path);
00028         dbApp->naming().changeDirectory(path);
00029       }
00030     }
00031   }  
00032   return retval;
00033 }
00034 
00035 int H_Naming_Factory::removeHisto(char * id) {
00036   int retval = 1;
00037   HepAnyRef previous = dbApp->naming().findObject((const char *)id);
00038   if (previous != 0)
00039     dbApp->naming().removeObject((const char *)id);
00040   else
00041     retval = 0;
00042   return retval;
00043 }
00044 
00045 int H_Naming_Factory::checkPrevious (char * id) {
00046   int retval = 1;
00047   HepAnyRef cNode;
00048   dbApp->naming().getCurrentNode(cNode);
00049   if (cNode != 0) {
00050     HepAnyRef previous = dbApp->naming().findObject((const char *)id);
00051     if (previous != 0) {        
00052       if (existingHisto == Override) {
00053         dbApp->naming().removeObject((const char *)id);
00054       } else {
00055         HTL_ERR("Factory mode is 'Keep' and an object with the same name");
00056         HTL_ERR("already exists. The histogram is not created");
00057         retval = 0;
00058       }
00059     }
00060   } else
00061     HTL_ERR("Naming service not available, action ignored" )    
00062   return retval;
00063 }
00064 
00065 HepRef(P_Histo1D) H_Naming_Factory::Histo1D (char *id, const char *a_title, 
00066                                               Size n, double x1, double x2, 
00067                                               End_Point_Convention epc) {
00068   HepRef(P_Histo1D) hhh = 0;
00069   hhh = H_Factory::Histo1D(a_title, n, x1, x2, epc);
00070   if (hhh != 0) {
00071     if (checkPrevious(id) != 0) {       
00072       dbApp->naming().nameObject(hhh,id);
00073     } else {
00074       ooDelete(hhh);
00075       hhh = 0;
00076     }
00077   }
00078   return hhh;
00079 }
00080 
00081 HepRef(P_Histo1D) H_Naming_Factory::Histo1D (int id, const char *a_title, 
00082                                              Size n, double x1, double x2, 
00083                                              End_Point_Convention epc) {
00084   char idc[128];
00085   sprintf (idc,"%d",id);
00086   return Histo1D (idc, a_title, n, x1, x2, epc);
00087 }
00088 
00089 HepRef(P_Histo1DVar) H_Naming_Factory::Histo1DVar(char *id, const char *title,
00090                                              HTL_STD::vector<float> &pts, 
00091                                              End_Point_Convention epc) {
00092   HepRef(P_Histo1DVar) hhh = 0;
00093   hhh = H_Factory::Histo1DVar(title, pts, epc);
00094   if (hhh != 0) {
00095     if (checkPrevious(id) != 0) {       
00096       dbApp->naming().nameObject(hhh,id);
00097     } else {
00098       ooDelete(hhh);
00099       hhh = 0;
00100     }
00101   }
00102   return hhh;
00103 }
00104 
00105 HepRef(P_Histo1DVar) H_Naming_Factory::Histo1DVar (int id, const char *title, 
00106                                              HTL_STD::vector<float> &pts, 
00107                                              End_Point_Convention epc) {
00108   char idc[128];
00109   sprintf (idc,"%d",id);
00110   return Histo1DVar (idc, title, pts, epc);
00111 }
00112 
00113 HepRef(P_Histo1DVar) H_Naming_Factory::Histo1DVar(char *id, const char *title,
00114                                              HTL_STD::vector<double> &pts, 
00115                                              End_Point_Convention epc) {
00116   HepRef(P_Histo1DVar) hhh = 0;
00117   hhh = H_Factory::Histo1DVar(title, pts, epc);
00118   if (hhh != 0) {
00119     if (checkPrevious(id) != 0) {       
00120       dbApp->naming().nameObject(hhh,id);
00121     } else {
00122       ooDelete(hhh);
00123       hhh = 0;
00124     }
00125   }
00126   return hhh;
00127 }
00128 
00129 HepRef(P_Histo1DVar) H_Naming_Factory::Histo1DVar (int id, const char *title, 
00130                                              HTL_STD::vector<double> &pts, 
00131                                              End_Point_Convention epc) {
00132   char idc[128];
00133   sprintf (idc,"%d",id);
00134   return Histo1DVar (idc, title, pts, epc);
00135 }
00136 
00137 HepRef(P_ProfileHisto1D) 
00138 H_Naming_Factory::ProfileHisto (char *id, const char *a_title, 
00139                                        Size n, double x1, double x2, 
00140                                        End_Point_Convention epc) {
00141   HepRef(P_ProfileHisto1D) hhh = 0;
00142   hhh = H_Factory::ProfileHisto(a_title, n, x1, x2, epc);
00143   if (hhh != 0) {
00144     if (checkPrevious(id) != 0) {       
00145       dbApp->naming().nameObject(hhh,id);
00146     } else {
00147       ooDelete(hhh);
00148       hhh = 0;
00149     }
00150   }
00151   return hhh;
00152 }
00153 
00154 HepRef(P_ProfileHisto1D) 
00155   H_Naming_Factory::ProfileHisto (int id, const char *title, 
00156                                     Size n, double x1, double x2, 
00157                                     End_Point_Convention epc) {
00158   char idc[128];
00159   sprintf (idc,"%d",id);
00160   return ProfileHisto (idc, title, n, x1, x2, epc);
00161 }
00162 
00163 HepRef(P_ProfileHisto1DVar) 
00164   H_Naming_Factory::ProfileHistoVar(char *id, const char *title,
00165                                       HTL_STD::vector<float> &pts, 
00166                                       End_Point_Convention epc) {
00167   HepRef(P_ProfileHisto1DVar) hhh = 0;
00168   hhh = H_Factory::ProfileHistoVar(title, pts, epc);
00169   if (hhh != 0) {
00170     if (checkPrevious(id) != 0) {       
00171       dbApp->naming().nameObject(hhh,id);
00172     } else {
00173       ooDelete(hhh);
00174       hhh = 0;
00175     }
00176   }
00177   return hhh;
00178 }
00179 
00180 HepRef(P_ProfileHisto1DVar) 
00181   H_Naming_Factory::ProfileHistoVar (int id, const char *title, 
00182                                        HTL_STD::vector<float> &pts, 
00183                                        End_Point_Convention epc) {
00184   char idc[128];
00185   sprintf (idc,"%d",id);
00186   return ProfileHistoVar (idc, title, pts, epc);
00187 }
00188 
00189 HepRef(P_ProfileHisto1DVar) 
00190   H_Naming_Factory::ProfileHistoVar(char *id, const char *title,
00191                                       HTL_STD::vector<double> &pts, 
00192                                       End_Point_Convention epc) {
00193   HepRef(P_ProfileHisto1DVar) hhh = 0;
00194   hhh = H_Factory::ProfileHistoVar(title, pts, epc);
00195   if (hhh != 0) {
00196     if (checkPrevious(id) != 0) {       
00197       dbApp->naming().nameObject(hhh,id);
00198     } else {
00199       ooDelete(hhh);
00200       hhh = 0;
00201     }
00202   }
00203   return hhh;
00204 }
00205 
00206 HepRef(P_ProfileHisto1DVar) 
00207   H_Naming_Factory::ProfileHistoVar (int id, const char *title, 
00208                                        HTL_STD::vector<double> &pts, 
00209                                        End_Point_Convention epc) {
00210   char idc[128];
00211   sprintf (idc,"%d",id);
00212   return ProfileHistoVar (idc, title, pts, epc);
00213 }
00214 
00215 HepRef(P_Histo2D) H_Naming_Factory::Histo2D (char *id, const char *a_title, 
00216                                               Size n1, double x1 , double x2, 
00217                                               Size n2, double y1 , double y2, 
00218                                               End_Point_Convention epc1 , 
00219                                               End_Point_Convention epc2 ) {
00220   HepRef(P_Histo2D) hhh = 0;
00221   hhh = H_Factory::Histo2D(a_title,n1,x1,x2,n2,y1,y2,epc1,epc2);
00222   if (hhh != 0) {
00223     if (checkPrevious(id) != 0) {       
00224       dbApp->naming().nameObject(hhh,id);
00225     } else {
00226       ooDelete(hhh);
00227       hhh = 0;
00228     }
00229   }
00230   return hhh;
00231 }
00232 
00233 HepRef(P_Histo2D) H_Naming_Factory::Histo2D (int id, const char *a_title, 
00234                                               Size n1, double x1 , double x2, 
00235                                               Size n2, double y1 , double y2, 
00236                                               End_Point_Convention epc1 , 
00237                                               End_Point_Convention epc2 ) {
00238   char idc[128];
00239   sprintf (idc,"%d",id);
00240   return  Histo2D(idc,a_title,n1,x1,x2,n2,y1,y2,epc1,epc2);
00241 }
00242 
00243 
00244 HepRef(P_Histo2DVar) 
00245   H_Naming_Factory::Histo2DVar(char *id, const char *a_title, 
00246                                HTL_STD::vector<float> &pts1, 
00247                                HTL_STD::vector<float> &pts2,
00248                                End_Point_Convention epc1,
00249                                End_Point_Convention epc2) {
00250   HepRef(P_Histo2DVar) hhh = 0;
00251 
00252   hhh = H_Factory::Histo2DVar(a_title,pts1,pts2,epc1,epc2);
00253   if (hhh != 0) {
00254     if (checkPrevious(id) != 0) {       
00255       dbApp->naming().nameObject(hhh,id);
00256     } else {
00257       ooDelete(hhh);
00258       hhh = 0;
00259     }
00260   }
00261   return hhh;
00262 }
00263 
00264 HepRef(P_Histo2DVar) 
00265   H_Naming_Factory::Histo2DVar(int id, const char *a_title, 
00266                                HTL_STD::vector<float> &pts1, 
00267                                HTL_STD::vector<float> &pts2,
00268                                End_Point_Convention epc1,
00269                                End_Point_Convention epc2) {
00270   char idc[128];
00271   sprintf (idc,"%d",id);
00272   return  Histo2DVar(idc,a_title,pts1,pts2,epc1,epc2);
00273 }
00274 
00275 HepRef(P_Histo2DVar) 
00276   H_Naming_Factory::Histo2DVar(char *id, const char *a_title, 
00277                                HTL_STD::vector<double> &pts1, 
00278                                HTL_STD::vector<double> &pts2,
00279                                End_Point_Convention epc1,
00280                                End_Point_Convention epc2) {
00281   HepRef(P_Histo2DVar) hhh = 0;
00282 
00283   hhh = H_Factory::Histo2DVar(a_title,pts1,pts2,epc1,epc2);
00284   if (hhh != 0) {
00285     if (checkPrevious(id) != 0) {       
00286       dbApp->naming().nameObject(hhh,id);
00287     } else {
00288       ooDelete(hhh);
00289       hhh = 0;
00290     }
00291   }
00292   return hhh;
00293 }
00294 
00295 HepRef(P_Histo2DVar) 
00296   H_Naming_Factory::Histo2DVar(int id, const char *a_title, 
00297                                HTL_STD::vector<double> &pts1, 
00298                                HTL_STD::vector<double> &pts2,
00299                                End_Point_Convention epc1,
00300                                End_Point_Convention epc2) {
00301   char idc[128];
00302   sprintf (idc,"%d",id);
00303   return  Histo2DVar(idc,a_title,pts1,pts2,epc1,epc2);
00304 }


Anaphe documentation generated by Doxygen (www.doxygen.org)