Class: Trema::NetworkComponent
- Inherits:
-
Object
- Object
- Trema::NetworkComponent
- Defined in:
- ruby/trema/network-component.rb
Overview
The base class of objects appears in the Trema DSL. e.g., host, switch, link etc.
Direct Known Subclasses
App, Host, Link, Netns, OpenflowSwitch, PacketinFilter, SwitchManager
Class Attribute Summary collapse
-
.instances ⇒ Array
Returns the ‘name’ => object hash DB of instances.
Class Method Summary collapse
-
.[](name) ⇒ Object
Looks up a instance DB by its name.
-
.add(object) ⇒ Object
Inserts a object to instance DB.
- .clear ⇒ Object
-
.each(&block) ⇒ Array
Iterates over the list of instances.
-
.inherited(subclass) ⇒ undefined
Called implicitly when inherited.
-
.size ⇒ Number
Returns the number of instances.
Class Attribute Details
.instances ⇒ Array
Returns the ‘name’ => object hash DB of instances
40 41 42 |
# File 'ruby/trema/network-component.rb', line 40 def instances @instances end |
Class Method Details
.[](name) ⇒ Object
Looks up a instance DB by its name
105 106 107 |
# File 'ruby/trema/network-component.rb', line 105 def self.[] name instances[ name ] end |
.add(object) ⇒ Object
Inserts a object to instance DB
140 141 142 |
# File 'ruby/trema/network-component.rb', line 140 def self.add object instances[ object.name ] = object end |
.clear ⇒ Object
66 67 68 |
# File 'ruby/trema/network-component.rb', line 66 def self.clear instances.clear end |
.each(&block) ⇒ Array
Iterates over the list of instances
83 84 85 86 87 |
# File 'ruby/trema/network-component.rb', line 83 def self.each &block instances.values.each do | each | block.call each end end |
.inherited(subclass) ⇒ undefined
Called implicitly when inherited
60 61 62 |
# File 'ruby/trema/network-component.rb', line 60 def self.inherited subclass subclass.instances ||= OrderedHash.new end |
.size ⇒ Number
Returns the number of instances.
120 121 122 |
# File 'ruby/trema/network-component.rb', line 120 def self.size instances.values.size end |