usbdmx.com Home of the opto isolated, bus powered, DMX512 interface with both in and out universes. Cheap and simple to build. USBDMX logo

LOCommandProcessor.h

00001 /*
00002  *
00003  * Copyright (c) 2006,2005,2004 Ben Suffolk <ben@usbdmx.com>
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without 
00007  * modification, are permitted provided that the following conditions are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright notice,
00010  *    this list of conditions and the following disclaimer.
00011  *
00012  * 2. Redistributions in binary form must reproduce the above copyright notice,
00013  *    this list of conditions and the following disclaimer in the documentation
00014  *    and/or other materials provided with the distribution.
00015  *
00016  * 3. Neither the name of the usbdmx.com web site nor the names of its 
00017  *    contributors may be used to endorse or promote products derived from this
00018  *    software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00025  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00026  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00029  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  *
00032  * $Id: LOCommandProcessor.h 241 2009-10-23 16:27:41Z ben.suffolk $
00033  *
00034  *******************************************************************************
00035  *
00036  * History :-
00037  *
00038  * <Name>  <Date>
00039  *
00040  * <Comment>
00041  * 
00042  *******************************************************************************
00043 */
00044 
00045 
00046 #import <Cocoa/Cocoa.h>
00047 @class LOCommandToken;
00048 @class LODirectProvider;
00049 @class LOCommandProcessor;
00050 
00051 #define LOCapturedChannelsDidBecomeTier1 @"LOCapturedChannelsDidBecomeTier1"
00052 #define LOCapturedChannelsDidBecomeTier2 @"LOCapturedChannelsDidBecomeTier2"
00053 #define LOCapturedChannelsDidSetValue @"LOCapturedChannelsDidSetValue"
00054 
00055 #define LOCommandProcessorChannels @"LOCommandProcessorChannels"
00056 #define LOCommandProcessorLastToken @"LOCommandProcessorLastToken"
00057 #define LOCommandProcessorValueToken @"LOCommandProcessorValueToken"
00058 
00059 typedef enum LOCommandProcessorDelegateReturn
00060               {
00061                LOCommandProcessorDelegateReturnNO = 0,
00062                LOCommandProcessorDelegateReturnYES,
00063                LOCommandProcessorDelegateReturnDEFAULT          
00064               } LOCommandProcessorDelegateReturn;
00065 
00066 
00072 @interface NSObject (LOCommandProcessorDelegate)
00073 
00074 
00099 - (LOCommandProcessorDelegateReturn)shouldAcceptToken:(LOCommandToken *)theToken processor:(LOCommandProcessor *)processor channelsIdentified:(BOOL)identifiedFlag mustExecute:(BOOL)executeFlag;
00100 
00101 
00118 - (LOCommandProcessorDelegateReturn)execute:(LOCommandProcessor *)processor mustExecute:(BOOL)flag withOptions:(NSDictionary *)options;
00119 
00120 
00127 - (BOOL)isCommandPosisble:(LOCommandProcessor *)processor defaultPosisble:(BOOL)possible;
00128 
00129 
00136 - (BOOL)isCommandComplete:(LOCommandProcessor *)processor defaultComplete:(BOOL)complete;
00137 
00138 
00144 - (void)didResetTokens:(LOCommandProcessor *)processor;
00145 
00146 @end;
00147 
00148 
00154 @interface LOCommandProcessor : NSObject
00155 {
00156  id delegate; 
00157  BOOL delegateMustExecute; 
00158 
00159  NSMutableIndexSet *commandChannels; 
00160 
00161  unsigned lastNumber;          
00162  BOOL lastSign;                
00163  BOOL channelsIdentified;      
00164  LOCommandToken *lastToken;    
00165  LOCommandToken *valueToken;   
00166  BOOL commandPossible;         
00167  BOOL commandEnd;              
00168  BOOL rangeStart;              
00169  BOOL capturePlus;             
00170  BOOL tier2Plus;               
00171  BOOL noLast;                  
00172  
00173 }
00174 
00175 
00176 - (id)init;
00177 
00178 
00189 - (id)delegate;
00190 
00191 
00202 - (void)setDelegate:(id)aDelegate;
00203 
00204 
00215 - (BOOL)executeTokens:(NSArray *)theTokens;
00216 
00217 
00223 - (void)resetTokens;
00224 
00225 
00234 - (BOOL)addToken:(LOCommandToken *)theToken;
00235 
00236 
00242 - (BOOL)execute;
00243 
00244 
00254 - (BOOL)releaseChannels;
00255 
00256 
00263 - (BOOL)cancelSolo;
00264 
00265 
00273 - (BOOL)commandPossible;
00274 
00275 
00283 - (BOOL)commandComplete;
00284 
00285 
00291 + (LODirectProvider *)defaultCaptureProvider;
00292 
00293 
00299 + (LODirectProvider *)defaultSoloProvider;
00300 
00301 
00307 + (NSMutableIndexSet *)defaultCapturedChannels;
00308 
00309 
00316 + (NSMutableIndexSet *)defaultLastChannels;
00317 
00318 
00319 @end
00320 
00321 
00322 
00323 
00324 
00325 
00326 
00327 
00328 
00329