1// tObject.h 
2// 
3// The base class for all tScene objects. All objects have an ID, a name, and attributes. 
4// 
5// Copyright (c) 2006, 2017 Tristan Grimmer. 
6// Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby 
7// granted, provided that the above copyright notice and this permission notice appear in all copies. 
8// 
9// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 
10// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 
11// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 
12// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 
13// PERFORMANCE OF THIS SOFTWARE. 
14 
15#pragma once 
16#include <Foundation/tString.h> 
17#include <Foundation/tList.h> 
18#include <System/tChunk.h> 
19#include "Scene/tAttribute.h" 
20namespace tScene 
21
22 
23 
24class tObject 
25
26public
27 tObject() { } 
28 tObject(const tObject& src) : ID(src.ID), Name(src.Name), Attributes(src.Attributes) { } 
29 tObject(const tString& name, uint32 id) : ID(id), Name(name) { } 
30 virtual ~tObject() { } 
31 
32 virtual void Save(tChunkWriter&) const
33 virtual void Load(const tChunk&); 
34 void Clear() { ID = 0xFFFFFFFF; Name.Clear(); Attributes.Clear(); } 
35 
36 bool IsFunctionallySame(const tObject& obj) const /* Does not check name or ID. */ { return (Attributes == obj.Attributes); } 
37 bool operator==(const tObject& obj) const { return (ID == obj.ID) && (Name == obj.Name) && (Attributes == obj.Attributes); } 
38 bool operator!=(const tObject& obj) const { return !(*this == obj); } 
39 tObject& operator=(const tObject& src) { Clear(); ID = src.ID; Name = src.Name; Attributes = src.Attributes; return *this; } 
40 
41 // The ID must be unique for all objects of the same type. Zero is a valid ID. 0xFFFFFFFF is the only invalid ID. 
42 const static uint32 InvalidID = 0xFFFFFFFF
43 uint32 ID = 0xFFFFFFFF
44 tString Name
45 tAttributes Attributes
46}; 
47 
48 
49
50