Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

sceneeffector.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003 this file is part of rcssserver3D
00004 Fri May 9 2003
00005 Copyright (C) 2002,2003 Koblenz University
00006 Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007 $Id: sceneeffector.cpp,v 1.1 2004/05/06 09:30:25 rollmark Exp $
00008 
00009 This program is free software; you can redistribute it and/or modify
00010 it under the terms of the GNU General Public License as published by
00011 the Free Software Foundation; version 2 of the License.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with this program; if not, write to the Free Software
00020 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 
00023 #include "sceneeffector.h"
00024 #include "sceneaction.h"
00025 #include <zeitgeist/logserver/logserver.h>
00026 #include <oxygen/gamecontrolserver/actionobject.h>
00027 #include <oxygen/agentaspect/agentaspect.h>
00028 
00029 using namespace boost;
00030 using namespace oxygen;
00031 using namespace zeitgeist;
00032 using namespace std;
00033 
00034 SceneEffector::SceneEffector() : oxygen::Effector()
00035 {
00036 }
00037 
00038 SceneEffector::~SceneEffector()
00039 {
00040 }
00041 
00042 bool SceneEffector::Realize(boost::shared_ptr<ActionObject> action)
00043 {
00044     shared_ptr<SceneAction> sceneAction =
00045         shared_dynamic_cast<SceneAction>(action);
00046 
00047     if (sceneAction.get() == 0)
00048         {
00049             GetLog()->Error()
00050                 << "(SceneEffector) ERROR: cannot realize "
00051                 << "an unknown ActionObject\n";
00052             return false;
00053         }
00054 
00055     boost::shared_ptr<AgentAspect> aspect =GetAgentAspect();
00056 
00057     if (aspect.get() == 0)
00058         {
00059             GetLog()->Error()
00060                 << "(SceneEffector) ERROR: cannot get AgentAspect\n";
00061             return false;
00062         }
00063 
00064     aspect->ImportScene(sceneAction->GetScene(), shared_ptr<ParameterList>());
00065     return true;
00066 }
00067 
00068 shared_ptr<ActionObject>
00069 SceneEffector::GetActionObject(const Predicate& predicate)
00070 {
00071     if (predicate.name != GetPredicate())
00072         {
00073             GetLog()->Error() << "(SceneEffector) ERROR: invalid predicate"
00074                               << predicate.name << "\n";
00075             return shared_ptr<ActionObject>();
00076         }
00077 
00078     string scene;
00079     if (! predicate.GetValue(predicate.begin(), scene))
00080         {
00081             GetLog()->Error()
00082                 << "ERROR: (SceneEffector) scene filename expected\n";
00083             return shared_ptr<ActionObject>();
00084         };
00085 
00086     return shared_ptr<ActionObject>(new SceneAction(GetPredicate(),scene));
00087 }
00088 
00089 

Generated on Thu Apr 6 15:25:39 2006 for rcssserver3d by  doxygen 1.4.4