Files
CydandClaude Fable 5 fdd9ac9d97 Initial import: Tesla Release 4.10 (Tesla:BattleTech & Tesla:Red Planet)
Archival snapshot of the Virtual World Entertainment Tesla cockpit
software, 1994-1996: MUNGA engine and L4 pod layer source (Borland
C++ 5.0), BT/RP game code, and game content (models, audio, maps,
gauges, Division renderer data). Includes third-party libraries:
Division dVS/DPL graphics, HMI SOS audio, WATTCP networking.

Files are preserved byte-for-byte (.gitattributes disables all
line-ending conversion). README.md documents the layout, target
hardware, and toolchain.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 13:21:58 -05:00

384 lines
11 KiB
C++

//===========================================================================//
// File: plug.hpp //
// Project: MUNGA Brick: Connection Library //
// Contents: Interface specifications for plugs and their iterators //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- -----------------------------------------------------------//
// 10/19/94 ECH Initial coding. //
// 10/20/94 JMA Fixed style stuff, merged PLGITR.HPP, added Remove() to //
// PlugIterator //
// 10/23/94 ECH Added greater deletion safety //
// 10/28/94 JMA Made compatible with SGI CC //
// 11/02/94 ECH Restored base ReceivePlugCommand //
// 11/03/94 ECH Made compatible with BC4.0 //
// 11/08/94 JMA Made compatible with GNU C++ //
// 11/29/94 JMA Changed ClassIdentity to ClassID //
// 11/30/94 JMA Adapted to style changes //
// 12/06/94 JMA Made virtual data publicly visible //
// 12/12/94 ECH Removed release handler //
// 02/16/95 ECH Removed plug commands, added node command //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(PLUG_HPP)
# define PLUG_HPP
# if !defined(VDATA_HPP)
# include <vdata.hpp>
# endif
# if !defined(ITERATOR_HPP)
# include <iterator.hpp>
# endif
# if !defined(LINK_HPP)
# include <link.hpp>
# endif
class PlugStream;
//
//--------------------------------------------------------------------
// Node Commands - start at zero, inherited commands start with
// Node::NextCommand
//--------------------------------------------------------------------
//
typedef Enumeration NodeCommandID;
enum
{
NodeNullCommandID = 0,
NodeNextCommandID
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Plug ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class PlugIterator;
class Plug :
public RegisteredClass
{
friend class Link;
friend class PlugIterator;
public:
//
//--------------------------------------------------------------------
// Destructor and instance testing
//--------------------------------------------------------------------
//
~Plug();
Logical
TestInstance() const;
protected:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Protected interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
Plug(ClassID class_id = TrivialPlugClassID);
Plug(PlugStream *stream);
private:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Private data
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
Link *linkHead;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PlugOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T> class PlugOf:
public Plug
{
public:
//
//--------------------------------------------------------------------
// Constructor, Destructor
//--------------------------------------------------------------------
//
PlugOf(const T &item);
~PlugOf();
//
//--------------------------------------------------------------------
// Can cast to the type
//--------------------------------------------------------------------
//
operator T() const
{return item;}
//
//--------------------------------------------------------------------
// Accessors
//--------------------------------------------------------------------
//
T
GetItem() const
{return item;}
T*
GetPointer()
{return &item;}
private:
//
//--------------------------------------------------------------------
// Private data
//--------------------------------------------------------------------
//
T item;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PlugOf templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T>
PlugOf<T>::PlugOf(const T &the_item)
{
item = the_item;
}
template <class T>
PlugOf<T>::~PlugOf()
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ PlugIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class PlugIterator:
public Iterator
{
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
//
//--------------------------------------------------------------------
// Constructor, Destructor & testing
//--------------------------------------------------------------------
//
PlugIterator(
const Plug *plug,
RegisteredClass::ClassID class_to_iterate=RegisteredClass::NullClassID
);
PlugIterator(const PlugIterator &iterator);
~PlugIterator();
Logical
TestInstance() const;
//
//--------------------------------------------------------------------
// Iterator methods (see Iterator for full listing)
//--------------------------------------------------------------------
//
void
First();
void
Last();
void
Next();
void
Previous();
CollectionSize
GetSize();
void
Remove();
//
//--------------------------------------------------------------------
// SendNodeCommand - Send a command and related info to all nodes,
// returns when all nodes receive command or until
// receive method returns non-zero. If the receive
// returns non-zero, then the iterator will remain
// at that plug.
//--------------------------------------------------------------------
//
int
SendNodeCommand(
NodeCommandID node_command,
void *info = NULL
);
//
//--------------------------------------------------------------------
// RemoveSocket - Removes this plug from the specified socket.
//--------------------------------------------------------------------
//
void
RemoveSocket(Socket *socket);
protected:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Protected interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void*
ReadAndNextImplementation();
void*
ReadAndPreviousImplementation();
void*
GetCurrentImplementation();
void*
GetNthImplementation(CollectionSize index);
protected:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Protected data
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
const Plug
*plug;
Link
*currentLink;
private:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Private
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
RegisteredClass::ClassID
classToIterate;
void
NextNode();
void
PreviousNode();
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~ PlugIteratorOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T> class PlugIteratorOf:
public PlugIterator
{
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
//
//--------------------------------------------------------------------
// Constructor, Destructors
//--------------------------------------------------------------------
//
PlugIteratorOf(
const Plug *plug,
RegisteredClass::ClassID class_to_iterate=RegisteredClass::NullClassID
);
PlugIteratorOf(
const Plug &plug,
RegisteredClass::ClassID class_to_iterate=RegisteredClass::NullClassID
);
PlugIteratorOf(const PlugIteratorOf<T> &iterator);
~PlugIteratorOf();
//
//--------------------------------------------------------------------
// Iterator methods (see Iterator for full listing)
//--------------------------------------------------------------------
//
T
ReadAndNext()
{return (T)ReadAndNextImplementation();}
T
ReadAndPrevious()
{return (T)ReadAndPreviousImplementation();}
T
GetCurrent()
{return (T)GetCurrentImplementation();}
T
GetNth(CollectionSize index)
{return (T)GetNthImplementation(index);}
#if 0
//
//---------------------------------------------------
// Operators useful when it is known that the iterator
// is a PlugIteratorOf<> Iterator
//---------------------------------------------------
//
Logical
operator!()
{return currentLink == NULL;}
operator T()
{return GetCurrent();}
T
operator->()
{return GetCurrent();}
PlugIteratorOf<T>&
operator++()
{Next(); return *this;}
PlugIteratorOf<T>&
operator--()
{Previous(); return *this;}
T
operator++(int)
{return ReadAndNext();}
T
operator--(int)
{return ReadAndPrevious();}
#endif
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~ PlugIteratorOf templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T>
PlugIteratorOf<T>::PlugIteratorOf(
const Plug *plug,
RegisteredClass::ClassID class_to_iterate
):
PlugIterator(plug, class_to_iterate)
{
}
template <class T>
PlugIteratorOf<T>::PlugIteratorOf(
const Plug &plug,
RegisteredClass::ClassID class_to_iterate
):
PlugIterator(&plug, class_to_iterate)
{
}
template <class T>
PlugIteratorOf<T>::PlugIteratorOf(const PlugIteratorOf<T> &iterator):
PlugIterator(iterator)
{
}
template <class T>
PlugIteratorOf<T>::~PlugIteratorOf()
{
}
#endif