cyphesis/rulesets/AtlasProperties.cpp
Al Riddoch e51e78927b 2007-01-03 Al Riddoch <alriddoch@zepler.org>
* rulesets/AtlasProperties.cpp, rulesets/AtlasProperties.h:
	  Add 3 custom property classes used to handle very commonly
	  used properties that are hard coded in Atlas more efficiently.

	* rulesets/Entity.cpp: Use the new performance property code in
	  Entity.
2007-01-03 21:55:30 +00:00

69 lines
2 KiB
C++

// Cyphesis Online RPG Server and AI Engine
// Copyright (C) 2007 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
// $Id: AtlasProperties.cpp,v 1.1 2007-01-03 21:55:31 alriddoch Exp $
#include "AtlasProperties.h"
#include "Entity.h"
#include "common/type_utils.h"
#include "common/debug.h"
#include <Atlas/Objects/SmartPtr.h>
#include <Atlas/Objects/RootEntity.h>
#include <cassert>
static const bool debug_flag = false;
using Atlas::Objects::Entity::RootEntity;
IdProperty::IdProperty(const std::string & data) :
ImmutableProperty<std::string>(data)
{
}
void IdProperty::add(const std::string & s, const RootEntity & ent) const
{
ent->setId(m_data);
}
NameProperty::NameProperty(std::string & data, unsigned int flags) :
Property<std::string>(data, flags)
{
}
void NameProperty::add(const std::string & s, const RootEntity & ent) const
{
ent->setName(m_data);
}
ContainsProperty::ContainsProperty(EntitySet & data) :
ImmutableProperty<EntitySet>(data)
{
}
void ContainsProperty::add(const std::string & s, const RootEntity & ent) const
{
std::list<std::string> & contains = ent->modifyContains();
contains.clear();
EntitySet::const_iterator Iend = m_data.end();
for (EntitySet::const_iterator I = m_data.begin(); I != Iend; ++I) {
contains.push_back((*I)->getId());
}
}