irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_database_manager.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
2 // irods includes
4 #include "irods_load_plugin.hpp"
5 
6 namespace irods {
7 // =-=-=-=-=-=-=-
8 // database manager singleton
10 
11 // =-=-=-=-=-=-=-
12 // public - Constructor
14 
15  } // ctor
16 
17 // =-=-=-=-=-=-=-
18 // public - Copy Constructor
20  plugins_ = _rhs.plugins_;
21 
22  } // cctor
23 
24 // =-=-=-=-=-=-=-
25 // public - Destructor
27 
28  } // dtor
29 
30 // =-=-=-=-=-=-=-
31 // public - retrieve a database plugin given its key
33  std::string _key,
34  database_ptr& _value ) {
35 
36  if ( _key.empty() ) {
37  return ERROR( SYS_INVALID_INPUT_PARAM, "empty key" );
38  }
39 
40  if ( plugins_.has_entry( _key ) ) {
41  _value = plugins_[ _key ];
42  return SUCCESS();
43 
44  }
45  else {
46  std::stringstream msg;
47  msg << "no database plugin found for name ["
48  << _key
49  << "]";
50  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
51 
52  }
53 
54  } // resolve
55 
57  database_ptr& _plugin,
58  const std::string& _plugin_name,
59  const std::string& _inst_name,
60  const std::string& _context ) {
61 
62  // =-=-=-=-=-=-=-
63  // call generic plugin loader
64  database* db = 0;
65  error ret = load_plugin< database >(
66  db,
67  _plugin_name,
69  _inst_name,
70  _context );
71  if ( ret.ok() && db ) {
72  _plugin.reset( db );
73  return SUCCESS();
74 
75  }
76 
77  return PASS( ret );
78 
79  } // load_database_plugin
80 
81 // =-=-=-=-=-=-=-
82 // public - given a type, load up a database plugin
84  const std::string& _type,
85  const std::string& _key,
86  const std::string& _inst,
87  const std::string& _ctx,
88  database_ptr& _db ) {
89  // =-=-=-=-=-=-=-
90  // create the database plugin and add it to the table
91  database_ptr ptr;
92  error ret = load_database_plugin( ptr, _type, _inst, _ctx );
93  if ( !ret.ok() ) {
94  return PASSMSG( "Failed to load database plugin", ret );
95  }
96 
97  plugins_[ _key ] = ptr;
98 
99  _db = plugins_[ _key ];
100 
101  return SUCCESS();
102 
103  } // init_from_type
104 
105 }; // namespace irods
106 
107 
108 
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
irods::database_manager::resolve
error resolve(std::string, database_ptr &)
Definition: irods_database_manager.cpp:32
irods::database_manager::database_manager
database_manager()
Definition: irods_database_manager.cpp:13
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
irods::database_manager::~database_manager
virtual ~database_manager()
Definition: irods_database_manager.cpp:26
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods::db_mgr
database_manager db_mgr
Definition: irods_database_manager.cpp:9
irods::PLUGIN_TYPE_DATABASE
const std::string PLUGIN_TYPE_DATABASE("database")
irods_database_manager.hpp
irods
Definition: apiHandler.hpp:35
irods_load_plugin.hpp
irods::database_manager::init_from_type
error init_from_type(const std::string &, const std::string &, const std::string &, const std::string &, database_ptr &)
Definition: irods_database_manager.cpp:83
irods::lookup_table::has_entry
bool has_entry(KeyType _k) const
Definition: irods_lookup_table.hpp:41
irods::database_manager::plugins_
lookup_table< database_ptr > plugins_
Definition: irods_database_manager.hpp:51
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::database_manager::load_database_plugin
error load_database_plugin(database_ptr &, const std::string &, const std::string &, const std::string &)
Definition: irods_database_manager.cpp:56
irods::error
Definition: irods_error.hpp:23
irods::database_ptr
boost::shared_ptr< database > database_ptr
Definition: irods_database_types.hpp:21
irods::database
Definition: irods_database_plugin.hpp:17
irods::database_manager
Definition: irods_database_manager.hpp:14
irods::error::ok
bool ok()
Definition: irods_error.cpp:258