~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/indiva/lib/ascp-packet.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # ascp-packet.tcl --

  2 #

  3 #   This object represents an ASCP message/packet.  We hide the format

  4 #   and the content of the packet from the users, so that we can easily

  5 #   add a new field, or rearrange the fields.

  6 #

  7 # Copyright (c) 1996-2002 The Regents of the University of California.

  8 # All rights reserved.

  9 #

 10 # Redistribution and use in source and binary forms, with or without

 11 # modification, are permitted provided that the following conditions are met:

 12 #

 13 # A. Redistributions of source code must retain the above copyright notice,

 14 #    this list of conditions and the following disclaimer.

 15 # B. Redistributions in binary form must reproduce the above copyright notice,

 16 #    this list of conditions and the following disclaimer in the documentation

 17 #    and/or other materials provided with the distribution.

 18 # C. Neither the names of the copyright holders nor the names of its

 19 #    contributors may be used to endorse or promote products derived from this

 20 #    software without specific prior written permission.

 21 #

 22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''

 23 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

 24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

 25 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR

 26 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL

 27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR

 28 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER

 29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,

 30 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

 31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 32 #

 33 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/indiva/lib/ascp-packet.tcl,v 1.1 2002/05/28 20:04:23 weitsang Exp $

 34 
 35 
 36 #--------------------------------------------------------------------------

 37 # Class:

 38 #   ASCPPacket

 39 # Description:

 40 #   This object represents an ASCP message/packet.  We hide the format

 41 #   and the content of the packet from the users, so that we can easily

 42 #   add a new field, or rearrange the fields.  The method to_string{}

 43 #   converts the packet to a string (for transmission) and method 

 44 #   from_string{} parses a packet into an object.  Method from_ascp{} takes

 45 #   in an operation and an ASCP object, and copies the contents of the packet 

 46 #   from the ASCP object.  Individual fields can be queried or modified using

 47 #   methods named after the field.

 48 # See Also:

 49 #   ASCP, ASCP/Client, ASCP/Server, ASCP/Manager

 50 #--------------------------------------------------------------------------

 51 
 52 Class ASCPPacket
 53 
 54 ASCPPacket instproc init { } {
 55     $self instvar agent_type_ agent_id_ args_ operation_ 
 56     $self instvar service_type_ service_location_ service_instance_ ssg_port_
 57     $self instvar precondition_
 58 
 59     set agent_type_ "-"
 60     set agent_id_ "-"
 61     set operation_ "-"
 62     set service_type_ "-"
 63     set service_location_ "-"
 64     set service_instance_ "-"
 65     set precondition_ "-"
 66     set ssg_port_ "-"
 67     set args_ "-"
 68 }
 69 
 70 ASCPPacket instproc to_string { } {
 71     $self instvar agent_type_ agent_id_ args_ operation_ 
 72     $self instvar service_type_ service_location_ service_instance_ ssg_port_
 73     $self instvar precondition_ 
 74     
 75     set o "ASCP v[ASCP version]\n"
 76     append o "$agent_type_\n"
 77     append o "$agent_id_\n"
 78     append o "$operation_\n"
 79     append o "$service_type_\n"
 80     append o "$service_location_\n"
 81     append o "$service_instance_\n"
 82     append o "$precondition_\n"
 83     append o "$ssg_port_\n"
 84     append o "$args_\n"
 85 
 86     return $o
 87 }
 88 
 89 
 90 ASCPPacket instproc from_ascp { operation ascp } {
 91     $self instvar agent_type_ agent_id_ args_ operation_ precondition_
 92     $self instvar service_type_ service_location_ service_instance_ ssg_port_
 93     set agent_type_ [$ascp agent_type]
 94     set agent_id_   [$ascp agent_id]
 95     set operation_  $operation
 96     set service_type_     [$ascp service_type]
 97     set service_location_ [$ascp service_location]
 98     set service_instance_ [$ascp service_instance]
 99     set precondition_   [$ascp precondition]
100     set ssg_port_   [$ascp ssg_port]
101     set args_ [$ascp args]
102 }
103 
104 
105 ASCPPacket instproc from_string { str } {
106     $self instvar agent_type_ agent_id_ args_ operation_ precondition_
107     $self instvar service_type_ service_location_ service_instance_ ssg_port_
108     set o [split $str \n]
109     if {[lindex $o 0] != "ASCP v[ASCP version]"} {
110         return "invalid version"
111     }
112     set agent_type_ [lindex $o 1]
113     set agent_id_   [lindex $o 2]
114     set operation_  [lindex $o 3]
115     set service_type_     [lindex $o 4]
116     set service_location_ [lindex $o 5]
117     set service_instance_ [lindex $o 6]
118     set precondition_   [lindex $o 7]
119     set ssg_port_   [lindex $o 8]
120     set args_ [join [lrange $o 9 end] \n]
121 }
122 
123 ASCPPacket instproc agent_type { args } {
124     $self instvar agent_type_
125     if {$args == ""} {
126         return $agent_type_
127     } else {
128         set agent_type_ $args
129     }
130 }
131 
132 
133 ASCPPacket instproc agent_id { args } {
134     $self instvar agent_id_
135     if {$args == ""} {
136         return $agent_id_
137     } else {
138         set agent_id_ $args
139     }
140 }
141 
142 
143 
144 ASCPPacket instproc operation { args } {
145     $self instvar operation_
146     if {$args == ""} {
147         return $operation_
148     } else {
149         set operation_ $args
150     }
151 }
152 
153 
154 ASCPPacket instproc service_type { args } {
155     $self instvar service_type_
156     if {$args == ""} {
157         return $service_type_
158     } else {
159         set service_type_ $args
160     }
161 }
162 
163 
164 ASCPPacket instproc service_location { args } {
165     $self instvar service_location_
166     if {$args == ""} {
167         return $service_location_
168     } else {
169         set service_location_ $args
170     }
171 }
172 
173 
174 ASCPPacket instproc service_instance { args } {
175     $self instvar service_instance_
176     if {$args == ""} {
177         return $service_instance_
178     } else {
179         set service_instance_ $args
180     }
181 }
182 
183 
184 ASCPPacket instproc precondition { args } {
185     $self instvar precondition_
186     if {$args == ""} {
187         return $precondition_
188     } else {
189         set precondition_ [lindex $args 0]
190     }
191 }
192 
193 
194 ASCPPacket instproc ssg_port { args } {
195     $self instvar ssg_port_
196     if {$args == ""} {
197         return $ssg_port_
198     } else {
199         set ssg_port_ $args
200     }
201 }
202 
203 
204 ASCPPacket instproc args { args } {
205     $self instvar args_
206     if {$args == ""} {
207         return $args_
208     } else {
209         set args_ [lindex $args 0]
210     }
211 }
212 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.