Named.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CERTI - HLA RunTime Infrastructure
00003 // Copyright (C) 2004  ONERA
00004 //
00005 // This file is part of CERTI-libCERTI
00006 //
00007 // CERTI-libCERTI is free software ; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License
00009 // as published by the Free Software Foundation ; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // CERTI-libCERTI is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY ; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015 // Lesser General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU Lesser General Public
00018 // License along with this program ; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020 // USA
00021 //
00022 // $Id: Named.cc,v 3.8 2008/11/08 00:59:38 erk Exp $
00023 // ----------------------------------------------------------------------------
00024 
00025 #include "Named.hh"
00026 
00027 namespace certi {
00028 
00029 Named::Named() { }
00030 
00031 Named::Named(std::string newName)
00032     : name(newName) { }
00033 
00034 Named::~Named() {}
00035 
00036 void
00037 Named::setName(std::string newName)
00038 {
00039     name = newName ;
00040 }
00041 
00042 void
00043 Named::setName(const char* newName) {
00044     name = newName;
00045 }
00046 
00047 const std::string&
00048 Named::getName() const
00049 {
00050     return name ;
00051 }
00052 
00053 
00054 const char *
00055 Named::getCName() const
00056 {
00057     return name.c_str();
00058 }
00059 
00060 bool
00061 Named::isNamed(const std::string &newName) const
00062 {
00063     return (name == newName);
00064 }
00065 
00066 bool
00067 Named::validateHLAName(const std::string& name) {
00068     // FIXME EN. should implement clean validation scheme
00069     // using IEEE-1516.2-2000 (ยง3.3.1 Names).
00070     return true;
00071 }
00072 
00073 bool
00074 Named::isQualifiedClassName(const std::string& name) {
00075 
00076     size_t idx = name.find_first_of('.',0);
00077     return (idx!=std::string::npos);
00078 }
00079 
00080 std::string
00081 Named::getNextClassName(std::string& qualifiedClassName) {
00082     std::string retval;
00083     size_t idx = 0;
00084     /* take the substring from start up to '.' (excluded) */
00085     idx    = qualifiedClassName.find_first_of('.',0);
00086     if (idx!=std::string::npos) {
00087         retval = qualifiedClassName.substr(0,idx);
00088         /* update the string with the remaining string */
00089         qualifiedClassName = qualifiedClassName.substr(idx+1);
00090     } else {
00091         retval = qualifiedClassName;
00092     }
00093     return retval;
00094 } /* end of getNextClassName */
00095 
00096 std::string
00097 Named::getLeafClassName(std::string qualifiedClassName) {
00098     size_t idx = 0;
00099     /* take the substring from '.' (excluded) until the end */
00100     idx    = qualifiedClassName.find_last_of('.');
00101     return qualifiedClassName.substr(idx+1);
00102 } /* end of getLeafClassName */
00103 
00104 } // certi
00105 
00106 // $Id: Named.cc,v 3.8 2008/11/08 00:59:38 erk Exp $

Generated on Thu Apr 30 15:53:49 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5