convert line ends
[canaan.git] / prj / cam / src / object / propman_.h
blob9c654d44f210beb93d5e48cd135f3af11540a5b7
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/object/propman_.h,v 1.18 2000/01/29 13:24:39 adurant Exp $
7 #pragma once
9 #ifndef PROPMAN__H
10 #define PROPMAN__H
13 #include <objtype.h>
14 #include <lgassert.h>
15 #include <dynarray.h>
16 #include <hashset.h>
17 #include <str.h>
18 #include <aggmemb.h>
20 #include <dbasemsg.h>
22 #include <appagg.h>
23 #include <propman.h>
25 class cNullProperty;
27 typedef cDynArray<IProperty*> PropArray;
28 typedef cDynArray<PropertyID> PropIDArray;
31 ////////////////////////////////////////////////////////////
33 // cPropertyManager
35 // The cPropertyManager is the one place that knows about all the
36 // properties. Only it has the ability to do things like iterate over
37 // all properties, etc.
39 ////////////////////////////////////////////////////////////
42 class cPropertyManager : public IPropertyManager
44 // Hash table mapping strings to Properties
45 class cPropertyTable : public cStrIHashSet <IProperty *>
47 public:
48 cPropertyTable () {};
49 tHashSetKey GetKey (tHashSetNode node) const
51 return (tHashSetKey) (((IProperty *) (node))->Describe()->name);
56 // We're going to be an aggregate member when we grow up
57 DECLARE_AGGREGATION(cPropertyManager);
59 public:
60 cPropertyManager (IUnknown* outer); // constructor
61 virtual ~cPropertyManager (); // destructor
63 // Find the Property with a given name, can return NULL
64 STDMETHOD_(IProperty *,GetProperty) (PropertyID id) const;
65 STDMETHOD_(IProperty *,GetPropertyNamed) (const char* name) const;
68 // Notify the property system of an event
69 STDMETHOD(Notify)(ePropertyNotifyMsg msg, PropNotifyData data);
71 // Iteration functions
72 STDMETHOD(BeginIter)(struct sPropertyIter* iter);
73 STDMETHOD_(IProperty*,NextIter)(struct sPropertyIter* iter);
75 //------------------------------------------------------------
76 // Property system internal methods
79 public:
80 // Add a Property to the list being managed, return success
81 // Sets id to be unique
82 STDMETHOD_(BOOL,AddProperty)(IProperty *prop, PropertyID *id);
84 // Remove a Property from the list being managed, return success
85 STDMETHOD_(BOOL,DelProperty)(IProperty *prop);
87 // Lookups that don't bump refcount
88 IProperty* ByID (PropertyID id) const;
89 IProperty* ByName (const char* name) const;
91 private:
92 // Called when a property message is recieved. Will be sent to appropriate prop for handling.
93 static void NetworkMessageCallback(const sNetMsg_Generic *pMsg, ulong size, ObjID from, void *pClientData);
95 // Code shared by AddProperty and AddMetaProperty
96 BOOL AddPropertyBase (IProperty * prop);
98 //----------------------------------------
99 // Aggregate protocol
102 HRESULT Init();
103 HRESULT End();
106 // Data members
109 cPropertyTable name_hash_; // mapping of names to Properties
110 PropArray props_; // mapping of IDs to properties
111 PropIDArray sort_order_; // constrained sort order.
112 PropIDArray begin_create_; // props that need begin create
113 PropIDArray end_create_; // props that need end create
114 PropIDArray load_obj_; // props that need load obj
116 cNullProperty* nullprop_;
117 BOOL props_sorted_; // is sort_order valid?
121 #endif // PROPMAN__H