Base class for classes with non-standard packing and unpacking.
This class is the base class for all data, you want to transmit,
for which there are no standard Register ()-Calls (see
Struct). For all types, that can be registered via
Register()-Calls, there are functions called Pack
(const Type &) and Unpack (type), which can be used in the
Pack () and UnPack ()-methods of Custom. You can also use
this mechanism, if you want to transmit data "compressed". For
example you could have a huge array, that is mostly used with
little data:
struct MyHugeArray : public Pvm::Custom
{
int Size;
int Huge[100000];
void Pack () const
{
Pvm::Pack (Size);
for (int i = 0; i < Size; ++i)
Pvm::Pack (Huge[i]);
}
void UnPack ()
{
Pvm::Unpack (Size);
for (int i = 0; i < Size; ++i)
Pvm::Unpack (Huge[i]);
}
};
struct Test : public Pvm::Struct
{
PvmSetStructId (43);
PvmRegistration ()
{
Pvm::Register (Data);
}
MyHugeArray Data;
};
int
main ()
{
Test A;
A.Data.Size = 3;
A.Data.Huge[ 0 ] = 4;
A.Data.Huge[ 1 ] = 8;
A.Data.Huge[ 2 ] = 16;
A.Send (Pvm::Pvm ().I ().Parent ()); // Only 4 ints are sent, not 100001 !
}