Class: Roby::Transactions::Task

Inherits:
Roby::Task show all
Includes:
Proxy
Defined in:
lib/roby/transactions/proxy.rb

Overview

Transaction proxy for Roby::Task

Direct Known Subclasses

PlanningTask::TransactionProxy

Constant Summary

Constants included from Log::TaskHooks

Log::TaskHooks::HOOKS

Constants included from Log::BasicObjectHooks

Log::BasicObjectHooks::HOOKS

Instance Attribute Summary

Attributes included from Proxy

#__getobj__, #transaction

Attributes inherited from PlanObject

#executable, #plan, #removed_at

Attributes inherited from BasicObject

#distribute

Instance Method Summary collapse

Methods included from Proxy

forwarder, #partition_new_old_relations, #pretty_print, proxy_class, proxy_for, #proxying?, #to_s

Methods inherited from Roby::Task

#_dump, _load, #droby_dump, improves, #improves?, improves?, match, needs, #needs?, needs?

Methods included from Roby::TaskStructure::ModelConflicts

#conflicts_with, #conflicts_with?

Methods included from Distributed::DRobyTaskModel::Dump

#droby_dump

Methods included from Distributed::DRobyModel::Dump

#droby_dump

Methods included from Distributed::TaskNotifications

#updated_data

Methods included from Roby::TaskOperations

#+, #|

Methods included from Log::TaskHooks

#added_child_object, #removed_child_object

Methods inherited from PlanObject

#add_child_object, #apply_relation_changes, child_plan_object, #finalized?, #forget_peer, #read_write?, #remotely_useful?, #removing_child_object, #replace_by, #replace_subplan_by, #root_object, #root_object?, #subscribed?, #update_on?, #updated_by?

Methods included from Distributed::RelationModificationHooks

#added_child_object, #removed_child_object

Methods included from PlanObjectUpdates

#adding_child_object, #removing_child_object

Methods included from DirectedRelationSupport

#add_child_object, #add_parent_object, #check_is_relation, #related_objects, #relations, #remove_child_object, #remove_children, #remove_parent_object, #remove_parents, #remove_relations

Methods inherited from BasicObject

#add_sibling_for, #distribute?, distribute?, #finalized?, #forget_peer, #has_sibling_on?, #initialize_copy, local_only, #read_write?, #remotely_useful?, #remove_sibling_for, #self_owned?, #sibling_of, #sibling_on, #subscribe, #subscribed?, #update_on?, #updated?, #updated_by?, #updated_peers

Methods included from Log::BasicObjectHooks

#added_owner, #removed_owner

Constructor Details

#initialize(object, transaction) ⇒ Task

Create a new proxy representing object in transaction



221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/roby/transactions/proxy.rb', line 221

def initialize(object, transaction)
    super(object, transaction)

    @arguments = Roby::TaskArguments.new(self)
    object.arguments.each do |key, value|
  if value.kind_of?(Roby::PlanObject)
      arguments.update!(key, transaction[value])
  else
      arguments.update!(key, value)
  end
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

:nodoc:



273
274
275
276
277
278
279
280
281
# File 'lib/roby/transactions/proxy.rb', line 273

def method_missing(m, *args, &block) # :nodoc:
    if m.to_s =~ /^(\w+)!$/ && has_event?($1.to_sym)
  event($1.to_sym).call(*args)
    elsif !Roby::Task.method_defined?(m)
  __getobj__.send(m, *args, &block)
    else
  super
    end
end

Instance Method Details

#bound_eventsObject

There is no bound_events map in task proxies. The proxy instead enumerates the real task’s events and create proxies when needed.

#bound_events is not part of the public API anyways



238
# File 'lib/roby/transactions/proxy.rb', line 238

def bound_events; {} end

#commit_transactionObject

Perform the operations needed for the commit to be successful. In practice, it updates the task arguments as needed.



257
258
259
260
261
262
263
264
265
266
# File 'lib/roby/transactions/proxy.rb', line 257

def commit_transaction
    super
    
    # Update the task arguments. The original
    # Roby::Task#commit_transaction has already translated the proxy
    # objects into real objects
    arguments.each do |key, value|
  __getobj__.arguments.update!(key, value)
    end
end

#discard_transactionObject

Perform the operations needed for the transaction to be discarded.



269
270
271
# File 'lib/roby/transactions/proxy.rb', line 269

def discard_transaction
    clear_relations
end

#executable?Boolean

Transaction proxies are never executable



244
# File 'lib/roby/transactions/proxy.rb', line 244

def executable?; false end

#has_sibling?(peer) ⇒ Boolean

True if peer has a representation of this object



287
288
289
# File 'lib/roby/transactions/proxy.rb', line 287

def has_sibling?(peer)
    plan.has_sibling?(peer)
end

#historyObject

Transaction proxies do not have history



247
# File 'lib/roby/transactions/proxy.rb', line 247

def history; "" end

#instantiate_model_event_relationsObject

:nodoc:



240
241
# File 'lib/roby/transactions/proxy.rb', line 240

def instantiate_model_event_relations # :nodoc:
end

#plan=(new_plan) ⇒ Object

:nodoc:



248
249
250
251
252
253
# File 'lib/roby/transactions/proxy.rb', line 248

def plan=(new_plan) # :nodoc:
    if new_plan && new_plan.plan != __getobj__.plan
  raise "invalid plan #{new_plan}"
    end
    @plan = new_plan
end