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_data_object.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
2 #include "irods_data_object.hpp"
4 
6 
7 namespace irods {
8 
9 // =-=-=-=-=-=-=-
10 // public - ctor
12  physical_path_( "" ),
13  resc_hier_( "" ),
14  id_( 0 ),
15  mode_( 0 ),
16  flags_( 0 ),
17  resc_id_(0) {
18  memset( &cond_input_, 0, sizeof( keyValPair_t ) );
19  } // ctor
20 
21 // =-=-=-=-=-=-=-
22 // public - ctor
24  const std::string& _phy_path,
25  rodsLong_t _resc_id,
26  int _mode,
27  int _flags ) :
28  physical_path_( _phy_path ),
29  id_( 0 ),
30  mode_( _mode ),
31  flags_( _flags ),
32  resc_id_( _resc_id ) {
33  memset( &cond_input_, 0, sizeof( keyValPair_t ) );
34 
35  std::string resc_hier;
38  } // ctor
39 
40 // =-=-=-=-=-=-=-
41 // public - ctor
43  const std::string& _phy_path,
44  rodsLong_t _resc_id,
45  int _mode,
46  int _flags,
47  const keyValPair_t& _cond_input ) :
48  physical_path_( _phy_path ),
49  id_( 0 ),
50  mode_( _mode ),
51  flags_( _flags ),
52  resc_id_( _resc_id ) {
53  replKeyVal( &_cond_input, &cond_input_ );
54 
55  std::string resc_hier;
58  } // ctor
59 
60 // =-=-=-=-=-=-=-
61 // public - ctor
63  const std::string& _phy_path,
64  const std::string& _resc_hier,
65  int _mode,
66  int _flags ) :
67  physical_path_( _phy_path ),
68  resc_hier_( _resc_hier ),
69  id_( 0 ),
70  mode_( _mode ),
71  flags_( _flags ) {
72  memset( &cond_input_, 0, sizeof( keyValPair_t ) );
73 
76  resc_id_ = resc_id;
77  } // ctor
78 
79 // =-=-=-=-=-=-=-
80 // public - ctor
82  const std::string& _phy_path,
83  const std::string& _resc_hier,
84  int _mode,
85  int _flags,
86  const keyValPair_t& _cond_input ) :
87  physical_path_( _phy_path ),
88  resc_hier_( _resc_hier ),
89  id_( 0 ),
90  mode_( _mode ),
91  flags_( _flags ) {
92  replKeyVal( &_cond_input, &cond_input_ );
93 
96  resc_id_ = resc_id;
97  } // ctor
98 
99 
100 // =-=-=-=-=-=-=-
101 // public - cctor
103  const data_object& _rhs ) :
104  first_class_object( _rhs ),
105  physical_path_( _rhs.physical_path_ ),
106  resc_hier_( _rhs.resc_hier_ ),
107  id_( _rhs.id_ ),
108  mode_( _rhs.mode_ ),
109  flags_( _rhs.flags_ ),
110  resc_id_( _rhs.resc_id_ ) {
112  } // cctor
113 
114 // =-=-=-=-=-=-=-
115 // public - dtor
118  } // dtor
119 
120 // =-=-=-=-=-=-=-
121 // public - assignment operator
123  const data_object& _rhs ) {
125  resc_hier_ = _rhs.resc_hier_;
126  resc_id_ = _rhs.resc_id_;
127  id_ = _rhs.id_;
128  mode_ = _rhs.mode_;
129  flags_ = _rhs.flags_;
131 
132  return *this;
133  } // operator=
134 
135 // =-=-=-=-=-=-=-
136 // public - copy attributes to irods kvp
138  rule_engine_vars_t& _kvp ) {
139 
140  _kvp[PHYSICAL_PATH_KW] = physical_path_.c_str();
141  _kvp[RESC_HIER_STR_KW] = resc_hier_.c_str();
142 
143  std::stringstream id_str;
144  id_str << id_;
145  _kvp[DATA_ID_KW] = id_str.str().c_str();
146 
147  std::stringstream mode_str;
148  mode_str << mode_;
149  _kvp[MODE_KW] = mode_str.str().c_str();
150 
151  std::stringstream flags_str;
152  flags_str << flags_;
153  _kvp[FLAGS_KW] = flags_str.str().c_str();
154 
155  // copy contents of cond_input
156  if(cond_input_.len > 0) {
157  for(int i = 0; i < cond_input_.len; ++i) {
159  if(cond_input_.value && cond_input_.value[i]) {
160  _kvp[cond_input_.keyWord[i]] = cond_input_.value[i];
161  }
162  else {
163  _kvp[cond_input_.keyWord[i]] = "empty_value";
164  }
165  }
166  } // for
167  } // if
168  return SUCCESS();
169 
170  } // get_re_vars
171 
173  data_object_ptr& _do,
174  const std::string& _k,
175  const std::string& _v ) {
176  addKeyVal(
177  &_do->cond_input_,
178  ( char* )_k.c_str(),
179  ( char* )_v.c_str() );
180  }
181 
183  data_object_ptr& _do,
184  const std::string& _k ) {
185  rmKeyVal(
186  &_do->cond_input_,
187  ( char* )_k.c_str() );
188 
189  }
190 }; // namespace irods
irods::data_object::cond_input_
keyValPair_t cond_input_
Definition: irods_data_object.hpp:140
irods::data_object::id_
long id_
Definition: irods_data_object.hpp:137
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
irods::data_object::flags_
int flags_
Definition: irods_data_object.hpp:139
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
irods::data_object_ptr
boost::shared_ptr< data_object > data_object_ptr
Definition: irods_data_object.hpp:17
irods_data_object.hpp
FLAGS_KW
#define FLAGS_KW
Definition: rodsKeyWdDef.h:249
irods::data_object::resc_id
virtual rodsLong_t resc_id() const
Definition: irods_data_object.hpp:92
irods::data_object
Definition: irods_data_object.hpp:22
irods::data_object::physical_path_
std::string physical_path_
Definition: irods_data_object.hpp:135
KeyValPair::value
char ** value
Definition: objInfo.h:123
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
MODE_KW
#define MODE_KW
Definition: rodsKeyWdDef.h:248
DATA_ID_KW
#define DATA_ID_KW
Definition: rodsKeyWdDef.h:48
RESC_HIER_STR_KW
#define RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:225
irods
Definition: apiHandler.hpp:35
irods::data_object::mode_
int mode_
Definition: irods_data_object.hpp:138
PHYSICAL_PATH_KW
#define PHYSICAL_PATH_KW
Definition: rodsKeyWdDef.h:247
KeyValPair::keyWord
char ** keyWord
Definition: objInfo.h:122
irods::data_object::resc_hier
virtual std::string resc_hier() const
Definition: irods_data_object.hpp:77
rmKeyVal
int rmKeyVal(keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:710
irods::data_object::~data_object
virtual ~data_object()
Definition: irods_data_object.cpp:116
irods::error
Definition: irods_error.hpp:23
irods::data_object::data_object
data_object()
Definition: irods_data_object.cpp:11
irods::add_key_val
void add_key_val(data_object_ptr &_do, const std::string &_k, const std::string &_v)
Definition: irods_data_object.cpp:172
irods::resource_manager::leaf_id_to_hier
error leaf_id_to_hier(const rodsLong_t &, std::string &)
Definition: irods_resource_manager.cpp:1119
irods::data_object::get_re_vars
virtual error get_re_vars(rule_engine_vars_t &)
Definition: irods_data_object.cpp:137
irods::resource_manager::hier_to_leaf_id
error hier_to_leaf_id(const std::string &, rodsLong_t &)
Definition: irods_resource_manager.cpp:1082
irods::first_class_object
Definition: irods_first_class_object.hpp:23
KeyValPair::len
int len
Definition: objInfo.h:121
irods_resource_manager.hpp
irods::resource_manager
Definition: irods_resource_manager.hpp:30
irods::data_object::resc_hier_
std::string resc_hier_
Definition: irods_data_object.hpp:136
irods::data_object::resc_id_
rodsLong_t resc_id_
Definition: irods_data_object.hpp:141
irods::remove_key_val
void remove_key_val(data_object_ptr &_do, const std::string &_k)
Definition: irods_data_object.cpp:182
KeyValPair
Definition: objInfo.h:120
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
replKeyVal
int replKeyVal(const keyValPair_t *srcCondInput, keyValPair_t *destCondInput)
Definition: rcMisc.cpp:739
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