# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

object_ident.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 
00027 #ifndef NL_OBJECT_IDENT_H
00028 #define NL_OBJECT_IDENT_H
00029 #include <stdlib.h>
00030 #include "nel/misc/file.h"
00031 #include "nel/ai/e/ai_exception.h" 
00032 #include "nel/ai/agent/ident.h"
00033 #include "nel/ai/agent/agent_object.h"
00034 
00035 namespace NLAIAGENT
00036 {
00037         class CObjectIdent : public IObjectIA
00038         {
00039         public:
00040                 static const NLAIC::CIdentType *IdObjectIdent;
00041         private:
00042                 CNumericIndex _Id;
00043         public:
00044                 CObjectIdent(const CObjectIdent &o) : _Id(o._Id)
00045                 {
00046                 }
00047 
00048                 CObjectIdent(const CNumericIndex &id):_Id(id)
00049                 {
00050                 }
00051         
00052                 CObjectIdent(const char *id):_Id(id)
00053                 {
00054                 }
00055 
00056                 CObjectIdent(const CStringType &id):_Id(id.getStr().getString())
00057                 {
00058                 }
00059 
00060                 CObjectIdent(NLMISC::IStream &is):_Id(is)
00061                 {
00062                 }
00063 
00064                 virtual ~CObjectIdent()
00065                 {
00066                 }
00067 
00068                 const CNumericIndex &getId() const
00069                 {
00070                         return _Id;
00071                 }
00072                 
00073                 void getDebugString(std::string &text) const
00074                 {
00075                         _Id.getDebugString(text);
00076                 }
00077 
00078                 const NLAIC::IBasicType *clone() const
00079                 {                       
00080                         return new CObjectIdent(*this);
00081                 }               
00082 
00083                 const NLAIC::IBasicType *newInstance() const
00084                 {
00085                         return clone();
00086                 }
00087                 
00088                 const NLAIC::CIdentType &getType() const
00089                 {
00090                         return *IdObjectIdent;
00091                 }
00092 
00093                 void save(NLMISC::IStream &os)
00094                 {                                               
00095                         _Id.save(os);
00096                 }
00097 
00098                 void load(NLMISC::IStream &is)
00099                 {                                               
00100                         _Id.load(is);                   
00101                 }
00102                 
00103                 bool isEqual(const IBasicObjectIA &a) const
00104                 {
00105                         const CObjectIdent &t = (const CObjectIdent &)a;
00106                         return t._Id == _Id;
00107                 }
00108                 
00109                 const CProcessResult &run()
00110                 {
00111                         return IObjectIA::ProcessRun;
00112                 }
00113 
00114         };
00115 }
00116 #endif