Module: Syskit::Models::Placeholder Private

Extended by:
Creation
Includes:
MetaRuby::DSLs::FindThroughMethodMissing
Defined in:
lib/syskit/models/placeholder.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Base implementation of the creation of models that represent an arbitrary mix of a task model and a set of data services.

Its most common usage it to represent a single data service (which is seen as a Component model with an extra data service). It can also be used to represent a taskcontext model that should have an extra data service at dependency-injection time because of e.g. dynamic service instantiation.

Defined Under Namespace

Modules: Creation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Creation

create_for, for, new_specialized_placeholder, resolve_models_argument, task_extension

Instance Attribute Details

#proxied_component_modelObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The base component model that is being proxied



16
17
18
# File 'lib/syskit/models/placeholder.rb', line 16

def proxied_component_model
  @proxied_component_model
end

#proxied_data_service_modelsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The list of data services that are being proxied



14
15
16
# File 'lib/syskit/models/placeholder.rb', line 14

def proxied_data_service_models
  @proxied_data_service_models
end

Instance Method Details

#component_model?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Whether this proxies only services or not

Returns:

  • (Boolean)


27
28
29
# File 'lib/syskit/models/placeholder.rb', line 27

def component_model?
    proxied_component_model != Syskit::Component
end

#each_fullfilled_model(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
# File 'lib/syskit/models/placeholder.rb', line 22

def each_fullfilled_model(&block)
    fullfilled_model.each(&block)
end

#each_input_portObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



94
95
96
97
98
99
100
# File 'lib/syskit/models/placeholder.rb', line 94

def each_input_port
    return enum_for(:each_input_port) unless block_given?

    @input_port_models.each_value do |list|
        list.each { |p| yield(p) }
    end
end

#each_output_portObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



86
87
88
89
90
91
92
# File 'lib/syskit/models/placeholder.rb', line 86

def each_output_port
    return enum_for(:each_output_port) unless block_given?

    @output_port_models.each_value do |list|
        list.each { |p| yield(p) }
    end
end

#each_portObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



102
103
104
105
106
# File 'lib/syskit/models/placeholder.rb', line 102

def each_port
    return enum_for(:each_port) if !block_given?
    each_output_port { |p| yield(p) }
    each_input_port { |p| yield(p) }
end

#each_required_modelObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
52
53
54
55
56
57
# File 'lib/syskit/models/placeholder.rb', line 49

def each_required_model
    return enum_for(:each_required_model) if !block_given?
    if component_model?
        yield(proxied_component_model)
    end
    proxied_data_service_models.each do |m|
        yield(m)
    end
end

#find_input_port(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



114
115
116
117
118
# File 'lib/syskit/models/placeholder.rb', line 114

def find_input_port(name)
    if list = @input_port_models[name]
        list.first
    end
end

#find_output_port(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



108
109
110
111
112
# File 'lib/syskit/models/placeholder.rb', line 108

def find_output_port(name)
    if list = @output_port_models[name]
        list.first
    end
end

#find_port(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



120
121
122
# File 'lib/syskit/models/placeholder.rb', line 120

def find_port(name)
    find_output_port(name) || find_input_port(name)
end

#find_through_method_missing(m, args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



152
153
154
155
156
# File 'lib/syskit/models/placeholder.rb', line 152

def find_through_method_missing(m, args)
    MetaRuby::DSLs.find_through_method_missing(
        self, m, args,
        '_port'.freeze => :find_port) || super
end

#fullfilled_modelObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/syskit/models/placeholder.rb', line 31

def fullfilled_model
    result = Set.new
    if component_model?
        proxied_component_model.each_fullfilled_model do |m|
            result << m
        end
    end
    proxied_data_service_models.each do |srv|
        srv.each_fullfilled_model do |m|
            result << m
        end
    end
    unless component_model?
        result << AbstractComponent
    end
    result
end

#has_port?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


124
125
126
127
# File 'lib/syskit/models/placeholder.rb', line 124

def has_port?(name)
    @input_port_models.has_key?(name.to_s) ||
        @output_port_models.has_key?(name.to_s)
end

#has_through_method_missing?(m) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


146
147
148
149
150
# File 'lib/syskit/models/placeholder.rb', line 146

def has_through_method_missing?(m)
    MetaRuby::DSLs.has_through_method_missing?(
        self, m,
        '_port'.freeze => :has_port?) || super
end

#merge(other_model) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/syskit/models/placeholder.rb', line 59

def merge(other_model)
    if other_model.kind_of?(Models::BoundDataService)
        return other_model.merge(self)
    end

    task_model, service_models, other_service_models =
        proxied_component_model, proxied_data_service_models, []
    if other_model.placeholder?
        task_model = task_model.merge(other_model.proxied_component_model)
        other_service_models = other_model.proxied_data_service_models
    else
        task_model = task_model.merge(other_model)
    end

    model_list = Models.merge_model_lists(service_models, other_service_models)

    # Try to keep the type of submodels of Placeholder for as
    # long as possible. We re-create a proxy only when needed
    if self <= task_model && model_list.all? { |m| service_models.include?(m) }
        return self
    elsif other_model <= task_model && model_list.all? { |m| other_service_models.include?(m) }
        return other_model
    end

    Placeholder.for(model_list, component_model: task_model)
end

#placeholder?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


142
143
144
# File 'lib/syskit/models/placeholder.rb', line 142

def placeholder?
    true
end

#to_instance_requirementsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
# File 'lib/syskit/models/placeholder.rb', line 18

def to_instance_requirements
    Syskit::InstanceRequirements.new([self])
end

#update_proxy_mappingsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/syskit/models/placeholder.rb', line 129

def update_proxy_mappings
    @output_port_models = Hash.new
    @input_port_models = Hash.new
    each_required_model do |m|
        m.each_output_port do |port|
            (@output_port_models[port.name] ||= Array.new) << port.attach(self)
        end
        m.each_input_port  do |port|
            (@input_port_models[port.name] ||= Array.new) << port.attach(self)
        end
    end
end