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_plugin_context.hpp
Go to the documentation of this file.
1 #ifndef __IRODS_PLUGIN_CONTEXT_HPP__
2 #define __IRODS_PLUGIN_CONTEXT_HPP__
3 
4 // =-=-=-=-=-=-=-
5 // stl includes
6 #include <string>
7 #include <boost/pointer_cast.hpp>
8 
9 // =-=-=-=-=-=-=-
10 #include "rodsErrorTable.h"
11 #include "irods_lookup_table.hpp"
13 
14 namespace irods {
15 
16 // =-=-=-=-=-=-=-
17 // base context class for communicating to plugins
19  public:
20  // =-=-=-=-=-=-=-
21  // ctor
23  irods::plugin_property_map& _prop_map,
25  const std::string& _results ) :
26  comm_( nullptr ),
27  prop_map_( &_prop_map ),
28  fco_( _fco ),
29  results_( _results ) {
30 
31  } // ctor
32 
33  // =-=-=-=-=-=-=-
34  // ctor
36  rsComm_t* _comm,
37  irods::plugin_property_map& _prop_map,
39  const std::string& _results ) :
40  comm_( _comm ),
41  prop_map_( &_prop_map ),
42  fco_( _fco ),
43  results_( _results ) {
44 
45  } // ctor
46 
47  // =-=-=-=-=-=-=-
48  // ctor
50  swap(*this, other);
51  return *this;
52  }
53 
55  rsComm_t* _comm,
56  irods::plugin_property_map& _prop_map ) :
57  comm_( _comm ),
58  prop_map_( &_prop_map ) {
59  }
60 
61  friend void swap(plugin_context& first, plugin_context& second) // nothrow
62  {
63  std::swap(first.comm_, second.comm_);
64  std::swap(first.fco_, second.fco_);
65  std::swap(first.prop_map_, second.prop_map_);
66  std::swap(first.results_, second.results_);
67  }
68 
69  // =-=-=-=-=-=-=-
70  // dtor
71  virtual ~plugin_context() {
72 
73  } // dtor
74 
75  // =-=-=-=-=-=-=-
76  // test to determine if contents are valid
77  virtual error valid() {
78  return SUCCESS();
79 
80  } // valid
81 
82  // =-=-=-=-=-=-=-
83  // test to determine if contents are valid
84  template < typename OBJ_TYPE >
86  // trap case of incorrect type for first class object
87  return boost::dynamic_pointer_cast< OBJ_TYPE >( fco_.get() ) == NULL ?
88  ERROR( INVALID_DYNAMIC_CAST, "invalid type for fco cast" ) :
89  valid();
90 
91  } // valid
92 
93  // =-=-=-=-=-=-=-
94  // accessors
95  virtual rsComm_t* comm() {
96  return comm_;
97  }
98 
100  return *prop_map_;
101  }
103  return fco_;
104  }
105  virtual const std::string rule_results() {
106  return results_;
107  }
108 
109  // =-=-=-=-=-=-=-
110  // mutators
111  virtual void comm( rsComm_t* _c ) {
112  comm_ = _c;
113  }
114 
115  virtual void rule_results( const std::string& _s ) {
116  results_ = _s;
117  }
118 
119  protected:
120  // =-=-=-=-=-=-=-
121  // attributes
122  rsComm_t* comm_; // server connection handle
123  irods::plugin_property_map* prop_map_; // resource property map
124  first_class_object_ptr fco_; // first class object in question
125  std::string results_; // results from the pre op rule call
126 
127  }; // class plugin_context
128 
131  typedef error( *plugin_operation )( plugin_context&, ... );
132 
133 }; // namespace irods
134 
135 #endif // __IRODS_PLUGIN_CONTEXT_HPP__
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
irods::lookup_table< boost::any >
irods::plugin_context::comm
virtual void comm(rsComm_t *_c)
Definition: irods_plugin_context.hpp:111
irods::plugin_context::valid
virtual error valid()
Definition: irods_plugin_context.hpp:77
INVALID_DYNAMIC_CAST
@ INVALID_DYNAMIC_CAST
Definition: rodsErrorTable.h:766
irods::plugin_context::fco_
first_class_object_ptr fco_
Definition: irods_plugin_context.hpp:124
irods::plugin_context::~plugin_context
virtual ~plugin_context()
Definition: irods_plugin_context.hpp:71
irods::plugin_context::operator=
plugin_context & operator=(plugin_context other)
Definition: irods_plugin_context.hpp:49
irods::plugin_context
Definition: irods_plugin_context.hpp:18
irods::plugin_context::comm_
rsComm_t * comm_
Definition: irods_plugin_context.hpp:122
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
irods::plugin_context::comm
virtual rsComm_t * comm()
Definition: irods_plugin_context.hpp:95
irods::first_class_object_ptr
boost::shared_ptr< first_class_object > first_class_object_ptr
Definition: irods_first_class_object.hpp:47
irods::plugin_context::prop_map
virtual irods::plugin_property_map & prop_map()
Definition: irods_plugin_context.hpp:99
irods
Definition: apiHandler.hpp:35
irods::plugin_context::swap
friend void swap(plugin_context &first, plugin_context &second)
Definition: irods_plugin_context.hpp:61
irods::plugin_context::plugin_context
plugin_context(rsComm_t *_comm, irods::plugin_property_map &_prop_map)
Definition: irods_plugin_context.hpp:54
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::plugin_context::results_
std::string results_
Definition: irods_plugin_context.hpp:125
irods::error
Definition: irods_error.hpp:23
irods_first_class_object.hpp
irods::plugin_context::rule_results
virtual const std::string rule_results()
Definition: irods_plugin_context.hpp:105
error
int error
Definition: filesystem.cpp:101
irods::plugin_context::fco
virtual first_class_object_ptr fco()
Definition: irods_plugin_context.hpp:102
irods::plugin_context::valid
error valid()
Definition: irods_plugin_context.hpp:85
irods::plugin_context::prop_map_
irods::plugin_property_map * prop_map_
Definition: irods_plugin_context.hpp:123
irods::experimental::filesystem::swap
auto swap(path &_lhs, path &_rhs) noexcept -> void
Definition: path.hpp:382
rodsErrorTable.h
irods::plugin_operation
error(* plugin_operation)(plugin_context &,...)
Definition: irods_plugin_context.hpp:131
irods::plugin_context::plugin_context
plugin_context(rsComm_t *_comm, irods::plugin_property_map &_prop_map, first_class_object_ptr _fco, const std::string &_results)
Definition: irods_plugin_context.hpp:35
irods::plugin_context::plugin_context
plugin_context(irods::plugin_property_map &_prop_map, first_class_object_ptr _fco, const std::string &_results)
Definition: irods_plugin_context.hpp:22
irods_lookup_table.hpp
irods::plugin_context::rule_results
virtual void rule_results(const std::string &_s)
Definition: irods_plugin_context.hpp:115