Module: RRT_RUBY::RRTComponent::ComponentFinderModule

Included in:
ComponentFinder, RRT_RUBY::RRTFinder
Defined in:
lib/rrt_ruby/rrt_component.rb

Overview

Adds functionality for querying component view elements.

Instance Method Summary collapse

Instance Method Details

#component_names(root_package) ⇒ Object

Delivers all fully qualified component names under the defined package. If the parameter does not correspond to a component view package it will return an empty array



81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rrt_ruby/rrt_component.rb', line 81

def component_names root_package
	components=Array.new
	#first of all find the package in the model
	pkg= find_component_package(root_package,debug)
	begin 
		comps=pkg.GetAllComponents
		@logger.debug("There are #{comps.Count} components under #{pkg.GetQualifiedName}")
		cnt=comps.Count
		1.upto(cnt){|i|
			components<<comps.GetAt(i).GetQualifiedName
		}
	end if pkg
	return components
end

#components(root_package) ⇒ Object

Returns all components in the given package



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/rrt_ruby/rrt_component.rb', line 96

def components root_package
	components=Array.new
	#first of all find the package in the model
	pkg= find_component_package(root_package,debug)
	begin 
		comps=pkg.GetAllComponents
		@logger.debug("There are #{comps.Count} components under #{pkg.GetQualifiedName}")
		cnt=comps.Count
		1.upto(cnt){|i|
			components<<Component.new(comps.GetAt(i))
		}
	end if pkg
	return components
end

#executables(root_package) ⇒ Object

Returns all executables in the given package



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/rrt_ruby/rrt_component.rb', line 111

def executables root_package
	components=Array.new
	#first of all find the package in the model
	pkg= find_component_package(root_package,debug)
	begin 
		comps=pkg.GetAllComponents
		@logger.debug("There are #{comps.Count} components under #{pkg.GetQualifiedName}")
		cnt=comps.Count
		1.upto(cnt){|i|
			comp=comps.GetAt(i)
			components<<Executable.new(comp) if comp.Type=~/Executable/
		}
	end if pkg
	return components
end

#external_libraries(root_package) ⇒ Object

Returns all external libraries in the given package and it’s subpackages



144
145
146
147
148
149
# File 'lib/rrt_ruby/rrt_component.rb', line 144

def external_libraries root_package
	comps=components(root_package,debug)
	return comps.collect{|c|
		c if c.type=~/External/
	}.compact
end

#find_component_package(package_name, debug = false) ⇒ Object

This will return the first component package matching the name, nil if no component package is found.

If no fully qualified name is provided, then the first match is returned



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/rrt_ruby/rrt_component.rb', line 153

def find_component_package package_name,debug=false
	#get the simple package name
	splitted=package_name.split("::")
	simple_name=splitted[splitted.size-1] unless splitted.size==0
	#get a collection with all the packages with the same name
	col=@model.FindModelElements(simple_name)
	count=col.Count
	@logger.debug("There are #{count} packages named #{simple_name}")
	1.upto(count){|i|
		obj=col.GetAt(i)
		#match the first if no qualified name is given
		return obj if package_name==simple_name&&obj.Name==simple_name && obj.IsClass("ComponentPackage")
		#match the qualified name
		return obj if obj.GetQualifiedName==package_name && obj.IsClass("ComponentPackage")
	}
	return nil
end

#libraries(root_package) ⇒ Object

returns all libraries in the given package and it’s subpackages



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/rrt_ruby/rrt_component.rb', line 127

def libraries root_package
	components=Array.new
	#first of all find the package in the model
	pkg= find_component_package(root_package,debug)
	begin 
		comps=pkg.GetAllComponents
		@logger.debug("There are #{comps.Count} components under #{pkg.GetQualifiedName}")
		cnt=comps.Count
		1.upto(cnt){|i|
			comp=comps.GetAt(i)
			type=comp.Type
			components<<Library.new(comp) if type=~/Library/ && !(type=~/External/)
		}
	end if pkg
	return components
end