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_collection_object.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
5 #include "irods_stacktrace.hpp"
6 
8 
9 namespace irods {
10 
11 // =-=-=-=-=-=-=-
12 // public - ctor
14  data_object(),
15  directory_pointer_( 0 ) {
16  } // collection_object
17 
18 // =-=-=-=-=-=-=-
19 // public - cctor
21  const collection_object& _rhs ) :
22  data_object( _rhs ) {
24 
25  } // cctor
26 
27 // =-=-=-=-=-=-=-
28 // public - ctor
30  const std::string& _fn,
31  rodsLong_t _resc_id,
32  int _m,
33  int _f ) :
35  _fn,
36  _resc_id,
37  _m,
38  _f ),
39  directory_pointer_( 0 ) {
40 
41  } // collection_object
42 
43 
44 // =-=-=-=-=-=-=-
45 // public - ctor
47  const std::string& _fn,
48  rodsLong_t _resc_id,
49  int _m,
50  int _f,
51  const keyValPair_t& _cond_input ) :
53  _fn,
54  _resc_id,
55  _m,
56  _f,
57  _cond_input ),
58  directory_pointer_( 0 ) {
59 
60  } // collection_object
61 
62 // =-=-=-=-=-=-=-
63 // public - ctor
65  const std::string& _fn,
66  const std::string& _resc_hier,
67  int _m,
68  int _f ) :
70  _fn,
71  _resc_hier,
72  _m,
73  _f ),
74  directory_pointer_( 0 ) {
75 
76  } // collection_object
77 
78 
79 // =-=-=-=-=-=-=-
80 // public - ctor
82  const std::string& _fn,
83  const std::string& _resc_hier,
84  int _m,
85  int _f,
86  const keyValPair_t& _cond_input ) :
88  _fn,
89  _resc_hier,
90  _m,
91  _f,
92  _cond_input ),
93  directory_pointer_( 0 ) {
94 
95  } // collection_object
96 
97 // =-=-=-=-=-=-=-
98 // public - dtor
100 
101  } // dtor
102 
103 // =-=-=-=-=-=-=-
104 // public - assignment operator
106  // =-=-=-=-=-=-=-
107  // call base class assignment first
108  data_object::operator=( _rhs );
109 
111 
112  return *this;
113 
114  } // operator=
115 
116 // =-=-=-=-=-=-=-
117 // plugin - resolve resource plugin for this object
119  const std::string& _interface,
120  plugin_ptr& _ptr ) {
121  // =-=-=-=-=-=-=-
122  // check to see if this is for a resource plugin
123  // resolution, otherwise it is an error
124  if ( RESOURCE_INTERFACE != _interface ) {
125  std::stringstream msg;
126  msg << "collection_object does not support a [";
127  msg << _interface;
128  msg << "] for plugin resolution";
129  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
130  }
131 
132  error result = SUCCESS();
133  error ret;
134 
135  hierarchy_parser hparse;
136  ret = hparse.set_string( resc_hier() );
137 
138  if ( !ret.ok() ) {
139  std::stringstream msg;
140  msg << __FUNCTION__ << " - ";
141  msg << "error parsing resource hierarchy \"" << resc_hier() << "\"";
142  result = PASSMSG( msg.str(), ret );
143  }
144  else {
145  std::string resc;
146 
147  ret = hparse.first_resc( resc );
148  if ( !ret.ok() ) {
149  std::stringstream msg;
150  msg << __FUNCTION__ << " - ERROR getting first resource from hierarchy.";
151  result = PASSMSG( msg.str(), ret );
152  }
153  else {
154 
155  if ( resc.empty() && resc_hier().empty() ) {
156  std::stringstream msg;
157  msg << __FUNCTION__;
158  msg << " - No resource hierarchy or resource specified.";
159  return ERROR( HIERARCHY_ERROR, msg.str() );
160  }
161  else if ( resc.empty() ) {
162  return ERROR( HIERARCHY_ERROR, "Hierarchy string is not empty but first resource is!" );
163  }
164 
165  resource_ptr resc_ptr;
166  ret = resc_mgr.resolve( resc, resc_ptr );
167  if ( !ret.ok() ) {
168  std::stringstream msg;
169  msg << __FUNCTION__ << " - ERROR resolving resource \"" << resc << "\"";
170  result = PASSMSG( msg.str(), ret );
171  }
172 
173  _ptr = boost::dynamic_pointer_cast< resource >( resc_ptr );
174  }
175  }
176  return result;
177 
178  } // resolve
179 
180 // =-=-=-=-=-=-=-
181 // public - get vars from object for rule engine
183  rule_engine_vars_t& _kvp ) {
184  data_object::get_re_vars( _kvp );
185  return SUCCESS();
186 
187  } // get_re_vars
188 
189 
190 }; // namespace irods
191 
192 
193 
irods::plugin_ptr
boost::shared_ptr< plugin_base > plugin_ptr
Definition: irods_first_class_object.hpp:18
irods.pyparsing.empty
empty
Definition: pyparsing.py:3430
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
irods::collection_object::operator=
virtual collection_object & operator=(const collection_object &)
Definition: irods_collection_object.cpp:105
irods_stacktrace.hpp
irods_collection_object.hpp
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
irods::hierarchy_parser
Definition: irods_hierarchy_parser.hpp:14
irods::data_object
Definition: irods_data_object.hpp:22
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
irods::collection_object::resolve
virtual error resolve(const std::string &, plugin_ptr &)
Definition: irods_collection_object.cpp:118
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods::data_object::operator=
virtual data_object & operator=(const data_object &)
Definition: irods_data_object.cpp:122
irods::hierarchy_parser::first_resc
error first_resc(std::string &_ret_resc) const
Definition: irods_hierarchy_parser.cpp:96
irods
Definition: apiHandler.hpp:35
irods::RESOURCE_INTERFACE
const std::string RESOURCE_INTERFACE("irods_resource_interface")
irods::data_object::resc_hier
virtual std::string resc_hier() const
Definition: irods_data_object.hpp:77
irods::resource_manager::resolve
error resolve(std::string, resource_ptr &)
Definition: irods_resource_manager.cpp:51
irods::hierarchy_parser::set_string
error set_string(const std::string &_resc_hier)
Definition: irods_hierarchy_parser.cpp:36
irods::collection_object
Definition: irods_collection_object.hpp:14
irods::collection_object::directory_pointer_
DIR * directory_pointer_
Definition: irods_collection_object.hpp:79
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
HIERARCHY_ERROR
@ HIERARCHY_ERROR
Definition: rodsErrorTable.h:752
irods::collection_object::collection_object
collection_object()
Definition: irods_collection_object.cpp:13
irods_hierarchy_parser.hpp
irods::data_object::get_re_vars
virtual error get_re_vars(rule_engine_vars_t &)
Definition: irods_data_object.cpp:137
irods_resource_manager.hpp
irods::resource_manager
Definition: irods_resource_manager.hpp:30
irods::collection_object::get_re_vars
virtual error get_re_vars(rule_engine_vars_t &)
Definition: irods_collection_object.cpp:182
KeyValPair
Definition: objInfo.h:120
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods::collection_object::~collection_object
virtual ~collection_object()
Definition: irods_collection_object.cpp:99
irods::rule_engine_vars_t
std::map< std::string, std::string > rule_engine_vars_t
Definition: irods_first_class_object.hpp:20
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32