Torque3D Documentation / _generateds / nodeListManager.h

nodeListManager.h

Engine/source/environment/nodeListManager.h

More...

Classes:

Detailed Description

Public Variables

NodeListManager * gClientNodeListManager 
NodeListManager * gServerNodeListManager 
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _NODELISTMANAGER_H_
 25#define _NODELISTMANAGER_H_
 26
 27#ifndef _TVECTOR_H_
 28#include "core/util/tVector.h"
 29#endif
 30#ifndef _MPOINT3_H_
 31#include "math/mPoint3.h"
 32#endif
 33#ifndef _MQUAT_H_
 34#include "math/mQuat.h"
 35#endif
 36#ifndef _NETCONNECTION_H_
 37#include "sim/netConnection.h"
 38#endif
 39
 40//-----------------------------------------------------------------------------
 41
 42class NodeListNotify;
 43
 44class NodeListManager
 45{
 46public:
 47   
 48   struct NodeList
 49   {
 50      U32   mId;
 51      U32   mTotalValidNodes;
 52      bool  mListComplete;
 53
 54      NodeList() { mId = 0; mTotalValidNodes = 0; mListComplete = false; }
 55      virtual ~NodeList() { }
 56   };
 57
 58   static U32 smMaximumNodesPerEvent;
 59
 60protected:
 61   bool  mIsServer;
 62   U32   mNextListId;
 63
 64   Vector<NodeList*>       mNodeLists;
 65   Vector<NodeListNotify*> mNotifyList;
 66
 67public:
 68   NodeListManager( const bool isServer );
 69   ~NodeListManager();
 70
 71   void clearNodeLists();
 72
 73   U32 nextListId();
 74
 75   void addNodeList( NodeList* list );
 76
 77   bool findListById( U32 id, NodeList** list, bool completeOnly=true );
 78
 79   void clearNotification( U32 listId );
 80   void clearAllNotifications();
 81   void registerNotification( NodeListNotify* notify );
 82   bool dispatchNotification( U32 listId );
 83   bool dispatchNotification( NodeList* list );
 84};
 85
 86extern NodeListManager* gClientNodeListManager;
 87extern NodeListManager* gServerNodeListManager;
 88
 89//-----------------------------------------------------------------------------
 90
 91class NodeListNotify
 92{
 93protected:
 94   U32  mListId;
 95
 96public:
 97   NodeListNotify() { mListId = 0; }
 98   virtual ~NodeListNotify() { }
 99
100   U32 getListId() { return mListId; }
101
102   virtual void sendNotification( NodeListManager::NodeList* list ) { }
103};
104
105//-----------------------------------------------------------------------------
106
107class NodeListEvent : public NetEvent
108{
109   typedef NetEvent Parent;
110
111public:
112   U32         mId;
113   U32         mTotalNodes;
114   U32         mLocalListStart;
115
116   NodeListManager::NodeList* mNodeList;
117
118public:
119   NodeListEvent() { mId = 0; mNodeList = NULL; mTotalNodes = mLocalListStart = 0; }
120   virtual ~NodeListEvent();
121
122   virtual void pack(NetConnection*, BitStream*);
123   virtual void write(NetConnection*, BitStream*);
124   virtual void unpack(NetConnection*, BitStream*);
125   virtual void process(NetConnection*);
126   virtual void mergeLists(NodeListManager::NodeList* oldList);
127
128   virtual void copyIntoList(NodeListManager::NodeList* copyInto) { }
129   virtual void padListToSize() { }
130
131   DECLARE_CONOBJECT(NodeListEvent);
132};
133
134#endif   // _NODELISTMANAGER_H_
135