Class: Syskit::RobyApp::LoggingGroup
- Defined in:
- lib/syskit/roby_app/logging_group.rb
Overview
Representation of a group of ports
This is used to configure which ports should or should not be configured. The documentation of LoggingConfiguration provides usage information.
Instance Attribute Summary collapse
-
#deployments ⇒ Set<Models::Deployment>
readonly
Set of deployment models whose ports should match.
-
#name_matchers ⇒ Set<#===>
readonly
Set of objects that can match names.
-
#name_set ⇒ Set<String>
readonly
Set of names that are matched against the deployment (process) name, port name, task name and type name.
-
#ports ⇒ Set<Models::Port>
readonly
Set of port models whose ports should match.
-
#tasks ⇒ Set<Models::TaskContext>
readonly
Set of task models whose ports should match.
-
#types ⇒ Set<Typelib::Type>
readonly
Set of types that should match.
Instance Method Summary collapse
-
#add(object) ⇒ Object
Adds an object to this logging group.
-
#enabled=(flag) ⇒ Object
Controls whether the ports matching this group should be logged (enabled? == true) or not.
-
#enabled? ⇒ Object
Controls whether the ports matching this group should be logged (enabled? == true) or not.
-
#initialize(enabled = true) ⇒ LoggingGroup
constructor
A new instance of LoggingGroup.
-
#matches_deployment?(deployment) ⇒ Boolean
Tests whether the given deployment is matched by this group.
-
#matches_name?(name) ⇒ Boolean
Tests whether the given name is matched by this group.
-
#matches_port?(port) ⇒ Boolean
Tests if this group matches the given port.
-
#matches_task?(task) ⇒ Boolean
Tests whether the given task is matched by this group.
-
#matches_type?(type) ⇒ Boolean
Tests whether the given type is matched by this group.
Constructor Details
#initialize(enabled = true) ⇒ LoggingGroup
Returns a new instance of LoggingGroup
10 11 12 13 14 15 16 17 18 |
# File 'lib/syskit/roby_app/logging_group.rb', line 10 def initialize(enabled = true) @deployments = Set.new @tasks = Set.new @ports = Set.new @types = Set.new @name_set = Set.new @name_matchers = Set.new @enabled = enabled end |
Instance Attribute Details
#deployments ⇒ Set<Models::Deployment> (readonly)
Set of deployment models whose ports should match
31 32 33 |
# File 'lib/syskit/roby_app/logging_group.rb', line 31 def deployments @deployments end |
#name_matchers ⇒ Set<#===> (readonly)
Set of objects that can match names. They are matched against the deployment (process) name, port name, task name and type name
58 59 60 |
# File 'lib/syskit/roby_app/logging_group.rb', line 58 def name_matchers @name_matchers end |
#name_set ⇒ Set<String> (readonly)
Set of names that are matched against the deployment (process) name, port name, task name and type name
52 53 54 |
# File 'lib/syskit/roby_app/logging_group.rb', line 52 def name_set @name_set end |
#ports ⇒ Set<Models::Port> (readonly)
Set of port models whose ports should match
41 42 43 |
# File 'lib/syskit/roby_app/logging_group.rb', line 41 def ports @ports end |
#tasks ⇒ Set<Models::TaskContext> (readonly)
Set of task models whose ports should match
36 37 38 |
# File 'lib/syskit/roby_app/logging_group.rb', line 36 def tasks @tasks end |
#types ⇒ Set<Typelib::Type> (readonly)
Set of types that should match
46 47 48 |
# File 'lib/syskit/roby_app/logging_group.rb', line 46 def types @types end |
Instance Method Details
#add(model) ⇒ Object #add(deployment) ⇒ Object #add(port) ⇒ Object #add(name) ⇒ Object
Adds an object to this logging group
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/syskit/roby_app/logging_group.rb', line 78 def add(object) case object when Class if object < Syskit::TaskContext tasks << object elsif object < Syskit::Deployment deployments << object elsif object < Typelib::Type types << object else raise ArgumentError, "unexpected model type #{object}" end when Models::Port ports << object when String name_set << object else # Verify that the object can match strings begin object === "a test string" rescue Exception => e raise ArgumentError, "expected given object to match strings with #=== but it raised #{e}" end name_matchers << object end end |
#enabled=(flag) ⇒ Object
Controls whether the ports matching this group should be logged (enabled? == true) or not. See Syskit::RobyApp::LoggingConfiguration for the logging behaviour when a port is matched by multiple groups
26 |
# File 'lib/syskit/roby_app/logging_group.rb', line 26 attr_predicate :enabled? , true |
#enabled? ⇒ Object
Controls whether the ports matching this group should be logged (enabled? == true) or not. See Syskit::RobyApp::LoggingConfiguration for the logging behaviour when a port is matched by multiple groups
26 |
# File 'lib/syskit/roby_app/logging_group.rb', line 26 attr_predicate :enabled? , true |
#matches_deployment?(deployment) ⇒ Boolean
Tests whether the given deployment is matched by this group
115 116 117 118 |
# File 'lib/syskit/roby_app/logging_group.rb', line 115 def matches_deployment?(deployment) deployments.include?(deployment.model) || matches_name?(deployment.model.deployment_name) end |
#matches_name?(name) ⇒ Boolean
Tests whether the given name is matched by this group
107 108 109 110 |
# File 'lib/syskit/roby_app/logging_group.rb', line 107 def matches_name?(name) name_set.include?(name) || name_matchers.any? { |m| m === name } end |
#matches_port?(port) ⇒ Boolean
Tests if this group matches the given port
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/syskit/roby_app/logging_group.rb', line 145 def matches_port?(port) if ports.include?(port.model) true elsif ports.any? { |p| p.name == port.name && port.component.model.fullfills?(p.component_model) } true elsif matches_name?(port.name) true elsif matches_task?(port.component) true elsif matches_type?(port.type) true end end |
#matches_task?(task) ⇒ Boolean
Tests whether the given task is matched by this group
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/syskit/roby_app/logging_group.rb', line 129 def matches_task?(task) if tasks.include?(task.model) true elsif tasks.any? { |t| task.model.fullfills?(t) } true elsif matches_name?(task.orocos_name) true elsif (deployment = task.execution_agent) && matches_deployment?(deployment) true end end |
#matches_type?(type) ⇒ Boolean
Tests whether the given type is matched by this group
121 122 123 124 |
# File 'lib/syskit/roby_app/logging_group.rb', line 121 def matches_type?(type) types.include?(type) || matches_name?(type.name) end |