Line 37... |
Line 37... |
# A small classes, used to group information
|
# A small classes, used to group information
|
# and to verify, auto-correct and auto-complete
|
# and to verify, auto-correct and auto-complete
|
# this information:
|
# this information:
|
# The class represents an interface definition:
|
# The class represents an interface definition:
|
# - name of the interface (mandatory)
|
# - name of the interface (mandatory)
|
# - a version (mandatory)
|
# - a id (mandatory)
|
# - a direction (mandatry)
|
# - a direction (mandatry)
|
# - ports (hash of type SOCMaker::IfcPort, mandatory)
|
# - ports (hash of type SOCMaker::IfcPort, mandatory)
|
#
|
#
|
# Note: instances of this class are used withing core-definitions.
|
# Note: instances of this class are used withing core-definitions.
|
# Different cores may use the same interface, but with a
|
# Different cores may use the same interface, but with a
|
# different naming of the ports. For this reason, the name+version
|
# different naming of the ports. For this reason, the name+id
|
# is used to identify, which interface specification (SOCMaker::IfcSpc)
|
# is used to identify, which interface specification (SOCMaker::IfcSpc)
|
# is defined. The port-hash makes the relation between the core port-naming
|
# is defined. The port-hash makes the relation between the core port-naming
|
# and the IfcSpc port-naming.
|
# and the IfcSpc port-naming.
|
|
# TODO
|
#
|
#
|
###############################################################
|
###############################################################
|
|
|
module SOCMaker
|
module SOCMaker
|
class IfcDef
|
class IfcDef
|
include ERR
|
include ERR
|
attr_accessor :name
|
attr_accessor :name
|
attr_accessor :dir
|
attr_accessor :dir
|
attr_accessor :version
|
attr_accessor :id
|
attr_accessor :ports
|
attr_accessor :ports
|
|
|
def initialize( name, version, dir, ports )
|
def initialize( name, id, dir, ports )
|
init_with( 'name' => name,
|
init_with( 'name' => name,
|
'dir' => dir,
|
'dir' => dir,
|
'version' => version,
|
'id' => id,
|
'ports' => ports )
|
'ports' => ports )
|
end
|
end
|
def encode_with( coder )
|
def encode_with( coder )
|
%w[ name dir version ports ].
|
%w[ name dir id ports ].
|
each { |v| coder[ v ] = instance_variable_get "@#{v}" }
|
each { |v| coder[ v ] = instance_variable_get "@#{v}" }
|
end
|
end
|
def init_with( coder )
|
def init_with( coder )
|
|
|
# name
|
# name
|
Line 83... |
Line 84... |
field: 'name' )
|
field: 'name' )
|
verr_if( @name.size == 0,
|
verr_if( @name.size == 0,
|
"Name has zero length",
|
"Name has zero length",
|
field: "name" )
|
field: "name" )
|
|
|
# version
|
# id
|
serr_if( coder[ 'version' ] == nil,
|
serr_if( coder[ 'id' ] == nil,
|
'version is not given for interface',
|
'id is not given for interface',
|
instance: @name,
|
instance: @name,
|
field: 'version' )
|
field: 'id' )
|
@version = coder[ 'version' ]
|
@id = coder[ 'id' ]
|
@version = @version.to_s if @version.is_a?( Numeric )
|
serr_if( !@id.is_a?( String ),
|
serr_if( !@version.is_a?( String ),
|
'Interface id is not defined as string',
|
'Interface version is not defined as string',
|
|
instance: @name,
|
instance: @name,
|
field: 'version' )
|
field: 'id' )
|
verr_if( @version.size == 0,
|
verr_if( @id.size == 0,
|
"Version has zero length",
|
"Version has zero length",
|
field: "name" )
|
field: "name" )
|
|
|
|
|
# ports
|
# ports
|
Line 142... |
Line 142... |
|
|
def ==(o)
|
def ==(o)
|
o.class == self.class &&
|
o.class == self.class &&
|
o.name == self.name &&
|
o.name == self.name &&
|
o.dir == self.dir &&
|
o.dir == self.dir &&
|
o.version == self.version &&
|
o.id == self.id &&
|
o.ports == self.ports
|
o.ports == self.ports
|
end
|
end
|
|
|
|
|
end # IFCDef
|
end # IFCDef
|