Files
TeslaRel410/CODE/RP/MUNGA/SCHAIN.HPP
T
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

325 lines
9.0 KiB
C++

//===========================================================================//
// File: schain.hh //
// Project: MUGNA Brick: Connection engine //
// Contents: Interface definition for safe chains //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 09/29/94 ECH Initial coding. //
// 11/01/94 JMA Made compatible with SGI CC, merged with iterator //
// 11/03/94 ECH Made compatible with BC4.0 //
// 11/05/94 JMA Made compatible with GNU C++ //
// 12/12/94 ECH Changed release mechanism //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(SCHAIN_HPP)
# define SCHAIN_HPP
# if !defined(SFESKT_HPP)
# include <sfeskt.hpp>
# endif
# if !defined(MEMBLOCK_HPP)
# include <memblock.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SChainLink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SCHAINLINK_MEMORYBLOCK_ALLOCATION (100)
class SChainLink:
public Link
{
friend class SChain;
friend class SChainIterator;
public:
~SChainLink();
Logical
TestInstance() const;
private:
SChainLink(
SChain *chain,
Plug *plug,
SChainLink *nextSChainLink,
SChainLink *prevSChainLink
);
SChainLink *nextSChainLink;
SChainLink *prevSChainLink;
private:
static MemoryBlock
AllocatedMemory;
void*
operator new(size_t)
{return AllocatedMemory.New();}
void
operator delete(void *where)
{AllocatedMemory.Delete(where);}
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SChain ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class SChain:
public SafeSocket
{
friend class SChainLink;
friend class SChainIterator;
public:
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// Public interface
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//
SChain(Node *node);
~SChain();
Logical
TestInstance() const;
static void
TestClass();
static void
ProfileClass();
protected:
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// Protected interface
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
//
void
AddImplementation(Plug *plug);
private:
//
//-----------------------------------------------------------------------
// Private utilities
//-----------------------------------------------------------------------
//
SChainLink*
InsertSChainLink(
Plug *plug,
SChainLink *link
);
//
//-----------------------------------------------------------------------
// Private data
//-----------------------------------------------------------------------
//
SChainLink *head;
SChainLink *tail;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SChainOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T> class SChainOf:
public SChain
{
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
SChainOf(Node *node);
~SChainOf();
//
//--------------------------------------------------------------------
// Socket methods (see Socket for full listing)
//--------------------------------------------------------------------
//
void
Add(T plug)
{AddImplementation(Cast_Object(Plug*,plug));}
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ SChainOf templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T>
SChainOf<T>::SChainOf(Node *node):
SChain(node)
{
}
template <class T>
SChainOf<T>::~SChainOf()
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SChainIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class SChainIterator:
public SafeIterator
{
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
//
//--------------------------------------------------------------------
// Constructors, Destructor and testing
//--------------------------------------------------------------------
//
SChainIterator(SChain *chain);
SChainIterator(const SChainIterator &iterator);
~SChainIterator();
Logical
TestInstance() const;
//
//--------------------------------------------------------------------
// Iterator methods (see Iterator for full listing)
//--------------------------------------------------------------------
//
void
First();
void
Last();
void
Next();
void
Previous();
CollectionSize
GetSize();
void
Remove();
protected:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Protected interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void*
ReadAndNextImplementation();
void*
ReadAndPreviousImplementation();
void*
GetCurrentImplementation();
void*
GetNthImplementation(
CollectionSize index
);
void
InsertImplementation(Plug *plug);
private:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Private interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void
ReceiveMemo(
IteratorMemo memo,
void *content
);
//
//--------------------------------------------------------------------
// Private data
//--------------------------------------------------------------------
//
SChainLink *currentLink;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SChainIteratorOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T> class SChainIteratorOf:
public SChainIterator
{
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
//
//--------------------------------------------------------------------
// Constructors and Destructor
//--------------------------------------------------------------------
//
SChainIteratorOf(SChainOf<T> *chain);
SChainIteratorOf(SChainOf<T> &chain);
SChainIteratorOf(const SChainIteratorOf<T> &iterator);
~SChainIteratorOf();
//
//--------------------------------------------------------------------
// 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);}
void
Insert(T plug)
{InsertImplementation(Cast_Object(Plug*,plug));}
};
//~~~~~~~~~~~~~~~~~~~~~~~ SChainIteratorOf templates ~~~~~~~~~~~~~~~~~~~~~~~
template <class T>
SChainIteratorOf<T>::SChainIteratorOf(SChainOf<T> *chain):
SChainIterator(chain)
{
}
template <class T>
SChainIteratorOf<T>::SChainIteratorOf(SChainOf<T> &chain):
SChainIterator(&chain)
{
}
template <class T>
SChainIteratorOf<T>::SChainIteratorOf(const SChainIteratorOf<T> &iterator):
SChainIterator(iterator)
{
}
template <class T>
SChainIteratorOf<T>::~SChainIteratorOf()
{
}
#endif