2008-01-17 23:31:07 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2008 Alistair Riddoch
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
|
2009-03-22 15:44:54 +00:00
|
|
|
#ifndef COMMON_ROUTER_H
|
|
|
|
|
#define COMMON_ROUTER_H
|
2008-01-17 23:31:07 +00:00
|
|
|
|
|
|
|
|
#include "OperationRouter.h"
|
|
|
|
|
|
|
|
|
|
#include <string>
|
2009-08-22 02:57:33 +01:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
namespace Atlas {
|
|
|
|
|
namespace Message {
|
|
|
|
|
class Element;
|
|
|
|
|
typedef std::map<std::string, Element> MapType;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-01-17 23:31:07 +00:00
|
|
|
|
2012-12-04 20:39:35 +00:00
|
|
|
class Link;
|
|
|
|
|
|
2008-01-17 23:31:07 +00:00
|
|
|
/// \brief This is the base class for any entity which has an Atlas
|
2015-05-05 22:01:11 +02:00
|
|
|
/// compatible identifier.
|
2008-01-17 23:31:07 +00:00
|
|
|
///
|
2009-02-02 Al Riddoch <alriddoch@googlemail.com>
* common/Identified.cpp, common/Identified.h:
Flatten down the base classes into one called Router.
* client/CharacterClient.cpp, client/CreatorClient.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp,
rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/LocatedEntity.cpp, rulesets/MemEntity.cpp,
rulesets/Plant.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp,
server/Connection.cpp, server/ExternalMind.cpp,
server/Lobby.cpp, server/Master.cpp,
server/Peer.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/SlaveClientConnection.cpp,
server/TrustedConnection.cpp, tests/LocatedEntitytest.cpp,
tests/ThingupdatePropertiestest.cpp: Update all the operation
routing classes to use the modified base class correctly.
2009-02-02 02:28:45 +00:00
|
|
|
class Router {
|
2008-01-17 23:31:07 +00:00
|
|
|
private:
|
|
|
|
|
/// \brief String identifier
|
|
|
|
|
const std::string m_id;
|
|
|
|
|
/// \brief Integer identifier
|
|
|
|
|
const long m_intId;
|
|
|
|
|
protected:
|
2009-02-02 Al Riddoch <alriddoch@googlemail.com>
* common/Identified.cpp, common/Identified.h:
Flatten down the base classes into one called Router.
* client/CharacterClient.cpp, client/CreatorClient.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp,
rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/LocatedEntity.cpp, rulesets/MemEntity.cpp,
rulesets/Plant.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp,
server/Connection.cpp, server/ExternalMind.cpp,
server/Lobby.cpp, server/Master.cpp,
server/Peer.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/SlaveClientConnection.cpp,
server/TrustedConnection.cpp, tests/LocatedEntitytest.cpp,
tests/ThingupdatePropertiestest.cpp: Update all the operation
routing classes to use the modified base class correctly.
2009-02-02 02:28:45 +00:00
|
|
|
explicit Router(const std::string & id, long intId);
|
2008-01-17 23:31:07 +00:00
|
|
|
public:
|
2018-02-06 10:26:54 +01:00
|
|
|
Router(const Router &) = delete;
|
2009-02-02 Al Riddoch <alriddoch@googlemail.com>
* common/Identified.cpp, common/Identified.h:
Flatten down the base classes into one called Router.
* client/CharacterClient.cpp, client/CreatorClient.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp,
rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/LocatedEntity.cpp, rulesets/MemEntity.cpp,
rulesets/Plant.cpp, rulesets/Stackable.cpp,
rulesets/Thing.cpp, rulesets/World.cpp,
server/Account.cpp, server/Admin.cpp,
server/Connection.cpp, server/ExternalMind.cpp,
server/Lobby.cpp, server/Master.cpp,
server/Peer.cpp, server/Player.cpp,
server/ServerRouting.cpp, server/SlaveClientConnection.cpp,
server/TrustedConnection.cpp, tests/LocatedEntitytest.cpp,
tests/ThingupdatePropertiestest.cpp: Update all the operation
routing classes to use the modified base class correctly.
2009-02-02 02:28:45 +00:00
|
|
|
virtual ~Router();
|
2008-01-17 23:31:07 +00:00
|
|
|
|
|
|
|
|
/// \brief Read only accessor for string identity
|
|
|
|
|
const std::string & getId() const {
|
|
|
|
|
return m_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// \brief Read only accessor for Integer identity
|
|
|
|
|
long getIntId() const {
|
|
|
|
|
return m_intId;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-21 12:43:42 +00:00
|
|
|
void buildError(const Operation &,
|
|
|
|
|
const std::string & errstring,
|
|
|
|
|
const Operation &,
|
|
|
|
|
const std::string & to) const;
|
2008-01-17 23:31:07 +00:00
|
|
|
void error(const Operation &, const std::string & errstring, OpVector &,
|
|
|
|
|
const std::string & to = "") const;
|
|
|
|
|
void clientError(const Operation &, const std::string & errstring,
|
|
|
|
|
OpVector &, const std::string & to = "") const;
|
|
|
|
|
|
2012-12-04 20:39:35 +00:00
|
|
|
virtual void externalOperation(const Operation & op, Link &) = 0;
|
2008-01-28 Al Riddoch <alriddoch@googlemail.com>
* client/BaseClient.cpp, common/BaseEntity.cpp, common/BaseEntity.h,
common/Identified.cpp, common/Identified.h, common/Makefile.am,
common/OOGThing.cpp, common/OOGThing.h, common/OperationRouter.cpp,
common/OperationRouter.h, rulesets/Character.h, rulesets/Entity.h,
rulesets/LocatedEntity.cpp, rulesets/LocatedEntity.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/CommClient.cpp, server/CommClient.h, server/Connection.cpp,
server/Connection.h, server/ExternalMind.cpp, server/ExternalMind.h,
server/ExternalProperty.cpp, server/ExternalProperty.h,
server/Lobby.cpp, server/Lobby.h, server/Master.cpp, server/Master.h,
server/Peer.cpp, server/Peer.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/SlaveClientConnection.cpp,
server/SlaveClientConnection.h: Factor out the more pointless base
classes, in favor of simple interface. Move destroyed signal to
Entity, which is the only place it is needed.
2008-01-28 23:48:30 +00:00
|
|
|
virtual void operation(const Operation &, OpVector &) = 0;
|
2012-11-13 23:33:23 +00:00
|
|
|
|
2008-01-28 Al Riddoch <alriddoch@googlemail.com>
* client/BaseClient.cpp, common/BaseEntity.cpp, common/BaseEntity.h,
common/Identified.cpp, common/Identified.h, common/Makefile.am,
common/OOGThing.cpp, common/OOGThing.h, common/OperationRouter.cpp,
common/OperationRouter.h, rulesets/Character.h, rulesets/Entity.h,
rulesets/LocatedEntity.cpp, rulesets/LocatedEntity.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/CommClient.cpp, server/CommClient.h, server/Connection.cpp,
server/Connection.h, server/ExternalMind.cpp, server/ExternalMind.h,
server/ExternalProperty.cpp, server/ExternalProperty.h,
server/Lobby.cpp, server/Lobby.h, server/Master.cpp, server/Master.h,
server/Peer.cpp, server/Peer.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/SlaveClientConnection.cpp,
server/SlaveClientConnection.h: Factor out the more pointless base
classes, in favor of simple interface. Move destroyed signal to
Entity, which is the only place it is needed.
2008-01-28 23:48:30 +00:00
|
|
|
virtual void addToMessage(Atlas::Message::MapType &) const;
|
|
|
|
|
virtual void addToEntity(const Atlas::Objects::Entity::RootEntity &) const;
|
2012-11-21 11:03:53 +00:00
|
|
|
|
|
|
|
|
friend class Routertest;
|
2008-01-18 15:26:44 +00:00
|
|
|
};
|
|
|
|
|
|
2009-03-22 15:44:54 +00:00
|
|
|
#endif // COMMON_ROUTER_H
|