Skip to content

Commit

Permalink
Delete redundant typedefs, rename client/sever base class aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Dec 13, 2015
1 parent c08c870 commit 56ea0a6
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 71 deletions.
15 changes: 4 additions & 11 deletions src/xrServerEntities/object_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@
class CObjectFactory {
public:
#ifndef NO_XR_GAME
typedef ObjectFactory::CLIENT_BASE_CLASS CLIENT_BASE_CLASS;
using ClientObjectBaseClass = ObjectFactory::ClientObjectBaseClass;
#endif
typedef ObjectFactory::SERVER_BASE_CLASS SERVER_BASE_CLASS;

#ifndef NO_XR_GAME
typedef ObjectFactory::CLIENT_SCRIPT_BASE_CLASS CLIENT_SCRIPT_BASE_CLASS;
#endif
typedef ObjectFactory::SERVER_SCRIPT_BASE_CLASS SERVER_SCRIPT_BASE_CLASS;
using ServerObjectBaseClass = ObjectFactory::ServerObjectBaseClass;

protected:
struct CObjectItemPredicate {
Expand Down Expand Up @@ -76,11 +71,9 @@ class CObjectFactory {
virtual ~CObjectFactory ();
void init ();
#ifndef NO_XR_GAME
IC CLIENT_BASE_CLASS *client_object (const CLASS_ID &clsid) const;
IC SERVER_BASE_CLASS *server_object (const CLASS_ID &clsid, LPCSTR section) const;
#else
IC SERVER_BASE_CLASS *server_object (const CLASS_ID &clsid, LPCSTR section) const;
inline ClientObjectBaseClass *client_object(const CLASS_ID &clsid) const;
#endif
inline ServerObjectBaseClass *server_object(const CLASS_ID &clsid, LPCSTR section) const;

IC int script_clsid (const CLASS_ID &clsid) const;
void register_script () const;
Expand Down
10 changes: 5 additions & 5 deletions src/xrServerEntities/object_factory_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ template <typename _client_type, typename _server_type>
IC void CObjectFactory::add (const CLASS_ID &clsid, LPCSTR script_clsid)
{
{
typedef object_type_traits::is_base_and_derived<CLIENT_BASE_CLASS,_client_type> a;
typedef object_type_traits::is_base_and_derived<ClientObjectBaseClass,_client_type> a;
STATIC_CHECK (a::value,Client_class_must_be_derived_from_the_CLIENT_BASE_CLASS);
}
{
typedef object_type_traits::is_base_and_derived<SERVER_BASE_CLASS,_server_type> a;
typedef object_type_traits::is_base_and_derived<ServerObjectBaseClass,_server_type> a;
STATIC_CHECK (a::value,Server_class_must_be_derived_from_the_SERVER_BASE_CLASS);
}
add (xr_new<CObjectItemClientServer<_client_type,_server_type> >(clsid,script_clsid));
Expand All @@ -39,15 +39,15 @@ template <typename _unknown_type>
IC void CObjectFactory::add (const CLASS_ID &clsid, LPCSTR script_clsid)
{
{
typedef object_type_traits::is_base_and_derived<CLIENT_BASE_CLASS,_unknown_type> a;
typedef object_type_traits::is_base_and_derived<SERVER_BASE_CLASS,_unknown_type> b;
typedef object_type_traits::is_base_and_derived<ClientObjectBaseClass,_unknown_type> a;
typedef object_type_traits::is_base_and_derived<ServerObjectBaseClass,_unknown_type> b;
STATIC_CHECK (a::value || b::value,Class_must_be_derived_from_the_CLIENT_BASE_CLASS_or_SERVER_BASE_CLASS);
}
add (
xr_new<
CObjectItemSingle<
_unknown_type,
object_type_traits::is_base_and_derived<CLIENT_BASE_CLASS,_unknown_type>::value
object_type_traits::is_base_and_derived<ClientObjectBaseClass,_unknown_type>::value
>
>
(clsid,script_clsid)
Expand Down
15 changes: 7 additions & 8 deletions src/xrServerEntities/object_factory_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,21 @@ IC int CObjectFactory::script_clsid (const CLASS_ID &clsid) const
}

#ifndef NO_XR_GAME
IC CObjectFactory::CLIENT_BASE_CLASS *CObjectFactory::client_object (const CLASS_ID &clsid) const
inline CObjectFactory::ClientObjectBaseClass *CObjectFactory::client_object (const CLASS_ID &clsid) const
{
return (item(clsid).client_object());
}
#endif

IC CObjectFactory::SERVER_BASE_CLASS *CObjectFactory::server_object (const CLASS_ID &clsid, LPCSTR section) const
inline CObjectFactory::ServerObjectBaseClass *CObjectFactory::server_object (const CLASS_ID &clsid, LPCSTR section) const
{
#ifndef NO_XR_GAME
return (item(clsid).server_object(section));
}
#else
IC CObjectFactory::SERVER_BASE_CLASS *CObjectFactory::server_object (const CLASS_ID &clsid, LPCSTR section) const
{
const CObjectItemAbstract *object = item(clsid,true);
return (object ? object->server_object(section) : 0);
}
const CObjectItemAbstract *object = item(clsid, true);
return (object ? object->server_object(section) : 0);
#endif
}

IC void CObjectFactory::actualize () const
{
Expand Down
21 changes: 6 additions & 15 deletions src/xrServerEntities/object_factory_space.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,19 @@
// Description : Object factory space
////////////////////////////////////////////////////////////////////////////

#ifndef object_factory_spaceH
#define object_factory_spaceH

#pragma once

#ifndef XRGAME_EXPORTS
# define NO_XR_GAME
#define NO_XR_GAME
#endif

class IFactoryObject;
class CSE_Abstract;

namespace ObjectFactory {

#ifndef NO_XR_GAME
typedef IFactoryObject CLIENT_BASE_CLASS;
#endif
typedef CSE_Abstract SERVER_BASE_CLASS;

namespace ObjectFactory
{
#ifndef NO_XR_GAME
typedef IFactoryObject CLIENT_SCRIPT_BASE_CLASS;
using ClientObjectBaseClass = IFactoryObject;
#endif
typedef CSE_Abstract SERVER_SCRIPT_BASE_CLASS;
using ServerObjectBaseClass = CSE_Abstract;
};

#endif
4 changes: 2 additions & 2 deletions src/xrServerEntities/object_item_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CObjectItemAbstract {
IC const CLASS_ID &clsid () const;
IC shared_str script_clsid () const;
#ifndef NO_XR_GAME
virtual ObjectFactory::CLIENT_BASE_CLASS *client_object () const = 0;
virtual ObjectFactory::ClientObjectBaseClass *client_object() const = 0;
#endif
virtual ObjectFactory::SERVER_BASE_CLASS *server_object (LPCSTR section) const = 0;
virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const = 0;
};

#include "object_item_abstract_inline.h"
Expand Down
8 changes: 4 additions & 4 deletions src/xrServerEntities/object_item_client_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class CObjectItemClientServer : public CObjectItemAbstract {
public:
IC CObjectItemClientServer (const CLASS_ID &clsid, LPCSTR script_clsid);
#ifndef NO_XR_GAME
virtual ObjectFactory::CLIENT_BASE_CLASS *client_object () const;
virtual ObjectFactory::ClientObjectBaseClass *client_object() const;
#endif
virtual ObjectFactory::SERVER_BASE_CLASS *server_object (LPCSTR section) const;
virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const;
};

#ifndef NO_XR_GAME
Expand All @@ -36,8 +36,8 @@ class CObjectItemClientServer : public CObjectItemAbstract {
typedef CObjectItemAbstract inherited;
public:
IC CObjectItemClientServerSingleMp (const CLASS_ID &clsid, LPCSTR script_clsid);
virtual ObjectFactory::CLIENT_BASE_CLASS *client_object () const;
virtual ObjectFactory::SERVER_BASE_CLASS *server_object (LPCSTR section) const;
virtual ObjectFactory::ClientObjectBaseClass *client_object() const;
virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const;
};
#endif // NO_XR_GAME

Expand Down
14 changes: 7 additions & 7 deletions src/xrServerEntities/object_item_client_server_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ IC CSObjectItemClientServer::CObjectItemClientServer (const CLASS_ID &clsid, LPC

#ifndef NO_XR_GAME
TEMPLATE_SPECIALIZATION
ObjectFactory::CLIENT_BASE_CLASS *CSObjectItemClientServer::client_object () const
ObjectFactory::ClientObjectBaseClass *CSObjectItemClientServer::client_object () const
{
return (xr_new<CLIENT_TYPE>()->_construct());
}
#endif

TEMPLATE_SPECIALIZATION
ObjectFactory::SERVER_BASE_CLASS *CSObjectItemClientServer::server_object (LPCSTR section) const
ObjectFactory::ServerObjectBaseClass *CSObjectItemClientServer::server_object (LPCSTR section) const
{
ObjectFactory::SERVER_BASE_CLASS * o = xr_new<SERVER_TYPE>(section)->init();
ObjectFactory::ServerObjectBaseClass * o = xr_new<SERVER_TYPE>(section)->init();
R_ASSERT (o);
return (o);
}
Expand All @@ -50,9 +50,9 @@ ObjectFactory::SERVER_BASE_CLASS *CSObjectItemClientServer::server_object (LPCST
}

TEMPLATE_SPECIALIZATION
ObjectFactory::CLIENT_BASE_CLASS *CSObjectItemClientServerSingleMp::client_object () const
ObjectFactory::ClientObjectBaseClass *CSObjectItemClientServerSingleMp::client_object () const
{
ObjectFactory::CLIENT_BASE_CLASS *result =
ObjectFactory::ClientObjectBaseClass *result =
IsGameTypeSingle() ?
xr_new<_client_type_single>() :
xr_new<_client_type_mp>();
Expand All @@ -61,9 +61,9 @@ ObjectFactory::SERVER_BASE_CLASS *CSObjectItemClientServer::server_object (LPCST
}

TEMPLATE_SPECIALIZATION
ObjectFactory::SERVER_BASE_CLASS *CSObjectItemClientServerSingleMp::server_object (LPCSTR section) const
ObjectFactory::ServerObjectBaseClass *CSObjectItemClientServerSingleMp::server_object (LPCSTR section) const
{
ObjectFactory::SERVER_BASE_CLASS *result =
ObjectFactory::ServerObjectBaseClass *result =
IsGameTypeSingle() ?
xr_new<_server_type_single>(section) :
xr_new<_server_type_mp>(section);
Expand Down
14 changes: 7 additions & 7 deletions src/xrServerEntities/object_item_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#ifndef NO_XR_GAME
# include "attachable_item.h"

ObjectFactory::CLIENT_BASE_CLASS *CObjectItemScript::client_object () const
ObjectFactory::ClientObjectBaseClass *CObjectItemScript::client_object () const
{
ObjectFactory::CLIENT_SCRIPT_BASE_CLASS *object = nullptr;
ObjectFactory::ClientObjectBaseClass *object = nullptr;
try {
object = m_client_creator();
}
Expand All @@ -29,9 +29,9 @@ ObjectFactory::CLIENT_BASE_CLASS *CObjectItemScript::client_object () const

#endif

ObjectFactory::SERVER_BASE_CLASS *CObjectItemScript::server_object (LPCSTR section) const
ObjectFactory::ServerObjectBaseClass *CObjectItemScript::server_object (LPCSTR section) const
{
ObjectFactory::SERVER_BASE_CLASS *object = nullptr;
ObjectFactory::ServerObjectBaseClass *object = nullptr;

try {
object = m_server_creator(section);
Expand All @@ -46,9 +46,9 @@ ObjectFactory::SERVER_BASE_CLASS *CObjectItemScript::server_object (LPCSTR secti
}

R_ASSERT (object);
ObjectFactory::SERVER_BASE_CLASS *o = object->init();
R_ASSERT (o);
return (o);
object = object->init();
R_ASSERT (object);
return (object);
}

CObjectItemScript::CObjectItemScript (
Expand Down
8 changes: 4 additions & 4 deletions src/xrServerEntities/object_item_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class CObjectItemScript : public CObjectItemAbstract {
typedef CObjectItemAbstract inherited;

protected:
mutable luabind::functor<ObjectFactory::CLIENT_BASE_CLASS *, luabind::policy::adopt<0>> m_client_creator;
mutable luabind::functor<ObjectFactory::SERVER_BASE_CLASS *, luabind::policy::adopt<0>> m_server_creator;
mutable luabind::functor<ObjectFactory::ClientObjectBaseClass *, luabind::policy::adopt<0>> m_client_creator;
mutable luabind::functor<ObjectFactory::ServerObjectBaseClass *, luabind::policy::adopt<0>> m_server_creator;

public:
CObjectItemScript (
Expand All @@ -35,7 +35,7 @@ class CObjectItemScript : public CObjectItemAbstract {
const CLASS_ID &clsid,
LPCSTR script_clsid
);
virtual ObjectFactory::CLIENT_BASE_CLASS *client_object () const;
virtual ObjectFactory::ClientObjectBaseClass *client_object() const;
#endif
virtual ObjectFactory::SERVER_BASE_CLASS *server_object (LPCSTR section) const;
virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const;
};
8 changes: 4 additions & 4 deletions src/xrServerEntities/object_item_single.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CObjectItemSingle : public CObjectItemAbstract {
public:
IC CObjectItemSingle (const CLASS_ID &clsid, LPCSTR script_clsid);
#ifndef NO_XR_GAME
virtual ObjectFactory::CLIENT_BASE_CLASS *client_object () const;
virtual ObjectFactory::ClientObjectBaseClass *client_object() const;
#endif
virtual ObjectFactory::SERVER_BASE_CLASS *server_object (LPCSTR section) const;
virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const;
};

#ifndef NO_XR_GAME
Expand All @@ -37,8 +37,8 @@ class CObjectItemSingle<_unknown_type,true> : public CObjectItemAbstract {

public:
IC CObjectItemSingle (const CLASS_ID &clsid, LPCSTR script_clsid);
virtual ObjectFactory::CLIENT_BASE_CLASS *client_object () const;
virtual ObjectFactory::SERVER_BASE_CLASS *server_object (LPCSTR section) const;
virtual ObjectFactory::ClientObjectBaseClass *client_object() const;
virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const;
};
#endif

Expand Down
8 changes: 4 additions & 4 deletions src/xrServerEntities/object_item_single_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ IC CSObjectItemSingle::CObjectItemSingle (const CLASS_ID &clsid, LPCSTR script_c

#ifndef NO_XR_GAME
TEMPLATE_SPECIALIZATION
ObjectFactory::CLIENT_BASE_CLASS *CSObjectItemSingle::client_object () const
ObjectFactory::ClientObjectBaseClass *CSObjectItemSingle::client_object () const
{
FATAL ("Cannot instantiate client object, because client class is not declared!");
return (0);
}
#endif

TEMPLATE_SPECIALIZATION
ObjectFactory::SERVER_BASE_CLASS *CSObjectItemSingle::server_object (LPCSTR section) const
ObjectFactory::ServerObjectBaseClass *CSObjectItemSingle::server_object (LPCSTR section) const
{
return (xr_new<SERVER_TYPE>(section)->init());
}
Expand All @@ -43,13 +43,13 @@ IC CObjectItemSingle<_unknown_type,true>::CObjectItemSingle (const CLASS_ID &cls
}

template <typename _unknown_type>
ObjectFactory::CLIENT_BASE_CLASS *CObjectItemSingle<_unknown_type,true>::client_object () const
ObjectFactory::ClientObjectBaseClass *CObjectItemSingle<_unknown_type,true>::client_object () const
{
return (xr_new<CLIENT_TYPE>()->_construct());
}

template <typename _unknown_type>
ObjectFactory::SERVER_BASE_CLASS *CObjectItemSingle<_unknown_type,true>::server_object (LPCSTR section) const
ObjectFactory::ServerObjectBaseClass *CObjectItemSingle<_unknown_type,true>::server_object (LPCSTR section) const
{
FATAL ("Cannot instantiate server object, because server class is not declared!");
return (0);
Expand Down

0 comments on commit 56ea0a6

Please sign in to comment.