Module: RRT_RUBY::RRTLogical::LogicalFinderModule
- Included in:
- RRT_RUBY::RRTFinder, LogicalFinder
- Defined in:
- lib/rrt_ruby/rrt_logical.rb
Overview
Adds functionlaity for querying component view elements.
Constant Summary collapse
- LOGICAL_PACKAGE =
'LogicalPackage'
Instance Method Summary collapse
-
#capsule_names(root_package, debug = false) ⇒ Object
delivers all fully qualified capsule names under the defined package.
- #find_capsule(capsule_name) ⇒ Object
-
#find_class(name) ⇒ Object
returns the RRTLogical::Class instance of the first class with the provided name.
-
#find_logical_package(package_name, debug = false) ⇒ Object
This will return the first logical view package matching the name or nil if no package is found if no fully qualified name is provided, then the first match is returned.
-
#package_names(root_package, debug = false) ⇒ Object
delivers all fully qualified package names under the defined package.
Instance Method Details
#capsule_names(root_package, debug = false) ⇒ Object
delivers all fully qualified capsule names under the defined package. If the parameter does not correspond to a logical view package it will return an empty array It will not recurse.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/rrt_ruby/rrt_logical.rb', line 220 def capsule_names root_package,debug=false raise RRTGeneric::FinderException.new(@modelname),"This Finder instance is invalid" unless @model capsules=Array.new #first of all find the package in the model pkg= find_logical_package(root_package,debug) begin caps=pkg.capsules @logger.debug("There are #{caps.size} capsules under #{pkg.qualifiedname}") caps.each{|i| capsules<<caps.qualifiedname } end if pkg return capsules end |
#find_capsule(capsule_name) ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/rrt_ruby/rrt_logical.rb', line 278 def find_capsule capsule_name raise RRTGeneric::FinderException.new(@modelname),"This Finder instance is invalid" unless @model #get the simple capsule name splitted=capsule_name.split("::") simple_name=splitted[splitted.size-1] unless splitted.size==0 #find it col=@model.FindModelElements(simple_name) count=col.Count 1.upto(count){|i| it=col.GetAt(i) #match the first if no qualified name is given return Capsule.new(it) if it &&capsule_name==simple_name&&it.Name==capsule_name && it.IsClass("Capsule") #match the qualified name return Capsule.new(it) if it&&it.GetQualifiedName==capsule_name&& it.IsClass("Capsule") } @logger.debug("Capsule #{capsule_name} not found in #{@modelname}") return nil end |
#find_class(name) ⇒ Object
returns the RRTLogical::Class instance of the first class with the provided name. nil if nothing is found
298 299 300 301 302 303 304 305 306 307 |
# File 'lib/rrt_ruby/rrt_logical.rb', line 298 def find_class name raise RRTGeneric::FinderException.new(@modelname) unless @model col=@model.FindModelElements(name) count=col.Count 1.upto(count){|i| it=col.GetAt(i) return Class.new(it) if it && it.Name==name && it.IsClass("Class") } return nil end |
#find_logical_package(package_name, debug = false) ⇒ Object
This will return the first logical view package matching the name or nil if no package is found if no fully qualified name is provided, then the first match is returned
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/rrt_ruby/rrt_logical.rb', line 256 def find_logical_package package_name,debug=false ret=nil raise RRTGeneric::FinderException.new(@modelname),"This Finder instance is invalid" unless @model #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 ret=LogicalPackage.new(obj) if obj&&package_name==simple_name&&obj.Name==simple_name && obj.IsClass(LOGICAL_PACKAGE) #match the qualified name ret=LogicalPackage.new(obj) if obj&&obj.GetQualifiedName==package_name && obj.IsClass(LOGICAL_PACKAGE) } col=nil count=0 return ret end |
#package_names(root_package, debug = false) ⇒ Object
delivers all fully qualified package names under the defined package. If the parameter does not correspond to a logical view package it will return an empty array It will not recurse.
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/rrt_ruby/rrt_logical.rb', line 237 def package_names root_package,debug=false raise RRTGeneric::FinderException.new(@modelname),"This Finder instance is invalid" unless @model packages=Array.new #first of all find the package in the model pkg= find_logical_package(root_package,debug) begin caps=pkg.LogicalPackages @logger.debug("There are #{caps.Count} packages under #{pkg.GetQualifiedName}") cnt=caps.Count 1.upto(cnt){|i| packages<<caps.GetAt(i).GetQualifiedName } end if pkg return packages end |