virtual DataType type() const = 0;Return the type of the particle. DataType is actually just a typedef for
constchar*, but when we use DataType, we treat it as an abstract type. Furthermore, two DataType values are considered the same if they compare equal, which means that we must assure that the same string is always used to represent a given type.
virtual operator int () const = 0;These are the virtual casting functions, which convert the data in the Particle into the desired form. The arithmetic Particles support all these functions cleanly. Message particles may return errors for some of these functions (they must return a value, but may also call
virtual operator float () const = 0;
virtual operator double () const = 0;
virtual operator Complex () const = 0;
virtual StringList print () const = 0;Return a printable representation of the Particle's data.
virtual void initialize() = 0;This function zeros the Particle (where this makes sense), or initializes it to some default value.
virtual void operator << (int arg) = 0;These functions are, in a sense, the inverses of the virtual casting operators. They load the particle with data from
virtual void operator << (double arg) = 0;
virtual void operator << (const Complex& arg) = 0;
arg,performing the appropriate type conversion.
virtual Particle& operator = (const Particle& arg) = 0;Copy a Particle. In general, we permit this only for Particles of the same type, and otherwise assert an error. But the arithmetic particle types invoke type conversion, via the virtual casting operators, so as to allow assignment from other arithmetic particle types. Without this exception, useful cases such as forking an INT output to INT and FLOAT inputs would fail in the simulation domains (because the fork stars use particle assignment).
virtual int operator == (const Particle&) = 0;Compare two particles. As a rule, Particles will be equal only if they have the same type, and, in a sense that is separately determined for each type, the same value.
virtual Particle* clone() const = 0;Produce a second, identical particle (as a rule, one is obtained from the Plasma for the particle if possible).
virtual Particle* useNew() const = 0;This is similar to
clone,except that the particle is allocated from the heap rather than from the Plasma.
virtual void die() = 0;Return the Particle to its Plasma.
virtual void getMessage (Envelope&);These functions are used to implement the Message interface. The default implementation returns errors for them; it is only if the Particle is really a MessageParticle that they successfully send or receive a Message from the Particle.
virtual void accessMessage (Envelope&) const;
virtual void operator << (const Envelope&);