Class: Roby::DRoby::V5::DRobyModel
- Inherits:
-
Object
- Object
- Roby::DRoby::V5::DRobyModel
show all
- Defined in:
- lib/roby/droby/v5/droby_model.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, remote_siblings, supermodel, provided_models) ⇒ DRobyModel
Returns a new instance of DRobyModel.
9
10
11
12
|
# File 'lib/roby/droby/v5/droby_model.rb', line 9
def initialize(name, remote_siblings, supermodel, provided_models)
@name, @remote_siblings, @supermodel, @provided_models =
name, remote_siblings, supermodel, provided_models
end
|
Instance Attribute Details
Returns the value of attribute name.
7
8
9
|
# File 'lib/roby/droby/v5/droby_model.rb', line 7
def name
@name
end
|
#provided_models ⇒ Object
Returns the value of attribute provided_models.
7
8
9
|
# File 'lib/roby/droby/v5/droby_model.rb', line 7
def provided_models
@provided_models
end
|
#remote_siblings ⇒ Object
Returns the value of attribute remote_siblings.
7
8
9
|
# File 'lib/roby/droby/v5/droby_model.rb', line 7
def remote_siblings
@remote_siblings
end
|
#supermodel ⇒ Object
Returns the value of attribute supermodel.
7
8
9
|
# File 'lib/roby/droby/v5/droby_model.rb', line 7
def supermodel
@supermodel
end
|
Class Method Details
.dump_provided_models_of(peer, model) ⇒ Object
57
58
59
60
61
|
# File 'lib/roby/droby/v5/droby_model.rb', line 57
def self.dump_provided_models_of(peer, model)
provided_models_of(model).map do |m|
peer.dump_model(m)
end
end
|
.dump_supermodel(peer, model) ⇒ Object
52
53
54
55
|
# File 'lib/roby/droby/v5/droby_model.rb', line 52
def self.dump_supermodel(peer, model)
s = model.supermodel
peer.dump_model(s) if s.kind_of?(ModelDumper)
end
|
.provided_models_of(model) ⇒ Object
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/roby/droby/v5/droby_model.rb', line 63
def self.provided_models_of(model)
super_m = model.supermodel
provided_m = []
model.ancestors.each do |m|
break if m == super_m
provided_m << m if (m != model) && m.kind_of?(ModelDumper)
end
provided_m
end
|
Instance Method Details
#create_new_proxy_model(peer) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/roby/droby/v5/droby_model.rb', line 28
def create_new_proxy_model(peer)
local_model =
@unmarshalled_supermodel
.new_submodel(name: name || "#{@unmarshalled_supermodel.name}#")
peer.register_model(local_model, remote_siblings)
local_model
end
|
#proxy(peer) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/roby/droby/v5/droby_model.rb', line 14
def proxy(peer)
unmarshal_dependent_models(peer)
if (local_m = peer.find_local_model(self))
local_m
elsif !supermodel
raise NoLocalObject,
"#{name}, at the root of a model hierarchy, was expected "\
"to be explicitely registered but is not"
else
create_new_proxy_model(peer)
end
end
|
#unmarshal_dependent_models(peer) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/roby/droby/v5/droby_model.rb', line 36
def unmarshal_dependent_models(peer)
@unmarshalled_supermodel = peer.local_model(supermodel) if supermodel
@unmarshalled_provided_models =
@provided_models.map { |m| peer.local_model(m) }
end
|
#update(peer, local_object, fresh_proxy: false) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/roby/droby/v5/droby_model.rb', line 44
def update(peer, local_object, fresh_proxy: false)
@unmarshalled_provided_models ||=
@provided_models.map { |m| peer.local_model(m) }
@unmarshalled_provided_models.each do |local_m|
local_object.provides(local_m) unless local_object <= local_m
end
end
|