/[freeride]/freeride/freebase/databus.rb
ViewVC logotype

Diff of /freeride/freebase/databus.rb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by richkilmer, Fri Aug 9 13:09:37 2002 UTC revision 1.10 by richkilmer, Fri Sep 13 04:05:59 2002 UTC
# Line 110  module FreeBASE Line 110  module FreeBASE
110          @path = parent.nil? ? "/" : "#{parent.path}#{name}/"          @path = parent.nil? ? "/" : "#{parent.path}#{name}/"
111          @databus = databus          @databus = databus
112          @slots = Hash.new          @slots = Hash.new
113            @links = Hash.new
114          @subscribers = Hash.new          @subscribers = Hash.new
115          @propagate_notifications = true          @propagate_notifications = true
116          notify(:notify_slot_add)          notify(:notify_slot_add)
# Line 177  module FreeBASE Line 178  module FreeBASE
178            subslot = path.shift            subslot = path.shift
179          end          end
180          return self unless subslot # path now empty...return self          return self unless subslot # path now empty...return self
181          unless child = @slots[subslot] # is child defined ?          unless (child = @slots[subslot]) # is child defined ?
182            child = @slots[subslot]= Slot.new(subslot, self, @databus) # build new one            unless (child = @links[subslot]) # is child a link?
183                child = @slots[subslot]= Slot.new(subslot, self, @databus) # build new one
184              end
185          end          end
186          while path.first==""  # get rid of multi-slashes foo///bar          while path.first==""  # get rid of multi-slashes foo///bar
187            path.shift            path.shift
# Line 204  module FreeBASE Line 207  module FreeBASE
207        end        end
208                
209        ##        ##
210        # Iterates over the sub-slots and yields each one        # Iterates over the sub-slots and link slots
211        #        #
212        # yeild:: [FreeBASE::DataBus::Slot] The child slot        # yeild:: [FreeBASE::DataBus::Slot] The child slot
213        #        #
214        def each_slot        def each_slot
215          @slots.each_value {|slot| yield slot}          @slots.each_value {|slot| yield slot}
216            @links.each_value {|slot| yield slot}
217          end
218          
219          ##
220          # Links a child slot name to another slot in the databus
221          #
222          # child:: [String] The name of the child
223          # destination:: [String | FreeBASE::DataBus::Slot] The destination of the link
224          #
225          def link(child, destination)
226            destination = self[destination] if destination.kind_of? String
227            raise "Can only link to a DataBus::Slot" unless destination.kind_of? Slot
228            @links[child] = destination
229          end
230          
231          ##
232          # Unlinks a child slot name to another slot in the databus
233          #
234          # child:: [String] The name of the child
235          #
236          def unlink(child)
237            @links.delete(child)
238          end
239          
240          ##
241          # Returns if the child slot name is linked
242          #
243          # child:: [String] The name of the child slot
244          # return:: [Boolean] True is the slot is a link
245          #
246          def is_linked?(child)
247            return @links.include?(child)
248        end        end
249                
250        ##        ##

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26