/****************************************************************************
 * Copyright/Copyleft:
 *
 * For this source the LGPL Lesser General Public License,
 * published by the Free Software Foundation is valid.
 * It means:
 * 1) You can use this source without any restriction for any desired purpose.
 * 2) You can redistribute copies of this source to everybody.
 * 3) Every user of this source, also the user of redistribute copies
 *    with or without payment, must accept this license for further using.
 * 4) But the LPGL is not appropriate for a whole software product,
 *    if this source is only a part of them. It means, the user
 *    must publish this part of source,
 *    but don't need to publish the whole source of the own product.
 * 5) You can study and modify (improve) this source
 *    for own using or for redistribution, but you have to license the
 *    modified sources likewise under this LGPL Lesser General Public License.
 *    You mustn't delete this Copyright/Copyleft inscription in this source file.
 *
 * @author Hartmut Schorrig: hartmut.schorrig@vishia.de, www.vishia.org
 * @version 0.93 2011-01-05  (year-month-day)
 *******************************************************************************/ 
package org.vishia.bridgeC;

/**This class describes an address of any instance in memory completed with a segment info.
 * The segment may designate the are of memory, maybe in another processor connected with
 * interprocess-communication. It means, the address need not be able to access.
 * <br><br>
 * For java-usage, the address is a Object-reference always.
 * For C-usage the address is a void* respectively int.
 * @author Hartmut
 *
 */
public class MemSegmJc
{
  private Object ptr;
  private int segment;
  
  public MemSegmJc(){
  	ptr = null;
  	segment = 0;
  }
  
  public MemSegmJc(Object ptr, int segm){
    setAddrSegm(ptr, segm);
  }
  
  /**The copy constructor.
   * @param src given instance, content will be copied to the this new one.
   */
  public MemSegmJc(MemSegmJc src){
    this.ptr = src.ptr;
    this.segment = src.segment;
  }
  
  public void setAddrSegm(Object ptr, int segm){
    this.ptr = ptr;
    this.segment = segm;
  }
  
  /**The copy assignment.
   * @param src given instance, content will be copied to the this.
   */
  public void setAddrSegm(MemSegmJc src){
    this.ptr = src.ptr;
    this.segment = src.segment;
  }
  
  /**Assignment from another given instance.
   * @param src
   */
  public void set(MemSegmJc src){
  	this.ptr = src.ptr;
  	this.segment = src.segment;
  }
  
  public void setNull(){
  	this.ptr = null;
  	this.segment = 0;
  }
  
  public Object obj(){ return ptr; }
  
  public static int segment(MemSegmJc ythis){ return ythis.segment; }
  
  
}
