Bdb packages | Design docs | Source docs | Guidelines | Recent releases

Search | Site Map .

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/CdbTools/CdbToolslsViewCmd.cc

Go to the documentation of this file.
00001 //
00002 //
00003 //
00004 #include "BaBar/BaBar.hh"
00005 
00006 #include "CdbTools/CdbToolslsViewCmd.hh"
00007 //
00008 //
00009 #include "CdbBase/CdbDatabase.hh"
00010 #include "CdbBase/CdbDatabaseItr.hh"
00011 #include "CdbBase/CdbView.hh"
00012 #include "CdbBase/CdbViewItr.hh"
00013 #include "CdbBase/Cdb.hh"
00014 #include "CdbBase/CdbStatus.hh"
00015 #include "CdbTools/CdbToolsContext.hh"
00016 
00017 CdbToolslsViewCmd::CdbToolslsViewCmd(CdbToolsContext* context)
00018   :CdbToolsCmd(context)
00019   ,_dbName("")
00020 {
00021 
00022 }
00023 CdbToolslsViewCmd::~CdbToolslsViewCmd()
00024 {
00025 }
00026 
00027 CdbToolsStatus::CdbCmdStatus
00028 CdbToolslsViewCmd::listView()
00029 {
00030   CdbToolsStatus::CdbCmdStatus status = CdbToolsStatus::Success;
00031   //Get a pointer to the database
00032 
00033   CdbDatabasePtr dbPtr;
00034   CdbStatus stat = CdbDatabase::instance(dbPtr, _dbName.c_str());
00035 
00036   if(stat != CdbStatus::Success){
00037     MsgOut<<"Faild to find and open the database \"" << _dbName
00038           << "\" due to: " << stat << endl;
00039     return CdbToolsStatus::Invalid;
00040   }
00041   CdbViewItr vItr;
00042   if(CdbStatus::Success != dbPtr->viewIterator( vItr )){
00043     MsgOut<<"Could not get a view iterator " << endl;
00044     return CdbToolsStatus::Invalid;
00045   }
00046   
00047   while( vItr.next( )) {
00048    MsgOut << "View: " << vItr.value( ) << endl;
00049   }
00050 
00051   return status;
00052 }
00053 CdbToolsStatus::CdbCmdStatus
00054 CdbToolslsViewCmd::doExecute()
00055 {
00056   CdbToolsStatus::CdbCmdStatus status = CdbToolsStatus::Error;
00057 
00058     if(argc() > 1){
00059       if(argv(1) == "-database"
00060          ||  argv(1) == "-db") {
00061         _dbName = argv(2);
00062       }
00063     }else{
00064       _dbName = context()->currentDB();
00065     }
00066 
00067   status = listView();
00068   resetNames();
00069 
00070   return status;
00071 }
00072 void
00073 CdbToolslsViewCmd::resetNames()
00074 {
00075   _dbName = "";
00076 }
00077 void
00078 CdbToolslsViewCmd::help()
00079 {
00080   MsgOut << "list view command:\n"
00081          <<" this command list all the views under the present daabase>\n"
00082          <<endl;
00083 }
00084 
00085 
00086 
00087 
00088 

 


BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us

Page Owner: Jacek Becla
Last Update: October 04, 2002