1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef R2_OBJECT_FACTORY_CLIENT_H
21 #define R2_OBJECT_FACTORY_CLIENT_H
23 #include "game_share/object.h"
25 #include "nel/gui/lua_object.h"
31 /** Reference Id object on the client.
32 * This object will trigger the right events on its parent when its target is created or erased.
33 * (creation is watched too. This is possible because we use instance id, not direct pointer on the object)
35 class CObjectRefIdClient
: public CObjectRefId
, public CEditor::IInstanceObserver
38 CObjectRefIdClient(const std::string
&value
);
39 ~CObjectRefIdClient();
41 virtual bool set(const std::string
& key
, const std::string
& value
);
42 CObject
* clone() const;
43 void enable(bool enabled
);
45 // from CEditor::IInstanceObserver
46 virtual void onInstanceCreated(CInstance
&instance
);
47 virtual void onInstanceErased(CInstance
&instance
);
48 virtual void onPreHrcMove(CInstance
&instance
);
49 virtual void onPostHrcMove(CInstance
&instance
);
50 virtual void onInstanceEraseRequest(CInstance
&instance
);
51 virtual void onAttrModified(CInstance
&instance
, const std::string
&attrName
, sint32 attrIndex
);
53 // cache for the 'name' of this property in the parent
54 CEditor::TInstanceObserverHandle _ObserverHandle
;
55 mutable sint32 _IndexInParent
;
56 mutable sint32 _IndexInParentArray
;
57 mutable CInstance::TRefPtr _ParentInstance
;
60 void updateParentInstancePtr() const;
61 void getNameInParent(std::string
&name
, sint32
&indexInArray
) const;
62 void addObserverHandle();
63 void removeObserverHandle();
67 // CObjectTable on client side
68 class CObjectTableClient
: public CObjectTable
72 void pushOnLuaStack(CLuaState
&state
, CLuaObject
&metatable
) const;
73 CObject
* clone() const;
75 mutable CLuaObject _Ref
;
78 // the client factory redefine R2::CObjectRefId so that it can perform its observer job on the client
79 class CObjectFactoryClient
: public CObjectFactory
82 CObjectFactoryClient(const std::string
&prefix
);
83 // from CObjectFactory
84 virtual CObject
* newBasic(const std::string
& type
);