[nio-cvs] r32 - branches/home/psmith/restructure/src/statemachine
psmith at common-lisp.net
psmith at common-lisp.net
Mon Jan 8 19:03:58 UTC 2007
Author: psmith
Date: Mon Jan 8 14:03:57 2007
New Revision: 32
Added:
branches/home/psmith/restructure/src/statemachine/
branches/home/psmith/restructure/src/statemachine/nio-sm-package.lisp
branches/home/psmith/restructure/src/statemachine/nio-sm.asd
branches/home/psmith/restructure/src/statemachine/state-machine.lisp
Log:
Start of state-machine class work
Added: branches/home/psmith/restructure/src/statemachine/nio-sm-package.lisp
==============================================================================
--- (empty file)
+++ branches/home/psmith/restructure/src/statemachine/nio-sm-package.lisp Mon Jan 8 14:03:57 2007
@@ -0,0 +1,33 @@
+#|
+Copyright (c) 2007
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+|#
+(defpackage :nio-sm (:use :cl :nio :nio-buffer)
+
+ (:export
+
+ ;; state-machine
+ state-machine
+ ))
Added: branches/home/psmith/restructure/src/statemachine/nio-sm.asd
==============================================================================
--- (empty file)
+++ branches/home/psmith/restructure/src/statemachine/nio-sm.asd Mon Jan 8 14:03:57 2007
@@ -0,0 +1,11 @@
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+
+(in-package :asdf)
+
+(defsystem :nio-sm
+
+ :components ((:file "nio-sm-package")
+ (:file "state-machine" :depends-on ("nio-sm-package"))
+ )
+
+ :depends-on (:nio))
\ No newline at end of file
Added: branches/home/psmith/restructure/src/statemachine/state-machine.lisp
==============================================================================
--- (empty file)
+++ branches/home/psmith/restructure/src/statemachine/state-machine.lisp Mon Jan 8 14:03:57 2007
@@ -0,0 +1,52 @@
+#|
+Copyright (c) 2007
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+|#
+(in-package :nio-sm)
+
+(declaim (optimize (debug 3) (speed 3) (space 0)))
+
+;
+;Base class for state machines
+;
+;Converts incomming data between bytes and packets using the supplied packet-factory.
+;Converts outgoing data between packets and bytes using the get-bytes method on packet.
+;
+;This way only the protocols packet heirarchy knows about binary representations and
+; the SM can deal with protocol logic and state maintenance
+;
+(defclass state-machine (async-fd)())
+
+(defmethod print-object ((sm state-machine) stream)
+ (format stream "#<STATE-MACHINE ~A >" (call-next-method sm nil)))
+
+(defmethod process-read((sm state-machine))
+ (with-slots (foreign-read-buffer foreign-write-buffer) sm
+ (let ((fn-result (execute-call (sb-ext:octets-to-string (get-string foreign-read-buffer) :external-format :ascii))))
+ (format t "process-read - function result: ~A~%" fn-result)
+ (nio-buffer:bytebuffer-write-string foreign-write-buffer (write-to-string fn-result) 0 :utf-8)
+ (close-sm sm))))
+
+
More information about the Nio-cvs
mailing list