214 lines
5.0 KiB
Plaintext
214 lines
5.0 KiB
Plaintext
###########################################################################
|
|
# #
|
|
# Copyright (C) 1995, Silicon Graphics, Inc. #
|
|
# #
|
|
# These coded instructions, statements, and computer programs contain #
|
|
# unpublished proprietary information of Silicon Graphics, Inc., and #
|
|
# are protected by Federal copyright law. They may not be disclosed #
|
|
# to third parties or copied or duplicated in any form, in whole or #
|
|
# in part, without the prior written consent of Silicon Graphics, Inc. #
|
|
# #
|
|
###########################################################################
|
|
|
|
#%COMMENT_BEGIN
|
|
# Filename: obj.tlib
|
|
# Version: $Revision: 1.1 $
|
|
# Synopsis: General utility functions for dealing with objects.
|
|
# Packages: Obj-Base
|
|
# Obj-Util
|
|
# Obj-Ext
|
|
#
|
|
#
|
|
#%COMMENT_END
|
|
|
|
|
|
#%COMMENT_BEGIN
|
|
# Package: Obj-Base
|
|
# Functions: obj:sort
|
|
# obj:parse
|
|
# obj:unparse
|
|
#
|
|
# Function: obj:sort
|
|
# Synopsis: A sorting routine that can be used as an agument to the "lsort"
|
|
# command. The objects are sorted on their name.
|
|
# Arguments: - x An object.
|
|
# - y An object.
|
|
#
|
|
# Function: obj:parse
|
|
# Synopsis: Parses an object storing each piece of the signature into
|
|
# the passed in references to variables.
|
|
# Arguments: - cls A reference to a variable in which to store
|
|
# the object class.
|
|
# - hst A reference to a variable in which to store
|
|
# the host that the object resides on.
|
|
# - nm A reference to a variable in which to store
|
|
# the object name.
|
|
# - typ A reference to a variable in which to store
|
|
# the object type.
|
|
#
|
|
# Function: obj:unparse
|
|
# Synopsis: Create the object represented byt the components passed in.
|
|
# Arguments: - cls The object class.
|
|
# - hst The object host.
|
|
# - nm The object name.
|
|
# - typ The object type.
|
|
#
|
|
#%COMMENT_END
|
|
|
|
#@package: Obj-Base obj:parse obj:unparse obj:sort
|
|
|
|
proc obj:sort { x y } \
|
|
{
|
|
if {[lindex $x 2] < [lindex $y 2]} {
|
|
return -1
|
|
} elseif {[lindex $x 2] > [lindex $y 2]} {
|
|
return 1
|
|
} else {
|
|
return 0
|
|
}
|
|
}
|
|
|
|
proc obj:parse { object cls hst nm typ } \
|
|
{
|
|
upvar $cls class
|
|
upvar $hst host
|
|
upvar $nm name
|
|
upvar $typ type
|
|
|
|
lassign $object host class name type
|
|
}
|
|
|
|
proc obj:unparse { cls hst nm typ } \
|
|
{
|
|
return "$hst $cls $nm $typ"
|
|
}
|
|
#@packend
|
|
|
|
|
|
#%COMMENT_BEGIN
|
|
# Package: Obj-Util
|
|
# Functions: obj:isXfsmTemplate
|
|
# obj:isXfsmObject
|
|
#
|
|
# Function: obj:isXfsmTemplate
|
|
# Synopsis: Determines whether or not an object is a XFSM template.
|
|
# Arguments: - object The object.
|
|
# - class An optional parameter that allows checking for
|
|
# a specific class of template.
|
|
# - type An optional parameter that allows checking for
|
|
# a specific type of template.
|
|
#
|
|
# Function: obj:isXfsmObject
|
|
# Synopsis: Determines whether or not an object is a XFSM object.
|
|
# Arguments: - object The object.
|
|
# - class An optional parameter that allows checking for
|
|
# a specific class of object.
|
|
# - type An optional parameter that allows checking for
|
|
# a specific type of object.
|
|
#
|
|
#%COMMENT_END
|
|
|
|
#@package: Obj-Util obj:isXfsmTemplate obj:isXfsmObject
|
|
|
|
proc obj:isXfsmObject { object {class ""} {type ""} } \
|
|
{
|
|
if {[llength $object] != 4} {
|
|
return 0
|
|
}
|
|
|
|
set o_class [lindex $object 1]
|
|
if {[lindex $object 0] == "_TEMPLATE_"} {
|
|
return 0
|
|
} elseif {$o_class != "DISK" && \
|
|
$o_class != "FS" && \
|
|
$o_class != "VOL"} {
|
|
return 0
|
|
} elseif {$class != "" & $class != $o_class} {
|
|
return 0
|
|
} elseif {$type != ""} {
|
|
set o_type [lindex $object 3]
|
|
if {$type != $o_type} {
|
|
return 0
|
|
}
|
|
}
|
|
|
|
return 1
|
|
}
|
|
|
|
proc obj:isXfsmTemplate { object {class ""} {type ""} } \
|
|
{
|
|
if {[llength $object] != 4} {
|
|
# puts "isXfsmTemplate: len=[llength $object]"
|
|
return 0
|
|
}
|
|
|
|
set o_class [lindex $object 1]
|
|
if {[lindex $object 0] != "_TEMPLATE_"} {
|
|
return 0
|
|
} elseif {$o_class != "DISK" && \
|
|
$o_class != "FS" && \
|
|
$o_class != "VOL"} {
|
|
return 0
|
|
} elseif {$class != "" && $class != $o_class} {
|
|
return 0
|
|
} elseif {$type != ""} {
|
|
set o_type [lindex $object 3]
|
|
if {$type != $o_type} {
|
|
return 0
|
|
}
|
|
}
|
|
|
|
return 1
|
|
}
|
|
#@packend
|
|
|
|
|
|
#%COMMENT_BEGIN
|
|
# Package: Obj-Ext
|
|
# Functions: obj:getHost
|
|
# obj:getClass
|
|
# obj:getName
|
|
# obj:getType
|
|
#
|
|
# Function: obj:getHost
|
|
# Synopsis: Returns the host component of an object.
|
|
# Arguments: - object The object.
|
|
#
|
|
# Function: obj:getClass
|
|
# Synopsis: Returns the class component of an object.
|
|
# Arguments: - object The object.
|
|
#
|
|
# Function: obj:getName
|
|
# Synopsis: Returns the name component of an object.
|
|
# Arguments: - object The object.
|
|
#
|
|
# Function: obj:getType
|
|
# Synopsis: Returns the type component of an object.
|
|
# Arguments: - object The object.
|
|
#
|
|
#%COMMENT_END
|
|
|
|
|
|
#@package: Obj-Ext obj:getHost obj:getClass obj:getName obj:getType
|
|
|
|
proc obj:getHost { obj } \
|
|
{
|
|
return [lindex [split [lindex $obj 0] .] 0]
|
|
}
|
|
|
|
proc obj:getClass { obj } \
|
|
{
|
|
return [lindex $obj 1]
|
|
}
|
|
|
|
proc obj:getName { obj } \
|
|
{
|
|
return [lindex $obj 2]
|
|
}
|
|
|
|
proc obj:getType { obj } \
|
|
{
|
|
return [lindex $obj 3]
|
|
}
|
|
#@packend
|