Class: NWRFC::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/nwrfc.rb,
lib/nwrfc.old.rb

Overview

Represents a remote-enabled function module for RFC, can be instantiated either by the caller or by calling Connection#get_function. This only represents the description of the function; to call a function, an instance of a function call must be obtained with #get_function_call


FIXME: We are using a shared error object in the connection, so what happens in a multi-threaded situation? Functions should each have their own error handle +++

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, func_name) ⇒ Function

Get a function module instance; can also be obtained by calling Connection#get_function



99
100
101
102
103
104
105
# File 'lib/nwrfc.rb', line 99

def initialize(connection, function_name)
  @function_name = function_name
  @error =  NWRFCLib::RFCError.new
  @desc = NWRFCLib.get_function_desc(connection.handle, function_name.cU, @error.to_ptr)
  @connection = connection
  NWRFC.check_error(@error)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *args, &block) ⇒ Object

Look up parameter by method name given, returns parameter instance if it refers to a valid parameter



233
234
235
236
237
238
239
# File 'lib/nwrfc.old.rb', line 233

def method_missing(method_sym, *args, &block)
  param_name = method_sym.to_s.upcase
  fpar = NWRFCLib::RFCFuncParam.new
  rc = NWRFCLib.get_parameter_desc_by_name(@func_desc, param_name.cU, fpar.to_ptr, @error.to_ptr)
  NWRFC.check_error(@error) if rc > 0
  parameter_to_hash(fpar)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



96
97
98
# File 'lib/nwrfc.rb', line 96

def connection
  @connection
end

#descObject (readonly)

Returns the value of attribute desc.



96
97
98
# File 'lib/nwrfc.rb', line 96

def desc
  @desc
end

#func_descObject (readonly)

Returns the value of attribute func_desc.



198
199
200
# File 'lib/nwrfc.old.rb', line 198

def func_desc
  @func_desc
end

#function_nameObject (readonly)

Returns the value of attribute function_name.



96
97
98
# File 'lib/nwrfc.rb', line 96

def function_name
  @function_name
end

#membersObject (readonly)

Returns the value of attribute members.



198
199
200
# File 'lib/nwrfc.old.rb', line 198

def members
  @members
end

Instance Method Details

#[](param) ⇒ Object



227
228
229
# File 'lib/nwrfc.old.rb', line 227

def [](param)
  (param)
end

#get_function_callObject

Create and return a callable instance of this function module



108
109
110
# File 'lib/nwrfc.rb', line 108

def get_function_call
  FunctionCall.new(self)
end

#member_metadata(param) ⇒ Object



241
242
243
244
245
246
247
# File 'lib/nwrfc.old.rb', line 241

def (param)
  param_name = param.to_s.upcase
  fpar = NWRFCLib::RFCFuncParam.new
  rc = NWRFCLib.get_parameter_desc_by_name(@func_desc, param_name.cU, fpar.to_ptr, @error.to_ptr)
  NWRFC.check_error(@error) if rc > 0
  parameter_to_hash(fpar)
end

#parameter_countObject

Get the number of parameters this function has



113
114
115
116
117
118
# File 'lib/nwrfc.rb', line 113

def parameter_count
  pcount = FFI::MemoryPointer.new(:uint)
  rc = NWRFCLib.get_parameter_count(@desc, pcount, @error)
  NWRFC.check_error(@error) if rc > 0
  pcount.read_uint
end

#parametersObject

Returns the definitions of parameters associated with this function module (lazy loading)



223
224
225
# File 'lib/nwrfc.old.rb', line 223

def parameters
  @members
end