Sha256: 1f40ac4e5ba2435122029bfdb4f7078ff08c1c7fe82721438b666436348c0e08
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
require 'set' require 'hashmake' module SPNet class MessageOutPort include Hashmake::HashMakeable ARG_SPECS = [ Hashmake::ArgSpec.new(:reqd => false, :key => :name, :type => String, :default => "UNNAMED"), ] attr_reader :name, :links def initialize args = {} hash_make MessageOutPort::ARG_SPECS, args @links = Set.new end def send_message message rvs = [] @links.each do |link| rvs.push link.recv_message message end return rvs end def add_link link raise ArgumentError, "link #{link} is not a MessageInPort" unless link.is_a?(MessageInPort) raise ArgumentError, "link #{link} is already linked to a MessageInPort" if link.link @links.add link link.set_link self end def remove_link link raise ArgumentError, "link #{link} is not a MessageInPort" unless link.is_a?(MessageInPort) raise ArgumentError, "@links does not include link #{link}" unless @links.include? link @links.delete link link.clear_link end def remove_bad_links marked_for_removal = [] @links.each do |link| bad = (link.link == nil) or (link.link != self) if bad marked_for_removal.push link end end marked_for_removal.each do |link| @links.delete link end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spnet-0.1.2 | lib/spnet/message_out_port.rb |
spnet-0.1.1 | lib/spnet/message_out_port.rb |