Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.search.api.events.SearchUpdateEvent.java

Here you can find all the information about the file org.dgpf.search.api.events.SearchUpdateEvent.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-03-30 15:25:58
 * Original Filename: org.dgpf.search.api.events.SearchUpdateEvent.java
 * Version          : 2.0.1
 * Last modification: 2006-07-20
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

 
package org.dgpf.search.api.events;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

import org.dgpf.search.api.SearchEngine;
import org.dgpf.search.api.SearchState;
import org.sfc.utils.ICloneable;
import org.sfc.utils.Typesafe;


/**
 * <p>
 * This event will be thrown whenever the search's state has been updated.
 * An update could be, for example, the completion of a generation in
 * Genetic Algorithms.
 * </p><p>
 * Warning: The reference to the state of the search engine is volatile.
 * The object referenced might change concurrently after the event was
 * thrown. You must process the state only inside the <code>receive</code>-
 * method of your event listener. If you need a permanent copy of the
 * event or the state, you may clone it.
 * </p>
 *
 * @param <Genotype>    The sort of genotype used to represent individuals.
 *                      This must be a serializable type.
 *                    
 * @author Thomas Weise
 */

public final  class SearchUpdateEvent<Genotype extends     Serializable>
                                               extends     SearchEvent
                                               implements  ICloneable
  {
/**
 * The serial version uid.
 */

  private static final long serialVersionUID = 1;
/**
 * The state of the search.
 */

  private transient SearchState<Genotype> m_state ;
  
  
/**
 * Create a new <code>SearchUpdateEvent</code>. Such an event will be
 * created automatically whenever a search's state has been updated.
 * An update could be, for example, the completion of a generation in
 * Genetic Algorithms.
 * @param p_source  The source of the event.
 * @param p_state   The state of the search.
 */

  public  SearchUpdateEvent(final SearchEngine<Genotype> p_source,
                            final SearchState<Genotype>  p_state)
    {
    super(p_source);
    this.m_state = p_state;
    }
  
/**
 * <p>
 * Obtain the current state of the search engine.
 * </p><p>
 * Warning: The reference to the state of the search engine is volatile.
 * The object referenced might change concurrently after the event was
 * thrown. You must process the state only inside the <code>receive</code>-
 * method of your event listener. If you need a permanent copy of the
 * event or the state, you may clone it.
 * </p>
 * @return The current state of the search engine.
 */

  public  final SearchState<Genotype> get_state()
    {
    return this.m_state;
    }
  
/**
 * Creates and returns a copy of this object.  The precise meaning 
 * of "copy" may depend on the class of the object. 
 *
 * @return     A clone of this instance.
 * 
 * @see java.lang.Cloneable
 */

  @Override
  public  final Object  clone ()
    {
    SearchUpdateEvent<Genotype> l_sue;
    
    try
      {
      l_sue         = Typesafe.cast(super.clone());
      l_sue.m_state = Typesafe.cast(l_sue.m_state.clone());
      return l_sue;
      }
    catch(Throwable l_t)
      {
      return this;
      }
    }
  

/**
 * Stores the <code>SfcEvent</code> into the stream.
 * @param p_s The output stream.
 * @throws  IOException If something io-like went wrong.
 */

  private final synchronized void writeObject(final ObjectOutputStream p_s)
        throws IOException
    {
    p_s.defaultWriteObject();    
    p_s.writeUnshared(this.m_state);
    }
  


/**
 * Reconstitute the <code>SfcEvent</code> instance from a stream (that is,
 * deserialize it).
 * @param p_s The input stream.
 * @throws  IOException If something io-like went wrong.
 * @throws  ClassNotFoundException  If a needed class could not be found.
 */

  private final void readObject(final ObjectInputStream p_s)
        throws IOException, ClassNotFoundException
    {
    p_s.defaultReadObject();
    this.m_state = Typesafe.cast(p_s.readUnshared());
    }
  }

File Information:

file name:SearchUpdateEvent.java
package:org.dgpf.search.api.events
qualified name:org.dgpf.search.api.events.SearchUpdateEvent.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/search/api/events/SearchUpdateEvent.java
size:4.993 KB (5113 B)
uploaded: 2015-07-22 04:11:00 GMT+0000
last update: 2006-07-21 12:56:54 GMT+0000
last access: 2017-11-18 06:39:54 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-19 04:51:03 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo