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_plugin.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
2 // My Includes
4 #include "irods_load_plugin.hpp"
5 
6 // =-=-=-=-=-=-=-
7 // STL Includes
8 #include <iostream>
9 #include <sstream>
10 #include <algorithm>
11 #include <vector>
12 
13 // =-=-=-=-=-=-=-
14 // dlopen, etc
15 #include <dlfcn.h>
16 
17 namespace irods {
18 
20  const std::string& _name,
21  const std::string& _data,
22  resource_ptr _resc ) {
23  // =-=-=-=-=-=-=-
24  // check params
25  if ( _name.empty() ) {
26  return ERROR(
28  "empty name" );
29  }
30 
31  if ( 0 == _resc.get() ) {
32  return ERROR(
34  "null resource pointer" );
35  }
36 
37  // =-=-=-=-=-=-=-
38  // add resource and data to the table
39  children_[ _name ] = std::make_pair( _data, _resc );
40 
41  return SUCCESS();
42 
43  } // add_child
44 
45  error resource::remove_child( const std::string& _name ) {
46  // =-=-=-=-=-=-=-
47  // if an entry exists, erase it otherwise issue a warning.
48  if ( children_.has_entry( _name ) ) {
49  children_.erase( _name );
50  return SUCCESS();
51  }
52  else {
53  std::stringstream msg;
54  msg << "resource has no child named [" << _name << "]";
55  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
56  }
57 
58  } // remove_child
59 
61  parent_ = _resc;
62  return SUCCESS();
63 
64  } // set_parent
65 
67  _resc = parent_;
68  if ( _resc.get() ) {
69  return SUCCESS();
70  }
71  else {
72  return ERROR(
74  "null parent pointer" );
75  }
76 
77  } // get_parent
78 
80  std::vector<std::string>& _out ) {
81  for( auto c_itr : children_ ) {
82  _out.push_back( c_itr.first );
83  }
84  } // children
85 
86 }; // namespace irods
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
irods::resource::remove_child
virtual error remove_child(const std::string &)
Definition: irods_resource_plugin.cpp:45
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
irods::resource::get_parent
virtual error get_parent(resource_ptr &)
Definition: irods_resource_plugin.cpp:66
irods::lookup_table::erase
size_t erase(KeyType _k)
Definition: irods_lookup_table.hpp:44
irods::resource::set_parent
virtual error set_parent(const resource_ptr &)
Definition: irods_resource_plugin.cpp:60
irods_resource_plugin.hpp
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods
Definition: apiHandler.hpp:35
irods_load_plugin.hpp
irods::lookup_table::has_entry
bool has_entry(KeyType _k) const
Definition: irods_lookup_table.hpp:41
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
irods::resource::children_
resource_child_map children_
Definition: irods_resource_plugin.hpp:89
irods::resource::add_child
virtual error add_child(const std::string &, const std::string &, resource_ptr)
Definition: irods_resource_plugin.cpp:19
irods::resource::parent_
resource_ptr parent_
Definition: irods_resource_plugin.hpp:90
irods::resource::children
virtual void children(std::vector< std::string > &)
Definition: irods_resource_plugin.cpp:79