| 1 | package com.gnstudio.nabiro.connectivity.amf.utils
|
|---|
| 2 | {
|
|---|
| 3 | /**
|
|---|
| 4 | *
|
|---|
| 5 | * GNstudio nabiro
|
|---|
| 6 | * =====================================================================
|
|---|
| 7 | * Copyright(c) 2009
|
|---|
| 8 | * http://www.gnstudio.com
|
|---|
| 9 | *
|
|---|
| 10 | *
|
|---|
| 11 | *
|
|---|
| 12 | * This file is part of the nabiro flash platform framework
|
|---|
| 13 | *
|
|---|
| 14 | *
|
|---|
| 15 | * nabiro is free software; you can redistribute it and/or modify
|
|---|
| 16 | * it under the terms of the GNU Lesser General Public License as published by
|
|---|
| 17 | * the Free Software Foundation; either version 3 of the License, or
|
|---|
| 18 | * at your option) any later version.
|
|---|
| 19 | *
|
|---|
| 20 | * nabiro is distributed in the hope that it will be useful,
|
|---|
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 23 | * GNU General Public License for more details.
|
|---|
| 24 | *
|
|---|
| 25 | * You should have received a copy of the GNU Lesser General Public License
|
|---|
| 26 | * along with Intelligere SCS; if not, write to the Free Software
|
|---|
| 27 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 28 | * =====================================================================
|
|---|
| 29 | *
|
|---|
| 30 | *
|
|---|
| 31 | *
|
|---|
| 32 | * @package nabiro
|
|---|
| 33 | *
|
|---|
| 34 | * @version 0.9
|
|---|
| 35 | * @idea maker Giorgio Natili [ g.natili@gnstudio.com ]
|
|---|
| 36 | * @author Giorgio Natili [ g.natili@gnstudio.com ]
|
|---|
| 37 | *
|
|---|
| 38 | *
|
|---|
| 39 | */
|
|---|
| 40 |
|
|---|
| 41 | import com.gnstudio.nabiro.connectivity.amf.remote.IRemoteMethod;
|
|---|
| 42 |
|
|---|
| 43 | /**
|
|---|
| 44 | * This classe defines the queue of remote methods to be invoked.
|
|---|
| 45 | *
|
|---|
| 46 | * This class implements the singleton pattern to provide an unique instance
|
|---|
| 47 | * of the queue object.
|
|---|
| 48 | */
|
|---|
| 49 | public class MethodsQueue{
|
|---|
| 50 |
|
|---|
| 51 | //----------------------------------------------------------------------
|
|---|
| 52 | //
|
|---|
| 53 | // Class properties
|
|---|
| 54 | //
|
|---|
| 55 | //----------------------------------------------------------------------
|
|---|
| 56 |
|
|---|
| 57 | /**
|
|---|
| 58 | * The singleton instance.
|
|---|
| 59 | */
|
|---|
| 60 | private static var manager:MethodsQueue;
|
|---|
| 61 |
|
|---|
| 62 | /**
|
|---|
| 63 | * Used to store methods in the queue.
|
|---|
| 64 | */
|
|---|
| 65 | private var history:Array;
|
|---|
| 66 |
|
|---|
| 67 | //----------------------------------------------------------------------
|
|---|
| 68 | //
|
|---|
| 69 | // Constructor
|
|---|
| 70 | //
|
|---|
| 71 | //----------------------------------------------------------------------
|
|---|
| 72 |
|
|---|
| 73 | /**
|
|---|
| 74 | * Constructor.
|
|---|
| 75 | */
|
|---|
| 76 | public function MethodsQueue(singleton:MethodsQueeSignleton) {
|
|---|
| 77 |
|
|---|
| 78 | history = [];
|
|---|
| 79 |
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | public static function getQueeManager():MethodsQueue{
|
|---|
| 84 |
|
|---|
| 85 | if(MethodsQueue.manager == null){
|
|---|
| 86 |
|
|---|
| 87 | MethodsQueue.manager = new MethodsQueue(new MethodsQueeSignleton());
|
|---|
| 88 |
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | return MethodsQueue.manager;
|
|---|
| 92 |
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | //----------------------------------------------------------------------
|
|---|
| 96 | //
|
|---|
| 97 | // Other methods
|
|---|
| 98 | //
|
|---|
| 99 | //----------------------------------------------------------------------
|
|---|
| 100 |
|
|---|
| 101 | public function getActualElements():int {
|
|---|
| 102 |
|
|---|
| 103 | return history.length;
|
|---|
| 104 |
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | public function getActualStep():MethodsQueueElement {
|
|---|
| 108 |
|
|---|
| 109 | //return history[history.length - 1];
|
|---|
| 110 | if (history.length > 0) return history[0];
|
|---|
| 111 | return null;
|
|---|
| 112 |
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | public function removeStep():void {
|
|---|
| 116 |
|
|---|
| 117 | // The queue follows a FIFO strategy: the first element which is
|
|---|
| 118 | // pushed into the queue is the first to be popped out.
|
|---|
| 119 | //if (history.length > 0) history.splice(history.length - 1, 1);
|
|---|
| 120 | if (history.length > 0) history.splice(0, 1);
|
|---|
| 121 |
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | public function addStep(obj:*):void {
|
|---|
| 125 |
|
|---|
| 126 | history.push(obj);
|
|---|
| 127 |
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | public function clear():void {
|
|---|
| 131 |
|
|---|
| 132 | history = [];
|
|---|
| 133 |
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | internal class MethodsQueeSignleton {
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 | } |
|---|