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

ArStringInfoGroup.cpp

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
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 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #include "ArExport.h"
00027 #include "ariaOSDef.h"
00028 #include "ArStringInfoGroup.h"
00029 
00030 /* 
00031    TODO the stringInt functions and such'll leak memory on a failed attempt 
00032 */
00033 
00034 AREXPORT ArStringInfoGroup::ArStringInfoGroup()
00035 {
00036 
00037 }
00038 
00039 AREXPORT ArStringInfoGroup::~ArStringInfoGroup()
00040 {
00041 
00042 }
00043 
00044 AREXPORT bool ArStringInfoGroup::addString(
00045     const char *name, ArTypes::UByte2 maxLength,
00046     ArFunctor2<char *, ArTypes::UByte2> *functor)
00047 {
00048   myDataMutex.lock();
00049   if (myAddedStrings.find(name) != myAddedStrings.end())
00050   {
00051     ArLog::log(ArLog::Normal, "ArStringInfoGroups: Cannot add info '%s', duplicate", name);
00052     myDataMutex.unlock();
00053     return false;
00054   }
00055 
00056   std::list<ArFunctor3<const char *, ArTypes::UByte2,
00057   ArFunctor2<char *, ArTypes::UByte2> *> *>::iterator it;
00058   ArLog::log(ArLog::Verbose, "ArStringInfoGroups: Adding info '%s'", name);
00059   myAddedStrings.insert(name);
00060   for (it = myAddStringCBList.begin(); it != myAddStringCBList.end(); it++)
00061   {
00062     (*it)->invoke(name, maxLength, functor);
00063   }
00064   ArLog::log(ArLog::Verbose, "ArStringInfoGroups: Added info '%s'", name);
00065   myDataMutex.unlock();
00066   return true;
00067 }
00068 
00069 AREXPORT bool ArStringInfoGroup::addStringInt(
00070     const char *name, ArTypes::UByte2 maxLength,
00071     ArRetFunctor<int> *functor, const char *format)
00072 {
00073   return addString(name, maxLength, 
00074         (new ArGlobalFunctor4<char *, ArTypes::UByte2, 
00075          ArRetFunctor<int> *, 
00076          const char *>(&ArStringInfoHolderFunctions::intWrapper, 
00077                (char *)NULL, (ArTypes::UByte2) 0, 
00078                functor, format)));
00079 }
00080 
00081 AREXPORT bool ArStringInfoGroup::addStringDouble(
00082     const char *name, ArTypes::UByte2 maxLength,
00083     ArRetFunctor<double> *functor, const char *format)
00084 {
00085   return addString(name, maxLength, 
00086         (new ArGlobalFunctor4<char *, ArTypes::UByte2, 
00087          ArRetFunctor<double> *, 
00088          const char *>(&ArStringInfoHolderFunctions::doubleWrapper, 
00089                (char *)NULL, (ArTypes::UByte2) 0, 
00090                functor, format)));
00091 }
00092 
00093 
00094 AREXPORT bool ArStringInfoGroup::addStringBool(
00095     const char *name, ArTypes::UByte2 maxLength,
00096     ArRetFunctor<bool> *functor, const char *format)
00097 {
00098   return addString(name, maxLength, 
00099         (new ArGlobalFunctor4<char *, ArTypes::UByte2, 
00100          ArRetFunctor<bool> *, 
00101          const char *>(&ArStringInfoHolderFunctions::boolWrapper, 
00102                (char *)NULL, (ArTypes::UByte2) 0, 
00103                functor, format)));
00104 }
00105 
00106 AREXPORT bool ArStringInfoGroup::addStringString(
00107     const char *name, ArTypes::UByte2 maxLength,
00108     ArRetFunctor<const char *> *functor, const char *format)
00109 {
00110   return addString(name, maxLength, 
00111         (new ArGlobalFunctor4<char *, ArTypes::UByte2, 
00112          ArRetFunctor<const char *> *, 
00113          const char *>(&ArStringInfoHolderFunctions::stringWrapper, 
00114                (char *)NULL, (ArTypes::UByte2) 0, 
00115                functor, format)));
00116 }
00117 
00118 
00119 AREXPORT void ArStringInfoGroup::addAddStringCallback(
00120     ArFunctor3<const char *, ArTypes::UByte2,
00121     ArFunctor2<char *, ArTypes::UByte2> *> *functor,
00122     ArListPos::Pos position)
00123 {
00124   if (position == ArListPos::FIRST)
00125     myAddStringCBList.push_front(functor);
00126   else if (position == ArListPos::LAST)
00127     myAddStringCBList.push_back(functor);
00128   else
00129     ArLog::log(ArLog::Terse, 
00130            "ArStringInfoGroup::addAddStringCallback: Invalid position.");
00131 }

Generated on Tue Feb 20 10:51:41 2007 for Aria by  doxygen 1.4.0