Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArActionGroup.cpp

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #include "ArExport.h"
00028 #include "ariaOSDef.h"
00029 #include "ArActionGroup.h"
00030 #include "ArAction.h"
00031 #include "ArRobot.h"
00032 #include "ArLog.h"
00033 
00042 ArActionGroup::ArActionGroup(ArRobot *robot)
00043 {
00044   myRobot = robot;
00045 }
00046 
00047 ArActionGroup::~ArActionGroup()
00048 {
00049   removeActions();
00050 }
00051 
00052 
00058 void ArActionGroup::addAction(ArAction *action, int priority)
00059 {
00060   if (myRobot == NULL)
00061   {
00062     ArLog::log(ArLog::Terse, 
00063             "ArActionGroup::addAction: NULL robot pointer... failed.");
00064     return;
00065   }
00066   myActions.push_front(action);
00067   myRobot->addAction(action, priority);
00068 }
00069 
00074 void ArActionGroup::remAction(ArAction *action)
00075 {
00076   if (myRobot == NULL)
00077   {
00078     ArLog::log(ArLog::Terse, 
00079             "ArActionGroup::remAction: NULL robot pointer... failed.");
00080     return;
00081   }
00082   myActions.remove(action);
00083   myRobot->remAction(action);
00084 }
00085 
00086 void ArActionGroup::activate(void)
00087 {
00088   std::list<ArAction *>::iterator it;
00089   if (myRobot == NULL)
00090   {
00091     ArLog::log(ArLog::Terse, 
00092             "ArActionGroup::activate: NULL robot pointer... failed.");
00093     return;
00094   }
00095   for (it = myActions.begin(); it != myActions.end(); it++)
00096     (*it)->activate();
00097 }
00098 
00099 void ArActionGroup::activateExclusive(void)
00100 {
00101   std::list<ArAction *>::iterator it;
00102   
00103   if (myRobot == NULL)
00104   {
00105     ArLog::log(ArLog::Terse, 
00106             "ArActionGroup::activateExclusive: NULL robot pointer... failed.");
00107     return;
00108   }
00109   myRobot->deactivateActions();
00110   for (it = myActions.begin(); it != myActions.end(); it++)
00111     (*it)->activate();
00112 }
00113 
00114 void ArActionGroup::deactivate(void)
00115 {
00116   std::list<ArAction *>::iterator it;
00117   if (myRobot == NULL)
00118   {
00119     ArLog::log(ArLog::Terse, 
00120             "ArActionGroup::deactivate: NULL robot pointer... failed.");
00121     return;
00122   }
00123   myRobot->deactivateActions();
00124   for (it = myActions.begin(); it != myActions.end(); it++)
00125     (*it)->deactivate();
00126 }
00127 
00128 std::list<ArAction *> *ArActionGroup::getActionList(void)
00129 {
00130   return &myActions;
00131 }
00132 
00133 void ArActionGroup::removeActions(void)
00134 {
00135   std::list<ArAction *>::iterator it;
00136 
00137   if (myRobot == NULL)
00138   {
00139     ArLog::log(ArLog::Terse, 
00140             "ArActionGroup::removeActions: NULL robot pointer... very bad.");
00141     return;
00142   }
00143 
00144   for (it = myActions.begin(); it != myActions.end(); ++it)
00145     myRobot->remAction((*it));
00146 }
00147 

Generated on Wed Oct 19 12:56:34 2005 for Aria by  doxygen 1.4.0