Class: Fhlow::Leaf
- Inherits:
-
Object
- Object
- Fhlow::Leaf
- Defined in:
- lib/module_fhlow/leaf.rb
Overview
Leaf’s are fhlows major objects. They are created while parsing the directory structure as children of Node’s. A Leaf holds informations about its dependencies which are also Leaf’s. Leaf is an acstract class, so there have to be subclasses in order to create Leaf objects.
Instance Attribute Summary collapse
-
#conf ⇒ Object
readonly
The configuration container.
-
#name ⇒ Object
readonly
The name of the Leaf.
-
#prefix ⇒ Object
readonly
The prefix of the Leaf.
Instance Method Summary collapse
-
#fetchDependencies ⇒ Object
Collects the dependencies by building a list of object references using the information from the configuration object.
-
#fetchOneDependency(_item) ⇒ Object
Each configuration item in the [Dependencies] section of the config file is passed to this function in order to request the coresponding Leaf from the parent.
-
#getFiles(_deptype, _istoplevel = true, _caller = nil, _files = Array.new) ⇒ Object
This function returns an Array of filenames in respect of the dependency tree and needs to be implemented by subclasses.
-
#getPath ⇒ Object
Returns the absolute path in the filesystem by requesting the path from the parent and adding prefix and name.
- #getTarget(_itemname) ⇒ Object
-
#printMe(_prefix = " ", _depth = 0, _caller = nil) ⇒ Object
Prints information about this child.
Instance Attribute Details
#conf ⇒ Object (readonly)
The configuration container.
43 44 45 |
# File 'lib/module_fhlow/leaf.rb', line 43 def conf @conf end |
#name ⇒ Object (readonly)
The name of the Leaf
37 38 39 |
# File 'lib/module_fhlow/leaf.rb', line 37 def name @name end |
#prefix ⇒ Object (readonly)
The prefix of the Leaf.
40 41 42 |
# File 'lib/module_fhlow/leaf.rb', line 40 def prefix @prefix end |
Instance Method Details
#fetchDependencies ⇒ Object
Collects the dependencies by building a list of object references using the information from the configuration object. This function is invoked by the parent. See RootNode.initialize and Node.fetchDependencies for more information.
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/module_fhlow/leaf.rb', line 79 def fetchDependencies() # there needs to be a [Dependencies] section the config file if @conf["Dependencies"].nil? raise FhlowException.new(getPath, "Couldn't find section [Dependencies] in any config.flw file responsible for this leaf.") end # iterate through all items of the [Dependencies] section @conf["Dependencies"].each do |item| # item -> one item of the [Dependencies] section fetchOneDependency(item) end # there needs to be a target section the config file if @conf["Target"+@conf["Target"]["Target"]].nil? raise FhlowException.new(getPath, "Couldn't find section [Target#{@conf["Target"]["Target"]}] in any config.flw file responsible for this leaf.") end fetchOneDependency(@conf["Target"+@conf["Target"]["Target"]].getItem("SimulationLibraries")) dummy = "" @dependencies.each{ |deptype, leafs| dummy += "#{deptype} -> "; leafs.each { |leaf| dummy += "#{leaf.prefix}#{leaf.name} "}; dummy += "; " } @log.debug(@prefix+@name, "direct dependencies: #{dummy}") end |
#fetchOneDependency(_item) ⇒ Object
Each configuration item in the [Dependencies] section of the config file is passed to this function in order to request the coresponding Leaf from the parent. If _item is is of type Config::ComplexUnit architectures are also handled.
_item
-
One item from the section [Dependencies].
TODO
in die konkreten leafs auslagern
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/module_fhlow/leaf.rb', line 111 def fetchOneDependency(_item) if _item.instance_of?(Config::ComplexUnit) _item.value.each do |value| begin leaf = @parent.getLeaf(value["deppath"], value["deppath"].length-1) raise FhlowException.new(@prefix+@name), "requested a Fhlow::Unit but got a #{leaf.class.to_s}!" unless leaf.instance_of?(Unit) leaf.addArchitectures(self, _item.name, value["archs"]) raise FhlowException.new(@prefix+@name), "has itself as dependency!" if leaf == self rescue FhlowObjectNotFoundException => e # fetch the exception and add the name of this leaf so the errormessage is more accurate raise FhlowObjectNotFoundException.new(@prefix+@name), "#{e.caller}: #{e.}" end # init the container if it is nil @dependencies[_item.name] = Array.new if @dependencies[_item.name].nil? # save the object in the container if it does'nt exist @dependencies[_item.name].push(leaf) unless @dependencies[_item.name].include?(leaf) end elsif _item.instance_of?(Config::ComplexPackage) or _item.instance_of?(Config::ComplexLibrary) _item.value.each do |value| begin leaf = @parent.getLeaf(value, value.length-1) raise FhlowException.new(@prefix+@name), "has itself as dependency!" if leaf == self rescue FhlowObjectNotFoundException => e # fetch the exception and add the name of this leaf so the errormessage is more accurate raise FhlowObjectNotFoundException.new(@prefix+@name), "#{e.caller}: #{e.}" end # init the container if it is nil @dependencies[_item.name] = Array.new if @dependencies[_item.name].nil? # save the object in the container if it does'nt exist @dependencies[_item.name].push(leaf) unless @dependencies[_item.name].include?(leaf) end end end |
#getFiles(_deptype, _istoplevel = true, _caller = nil, _files = Array.new) ⇒ Object
This function returns an Array of filenames in respect of the dependency tree and needs to be implemented by subclasses.
_deptype
-
Type of the requested dependencies (could be Units, BhvUnits, Packages and so on)
_istoplevel
-
Is used to indicate the first entrance to this function.
_caller
-
Reference to the caller of the function. This is needed to request architectures.
_files
-
The Array of the files which will be filled with the requested filenames and returned in the end.
160 161 162 163 |
# File 'lib/module_fhlow/leaf.rb', line 160 def getFiles(_deptype, _istoplevel=true, _caller=nil, _files=Array.new) # this funktion needs to be implemented in an derived class! raise FhlowException.new(self.class), "getFiles() is not implemented for "+self.class.to_s end |
#getPath ⇒ Object
Returns the absolute path in the filesystem by requesting the path from the parent and adding prefix and name.
167 168 169 |
# File 'lib/module_fhlow/leaf.rb', line 167 def getPath() @parent.getPath+@prefix+@name+"/" end |
#getTarget(_itemname) ⇒ Object
187 188 189 190 191 192 193 |
# File 'lib/module_fhlow/leaf.rb', line 187 def getTarget(_itemname) if _itemname == "Name" "Target#{@conf["Target"]["Target"]}" else @conf["Target#{@conf["Target"]["Target"]}"][_itemname] end end |
#printMe(_prefix = " ", _depth = 0, _caller = nil) ⇒ Object
Prints information about this child.
_prefix
-
This prefix will be added to the output of ths function.
_depth
-
The depth of the recursion.
_caller
-
The reference to the caller.
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/module_fhlow/leaf.rb', line 175 def printMe(_prefix=" ", _depth=0, _caller=nil) self.print(_prefix, _depth, _caller) @dependencies.each do |deptype, leafs| leafs.each { |leaf| leaf.printMe(_prefix+" ", _depth+1, self) } end if !@dependencies.empty? @pen.print "\n" if _depth == 0 end |