001         package com.croftsoft.apps.infant;
002         
003         import com.croftsoft.core.lang.*;
004         
005         /*********************************************************************
006         * A request to or an event generated by InfantModel.
007         * 
008         * @version
009         *   $Id: InfantMessage.java,v 1.5 2007/02/25 03:17:05 croft Exp $
010         * @since
011         *   2006-06-14
012         * @author
013         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
014         *********************************************************************/
015    
016         public final class  InfantMessage
017         //////////////////////////////////////////////////////////////////////
018         //////////////////////////////////////////////////////////////////////
019         {
020           
021         public enum  Type
022         {
023           DURATION_CHANGED,
024           DURATION,
025           EXPERIMENT_BEGIN,
026           EXPERIMENT_END,
027           GET_SAVE_REPORT_FILENAME,
028           IMAGE,
029           ISI, // a request to change the interStimulusInterval
030           ISI_CHANGED,
031           LOAD_SETUP,
032           PACIFIER,
033           REQUEST_SAVE_FILENAME,
034           SAVE_DATA,
035           SET_CONTROLLER_INDEX,
036           SET_SCALE_REQUEST,
037           STIMULUS_WINDOW_CLOSE,
038           STIMULUS_WINDOW_CLOSING,
039           STIMULUS_WINDOW_OPEN,
040         }
041         
042         private final Type    type;
043         
044         private final Object  value;
045         
046         //////////////////////////////////////////////////////////////////////
047         //////////////////////////////////////////////////////////////////////
048         
049         public  InfantMessage (
050           final Type    type,
051           final Object  value )
052         //////////////////////////////////////////////////////////////////////
053         {
054           NullArgumentException.check ( this.type = type );
055           
056           this.value = value;
057         }
058         
059         public  InfantMessage ( final Type  type )
060         //////////////////////////////////////////////////////////////////////
061         {
062           this ( type, null );
063         }
064         
065         //////////////////////////////////////////////////////////////////////
066         //////////////////////////////////////////////////////////////////////
067         
068         public Type    getType  ( ) { return type;  }
069         
070         public Object  getValue ( ) { return value; }
071         
072         //////////////////////////////////////////////////////////////////////
073         //////////////////////////////////////////////////////////////////////
074         
075         @Override
076         public String  toString ( )
077         //////////////////////////////////////////////////////////////////////
078         {
079           return type.name ( ) + ( value == null ? "" : " " + value );
080         }
081    
082         //////////////////////////////////////////////////////////////////////
083         //////////////////////////////////////////////////////////////////////
084         }