/* File: SimulationManagementFamily.java CVS Info: $Id: SimulationManagementFamily.java,v 1.2 1998/01/27 18:44:27 mcgredo Exp $ Compiler: jdk 1.3 */ package mil.navy.nps.dis; // package to which we belong import mil.navy.nps.util.*; // General-purpose utilities import mil.navy.nps.disEnumerations.*; // Enumerations for DIS import java.util.*; // utility stuff we need import java.io.*; // input/output for serialization /** * Abstract (uninstantiated) parent class for Simulation Management PDU family. * *@version 1.0 *@author Antonio Alexandre Rua (http://www.garfield.fe.up.pt/~alexrua) * *
sizeOf = 12 bytes
*/
public static final int sizeOf = 12;
// 12 bytes long (exclusive of ProtocolDataUnit general header data)
// stands for originatingEntityID.sizeOf()+receivingEntityID.sizeOf()
public SimulationManagementFamily() // default constructor
{
originatingEntityID = new EntityID();
receivingEntityID = new EntityID();
return;
}
public void serialize(DataOutputStream outputStream)
{
/**
Serialize our data out to the stream. We first call the superclass,
so that all the data there is written out to the buffer first.
Then we serialize each of our ivars to the stream, being careful
about the order.
*/
// takes care of all the header variables in superclass
super.serialize(outputStream);
// write out the entity IDs...
originatingEntityID.serialize(outputStream);
receivingEntityID.serialize(outputStream);
return;
}
public void deSerialize(DataInputStream inputStream)
{
/**
deserialize our data from the stream. We first call the superclass,
so that all the data there is read into the buffer first.
Then we deserialize each of our ivars from the stream, being careful
about the order.
*/
//read protocol data unit general header first
super.deSerialize(inputStream);
// Read in Entity IDs...
originatingEntityID.deSerialize(inputStream);
receivingEntityID.deSerialize(inputStream);
return;
}
public Object clone()
{
/**
Clone the SimulationManagementFamily Pdu, being careful to not share any pointers between the
new object and the old object.
*/
SimulationManagementFamily newPdu = (SimulationManagementFamily)super.clone();
newPdu.setOriginatingEntityID(this.getOriginatingEntityID());
newPdu.setReceivingEntityID(this.getReceivingEntityID());
return newPdu;
}
public int length()
{
return (super.length() + sizeOf);
}
/**
*Returns the name of this PDU
*
*@return the name of this PDU
*/
public abstract String pduName();
public void printValues(int indentLevel, PrintStream printStream)
{
int superclassIndent = indentLevel; // level of indentation for our superclass
// ugly wart: get the superclass over to the left a couple pixels, if we have any to spare,
// so the header info will be indented a bit less.
if(superclassIndent > 0)
superclassIndent -= 1;
super.printValues(superclassIndent, printStream);
originatingEntityID.printValues(indentLevel, printStream);
receivingEntityID.printValues(indentLevel, printStream);
return;
}
// Accessor methods
public EntityID getOriginatingEntityID()
{ return (EntityID)originatingEntityID.clone();
}
public void setOriginatingEntityID(EntityID pEntityID)
{ originatingEntityID = pEntityID;
}
public EntityID getReceivingEntityID()
{ return (EntityID)receivingEntityID.clone();
}
public void setReceivingEntityID(EntityID pEntityID)
{ receivingEntityID = pEntityID;
}
} // end of class SimulationManagementFamily