//===========================================================================// // File: entity2.cc // // Project: MUNGA Brick: Entity Manager // // Contents: Implementation details of the entity class // //---------------------------------------------------------------------------// // Date Who Modification // // -------- --- ---------------------------------------------------------- // // 11/29/94 JMA Initial coding. // //---------------------------------------------------------------------------// // Copyright (C) 1994-1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #include #pragma hdrstop #if !defined(ENTITYID_HPP) # include #endif //############################################################################# //############################# EntityID ################################ //############################################################################# EntityID EntityID::Null; EntityID::LocalID EntityID::LocalNull = 0; #if defined(USE_SIGNATURE) int Is_Signature_Bad(const volatile EntityID *) { return False; } #endif //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID::EntityID(): hostID(NullHostID), localID(LocalNull) { } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID::EntityID(const EntityID &entityID): hostID(entityID.hostID), localID(entityID.localID) { } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID::EntityID(HostID hostID) { this->hostID = hostID; this->localID = LocalNull; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID::EntityID( HostID hostID, LocalID localID ) { this->hostID = hostID; this->localID = localID; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Logical EntityID::TestInstance() const { return True; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID& EntityID::operator=(const EntityID &entityID) { hostID = entityID.hostID; localID = entityID.localID; return *this; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID& EntityID::operator+=(const EntityID &entityID) { Check(this); Check(&entityID); hostID += entityID.hostID; localID += entityID.localID; return *this; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID EntityID::operator-(const EntityID &entityID) const { Check(this); Check(&entityID); return EntityID( (HostID)(hostID - entityID.hostID), (HostID)(localID - entityID.localID) ); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID& EntityID::operator-=(const EntityID &entityID) { Check(this); Check(&entityID); hostID -= entityID.hostID; localID -= entityID.localID; return *this; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID& EntityID::operator+=(LocalID i) { Check(this); localID += i; return *this; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID& EntityID::operator-=(LocalID i) { Check(this); localID -= i; return *this; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Logical EntityID::operator<(const EntityID &entityID) const { return (hostID == entityID.hostID) ? (localID < entityID.localID) : (hostID < entityID.hostID); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Logical EntityID::operator<=(const EntityID &entityID) const { return (hostID == entityID.hostID) ? (localID <= entityID.localID) : (hostID < entityID.hostID); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Logical EntityID::operator>(const EntityID &entityID) const { return (hostID == entityID.hostID) ? (localID > entityID.localID) : (hostID > entityID.hostID); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Logical EntityID::operator>=(const EntityID &entityID) const { return (hostID == entityID.hostID) ? (localID >= entityID.localID) : (hostID > entityID.hostID); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Logical EntityID::operator==(const EntityID &entityID) const { return (hostID == entityID.hostID && localID == entityID.localID); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Logical EntityID::operator!=(const EntityID &entityID) const { return (hostID != entityID.hostID || localID != entityID.localID); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EntityID::operator int() const { return int(localID); }