39 using std::stringstream ;
42 #include "BESContainerStorageFile.h" 43 #include "BESFileContainer.h" 44 #include "TheBESKeys.h" 45 #include "BESInternalError.h" 46 #include "BESSyntaxUserError.h" 48 #include "BESServiceRegistry.h" 86 string key =
"BES.Container.Persistence.File." + n ;
91 string s = key +
" not defined in BES configuration file" ;
95 ifstream persistence_file( _file.c_str() ) ;
97 if( !persistence_file )
99 char *err = strerror( myerrno ) ;
100 string s =
"Unable to open persistence file " + _file +
": " ;
104 s +=
"Unknown error" ;
111 while( !persistence_file.eof() )
114 persistence_file.getline( cline, 80 ) ;
115 if( !persistence_file.eof() )
118 BESContainerStorageFile::container *c =
119 new BESContainerStorageFile::container ;
120 strm >> c->_symbolic_name ;
121 strm >> c->_real_name ;
122 strm >> c->_container_type ;
125 if( c->_symbolic_name ==
"" ||
126 c->_real_name ==
"" ||
127 c->_container_type ==
"" )
130 persistence_file.close() ;
131 string s =
"Incomplete container persistence line in file " 137 persistence_file.close() ;
139 string s =
"Too many fields in persistence file " 143 _container_list[c->_symbolic_name] = c ;
146 persistence_file.close() ;
149 BESContainerStorageFile::~BESContainerStorageFile()
151 BESContainerStorageFile::Container_citer i = _container_list.begin() ;
152 BESContainerStorageFile::Container_citer ie = _container_list.end() ;
153 for( ; i != ie; i++ )
155 BESContainerStorageFile::container *c = (*i).second ;
175 BESContainerStorageFile::Container_citer i ;
176 i = _container_list.find( sym_name ) ;
177 if( i != _container_list.end() )
179 BESContainerStorageFile::container *c = (*i).second;
182 c->_container_type ) ;
185 return ret_container ;
203 string err =
"Unable to add a container to a file, not yet implemented" ;
220 BESContainerStorageFile::Container_iter i ;
221 i = _container_list.find( s_name ) ;
222 if( i != _container_list.end() )
224 BESContainerStorageFile::container *c = (*i).second;
225 _container_list.erase( i ) ;
245 while( _container_list.size() != 0 )
247 Container_iter ci = _container_list.begin() ;
248 BESContainerStorageFile::container *c = (*ci).second;
249 _container_list.erase( ci ) ;
267 list<string> &provides )
301 BESContainerStorageFile::Container_citer i ;
302 i = _container_list.begin() ;
303 for( i = _container_list.begin(); i != _container_list.end(); i++ )
305 BESContainerStorageFile::container *c = (*i).second;
306 string sym = c->_symbolic_name ;
307 string real = c->_real_name ;
308 string type = c->_container_type ;
323 strm << BESIndent::LMarg <<
"BESContainerStorageFile::dump - (" 324 << (
void *)
this <<
")" << endl ;
325 BESIndent::Indent() ;
326 strm << BESIndent::LMarg <<
"name: " <<
get_name() << endl ;
327 strm << BESIndent::LMarg <<
"file: " << _file << endl ;
328 if( _container_list.size() )
330 strm << BESIndent::LMarg <<
"containers:" << endl ;
331 BESIndent::Indent() ;
332 BESContainerStorageFile::Container_citer i = _container_list.begin() ;
333 BESContainerStorageFile::Container_citer ie = _container_list.end() ;
334 for( i = _container_list.begin(); i != ie; i++ )
336 BESContainerStorageFile::container *c = (*i).second;
337 strm << BESIndent::LMarg << c->_symbolic_name ;
338 strm <<
", " << c->_real_name ;
339 strm <<
", " << c->_container_type ;
342 BESIndent::UnIndent() ;
346 strm << BESIndent::LMarg <<
" containers: none" << endl ;
348 BESIndent::UnIndent() ;
provides persistent storage for data storage information represented by a container.
virtual void show_container(const string &sym_name, const string &real_name, const string &type, BESInfo &info)
add information for a container to the informational response object
exception thrown if inernal error encountered
virtual bool del_container(const string &s_name)
removes a container with the given symbolic name
virtual void show_containers(BESInfo &info)
show information for each container in this persistent store
Holds real data, container type and constraint for symbolic name read from persistence.
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
virtual void dump(ostream &strm) const
dumps information about this object
error thrown if there is a user syntax error in the request or any other user error
informational response object
static TheBESKeys * TheKeys()
virtual void add_container(const string &sym_name, const string &real_name, const string &type)
adds a container with the provided information
virtual bool isData(const string &inQuestion, list< string > &provides)
determine if the given container is data and what servies are available for it
virtual BESContainer * look_for(const string &sym_name)
looks for the specified container in the list of containers loaded from the file.
virtual bool del_containers()
removes all containers
string get_container_type() const
retrieve the type of data this container holds, such as cedar or netcdf.
A container is something that holds data. I.E. a netcdf file or a database entry.
BESContainerStorageFile(const string &n)
pull container information from the specified file
virtual const string & get_name() const
retrieve the name of this persistent store
virtual void services_handled(const string &handler, list< string > &services)
returns the list of servies provided by the handler in question