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_resource_backport.hpp
Go to the documentation of this file.
1 #ifndef __IRODS_RESOURCE_BACKPORT_HPP_
2 #define __IRODS_RESOURCE_BACKPORT_HPP_
3 
4 // =-=-=-=-=-=-=-
7 
8 // =-=-=-=-=-=-=-
9 // irods includes
10 #include "rsGlobalExtern.hpp"
11 
12 namespace irods {
13 
14 // =-=-=-=-=-=-=-
15 // helper functions for knitting back into legacy irods code
17  error get_resc_properties_as_kvp(const std::string&, keyValPair_t*);
19  error is_hier_live( const std::string& );
20  error set_default_resource( rsComm_t*, const std::string&, const std::string&, keyValPair_t*, std::string& );
21  error resolve_resource_name( const std::string&, keyValPair_t*, std::string& );
24  const std::string&, // hier string
25  int&, // local flag
26  rodsServerHost_t*& ); // server host
27  error get_resc_type_for_hier_string( const std::string&, std::string& );
28 
29 // =-=-=-=-=-=-=-
32  const std::string& _hier, // hier string
33  std::string& _loc );// location
34 
35  template< typename T >
36  error get_resource_property( rodsLong_t _resc_id, const std::string& _prop_name, T& _prop ) {
37  // =-=-=-=-=-=-=-
38  // resolve the resource by name
39  resource_ptr resc;
40  error res_err = resc_mgr.resolve( _resc_id, resc );
41  if ( !res_err.ok() ) {
42  std::stringstream msg;
43  msg << "failed to resolve resource [";
44  msg << _prop_name;
45  msg << "]";
46  return PASSMSG( msg.str(), res_err );
47  }
48 
49  // =-=-=-=-=-=-=-
50  // get the resource property
51  error get_err = resc->get_property< T >( _prop_name, _prop );
52  if ( !get_err.ok() ) {
53  std::stringstream msg;
54  msg << "failed to get property [";
55  msg << _prop_name;
56  msg << "]";
57  return PASSMSG( msg.str(), get_err );
58  }
59 
60  return SUCCESS();
61 
62  } // get_resource_property
63 
64  template< typename T >
65  error set_resource_property( std::string _name, const std::string& _prop_name, T& _prop ) {
66  // =-=-=-=-=-=-=-
67  // resolve the resource by name
68  resource_ptr resc;
69  error res_err = resc_mgr.resolve( _name, resc );
70  if ( !res_err.ok() ) {
71  std::stringstream msg;
72  msg << "failed to resolve resource [";
73  msg << _prop_name;
74  msg << "]";
75  return PASSMSG( msg.str(), res_err );
76  }
77 
78  // =-=-=-=-=-=-=-
79  // set the resource property
80  error set_err = resc->set_property< T >( _prop_name, _prop );
81  if ( !set_err.ok() ) {
82  std::stringstream msg;
83  msg << "failed to set property [";
84  msg << _prop_name;
85  msg << "]";
86  return PASSMSG( msg.str(), set_err );
87  }
88 
89  return SUCCESS();
90 
91  } // set_resource_property
92 
94  template< typename T >
96  const std::string& _hier_string,
97  const std::string& _prop_name,
98  T& _prop ) {
99 
100  error result = SUCCESS();
101  error ret;
103  ret = parser.set_string( _hier_string );
104  if ( !ret.ok() ) {
105  std::stringstream msg;
106  msg << __FUNCTION__;
107  msg << " - Failed to parse hierarchy string: \"" << _hier_string << "\"";
108  result = PASSMSG( msg.str(), ret );
109  }
110  else {
111  std::string last_resc;
112  ret = parser.last_resc( last_resc );
113  if ( !ret.ok() ) {
114  std::stringstream msg;
115  msg << __FUNCTION__;
116  msg << " - Failed to get last resource in hierarchy: \"" << _hier_string << "\"";
117  result = PASSMSG( msg.str(), ret );
118  }
119  else {
120  ret = get_resource_property<T>( last_resc, _prop_name, _prop );
121  if ( !ret.ok() ) {
122  std::stringstream msg;
123  msg << __FUNCTION__;
124  msg << " - Failed to get property: \"" << _prop_name << "\" from resource: \"" << last_resc << "\"";
125  result = PASSMSG( msg.str(), ret );
126  }
127  }
128  }
129 
130  return result;
131  }
132 
133  error get_vault_path_for_hier_string( const std::string& _hier_string, std::string& _rtn_vault_path );
134 }; // namespace irods
135 
136 #endif // __IRODS_RESOURCE_BACKPORT_HPP_
137 
138 
139 
140 
rsComm_t
Definition: rcConnect.h:145
irods::get_vault_path_for_hier_string
error get_vault_path_for_hier_string(const std::string &_hier_string, std::string &_rtn_vault_path)
Definition: irods_resource_backport.cpp:658
irods::get_resource_property
error get_resource_property(rodsLong_t _resc_id, const std::string &_prop_name, T &_prop)
Definition: irods_resource_backport.hpp:36
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
irods::resource_to_kvp
error resource_to_kvp(resource_ptr &, keyValPair_t *)
Definition: irods_resource_backport.cpp:15
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
irods::is_hier_live
error is_hier_live(const std::string &)
Definition: irods_resource_backport.cpp:234
irods::set_default_resource
error set_default_resource(rsComm_t *, const std::string &, const std::string &, keyValPair_t *, std::string &)
Definition: irods_resource_backport.cpp:298
irods::get_resc_type_for_hier_string
error get_resc_type_for_hier_string(const std::string &, std::string &)
Definition: irods_resource_backport.cpp:677
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
deploy_schemas_locally.parser
parser
Definition: deploy_schemas_locally.py:59
irods::get_resc_hier_property
error get_resc_hier_property(const std::string &_hier_string, const std::string &_prop_name, T &_prop)
Definition: irods_resource_backport.hpp:95
irods::get_resc_properties_as_kvp
error get_resc_properties_as_kvp(const std::string &, keyValPair_t *)
Definition: irods_resource_backport.cpp:500
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
rsGlobalExtern.hpp
irods
Definition: apiHandler.hpp:35
irods::get_host_for_hier_string
error get_host_for_hier_string(const std::string &, int &, rodsServerHost_t *&)
Definition: irods_resource_backport.cpp:581
irods::resource_manager::resolve
error resolve(std::string, resource_ptr &)
Definition: irods_resource_manager.cpp:51
irods::error
Definition: irods_error.hpp:23
irods::resolve_resource_name
error resolve_resource_name(const std::string &, keyValPair_t *, std::string &)
Definition: irods_resource_backport.cpp:432
irods::set_resource_property
error set_resource_property(std::string _name, const std::string &_prop_name, T &_prop)
Definition: irods_resource_backport.hpp:65
irods::get_host_status_by_host_info
error get_host_status_by_host_info(rodsServerHost_t *)
Definition: irods_resource_backport.cpp:469
irods_hierarchy_parser.hpp
rodsServerHost
Definition: rodsConnect.h:62
error
int error
Definition: filesystem.cpp:101
irods_resource_manager.hpp
irods::get_loc_for_hier_string
error get_loc_for_hier_string(const std::string &_hier, std::string &_loc)
Definition: irods_resource_backport.cpp:633
KeyValPair
Definition: objInfo.h:120
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
irods::is_resc_live
error is_resc_live(rodsLong_t)
Definition: irods_resource_backport.cpp:263