# 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  

interpret_object_agent.h

Go to the documentation of this file.
00001 
00006 /* Copyright, 2000 Nevrax Ltd.
00007  *
00008  * This file is part of NEVRAX NEL.
00009  * NEVRAX NEL 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; either version 2, or (at your option)
00012  * any later version.
00013 
00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * General Public License for more details.
00018 
00019  * You should have received a copy of the GNU General Public License
00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00022  * MA 02111-1307, USA.
00023  */
00024 #ifndef NL_INTERPRET_OBJECT_AGENT_H
00025 #define NL_INTERPRET_OBJECT_AGENT_H
00026 #include "nel/ai/script/interpret_object.h"
00027 #include "nel/ai/agent/msg.h"
00028 #include "nel/ai/script/codage.h"
00029 
00030 namespace NLAIAGENT {
00031         class CAgentScript;
00032 };
00033 
00034 namespace NLAISCRIPT
00035 {
00046         class IAgentMultiClass: public IClassInterpret
00047         {
00048         private:
00050                 sint32  _BaseMethodCount;
00052                 NLAIAGENT::IObjectIA *_BaseObjectInstance;
00053         public:
00054 
00055                 //IAgentMultiClass(NLAIAGENT::IObjectIA *b);
00056                 
00057 
00058                 IAgentMultiClass()
00059                 {
00060                 }
00061                 virtual ~IAgentMultiClass()
00062                 {
00063                 }
00065                 sint32 getBaseMethodCount() const
00066                 {
00067                         return _BaseMethodCount;
00068                 }
00069 
00071                 void setBaseMethodCount(sint32 n)
00072                 {
00073                         _BaseMethodCount = n;
00074                 }
00075 
00077                 NLAIAGENT::IObjectIA *getBaseObjectInstance() const
00078                 {
00079                         return _BaseObjectInstance;
00080                 }
00081 
00083                 void setBaseObjectInstance(NLAIAGENT::IObjectIA *o)
00084                 {
00085                         _BaseObjectInstance = o;
00086                 }
00087         };
00088 
00089         
00101         class CAgentClass: public IAgentMultiClass
00102         {
00103         public:
00104                 struct CMethodType
00105                 {
00106                         CMethodeName    *Method;
00107                         bool                    DefineInBaseClass;
00108                         
00109                         CMethodType()
00110                         {
00111                                 Method = NULL;
00112                                 DefineInBaseClass = true;
00113                         }
00114 
00115                         CMethodType(const CMethodType &m)
00116                         {
00117                                 Method = m.Method;
00118                                 if(Method != NULL) Method->incRef();
00119                                 DefineInBaseClass = m.DefineInBaseClass;
00120                         }
00121 
00122                         CMethodType &operator = (const CMethodType &m)
00123                         {
00124                                 Method = m.Method;
00125                                 if(Method != NULL) Method->incRef();
00126                                 DefineInBaseClass = m.DefineInBaseClass;
00127                                 return *this;
00128                         }
00129 
00130                         CMethodType(CMethodeName *m)
00131                         {
00132                                 Method = m;
00133                                 DefineInBaseClass = true;
00134                         }
00135 
00136                         virtual ~CMethodType()
00137                         {
00138                                 if(Method != NULL) Method->release();
00139                         }
00140 
00141                         const bool &isBasedOnBaseClass() const
00142                         {
00143                                 return DefineInBaseClass;
00144                         }
00145 
00146                         void setMethodBasedOnBaseClassState(bool b)
00147                         {
00148                                 DefineInBaseClass = b;
00149                         }
00150                 };
00151         public:
00152                 static const NLAIC::CIdentType IdAgentClass;
00153         private:
00154                 std::vector<CComponent *> _Components;
00155                 std::vector<NLAIAGENT::IObjectIA *> _StaticComponents;
00156 
00157                 typedef std::vector<CMethodType>        tVectorMethode;
00158                 tVectorMethode                                          _Methode;
00159                 std::vector<const CAgentClass  *>       _VTable;
00160                 std::vector<sint32 *>                           _MsgIndirectTable;
00161                 sint32 _lastRef;                
00162                 sint32 _RunIndex;
00163                 const IClassInterpret                                           *_Base_class;
00164 //              sint32 _NbScriptedComponents;           // Number of static components which are interpreted object (which means derived from CAgentScript)
00165         private:                        
00166                 NLAIAGENT::IVarName *_Inheritance;              
00167 
00168                 bool isMessageFunc(const CParam &) const;
00169                 void clearIndirectMsgTable();
00170         public:
00171 
00172                 CAgentClass(const NLAIAGENT::IVarName &);
00173                 CAgentClass(const NLAIAGENT::IVarName &, const NLAIAGENT::IVarName &);
00174                 CAgentClass(const CAgentClass &);
00175                 CAgentClass(const NLAIC::CIdentType &);
00176                 CAgentClass();
00177                 virtual ~CAgentClass();
00178 
00179                 virtual NLAIAGENT::IObjectIA *buildNewInstance() const;
00180                 virtual const NLAIC::IBasicType *clone() const;
00181                 virtual const NLAIC::IBasicType *newInstance() const;
00182                 virtual void getDebugString(std::string &) const;
00183                 virtual void save(NLMISC::IStream &);
00184                 virtual void load(NLMISC::IStream &);
00185                 virtual const NLAIAGENT::IObjectIA::CProcessResult &run();
00186                 virtual bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00187 
00188 
00190                 virtual sint32 registerComponent(const NLAIAGENT::IVarName &type_name);
00191                 virtual sint32 registerComponent(const NLAIAGENT::IVarName &type_name, const NLAIAGENT::CStringVarName &field_name);
00194                 virtual CComponent *getComponent(sint32 i) const;
00197                 virtual CComponent *getComponent(const NLAIAGENT::IVarName &name) const;
00198                 virtual sint32 getComponentIndex(const NLAIAGENT::IVarName &) const;
00199 //              virtual sint32 getInheritedComponentIndex(const NLAIAGENT::IVarName &name) const;
00200 
00203                 virtual sint32 getStaticMemberIndex(const NLAIAGENT::IVarName &) const;         
00204                 virtual const NLAIAGENT::IObjectIA *getStaticMember(sint32) const; //throw Exc::IException &
00206                 virtual sint32 getStaticMemberSize() const;
00207                 sint32 getInheritedStaticMemberIndex(const NLAIAGENT::IVarName &) const;
00208                 
00209 
00211                 virtual void createComponents(std::list<NLAIAGENT::IObjectIA *> &) const;
00213                 virtual void createBaseClassComponents(std::list<NLAIAGENT::IObjectIA *> &) const;
00215                 virtual const char *getComponentName(sint32) const;
00216                 
00218 
00219                 virtual sint32 addBrancheCode(const NLAIAGENT::IVarName &,const CParam &);
00220                 virtual CMethodeName &getBrancheCode() const; 
00221                 virtual CMethodeName &getBrancheCode(sint32) const;
00222                 virtual CMethodeName &getBrancheCode(sint32, sint32) const;
00223                 virtual sint32 getBrancheCodeSize() const;
00224                 virtual NLAIAGENT::tQueue isMember(const NLAIAGENT::IVarName *className,const NLAIAGENT::IVarName *methodName,const NLAIAGENT::IObjectIA &param) const;
00225                 virtual NLAIAGENT::tQueue getPrivateMember(const NLAIAGENT::IVarName *,const NLAIAGENT::IVarName *,const NLAIAGENT::IObjectIA &) const;
00226                 virtual sint32 getMethodIndexSize() const;              
00227                 virtual sint32 getRunMethod() const;
00228                 virtual void setRunMethod(sint32 index);
00230                                 
00232 
00233                 virtual void buildVTable();
00234                 virtual void buildVMethode();           
00235                 virtual sint32 sizeVTable() const;
00236                 void buildChildsMessageMap();
00237 //              void buildChildsMessageMap(CAgentClass *);
00238 //              void buildChildMsgPath( CAgentClass *father_class = NULL );
00239 
00241                 
00243 
00244                 virtual sint32 isClassInheritedFrom(const NLAIAGENT::IVarName &) const;
00245                 const NLAIAGENT::IVarName *getInheritanceName() const;                                  
00246                 void setInheritanceName(const NLAIAGENT::IVarName &name);                               
00247                 virtual const IClassInterpret *getBaseClass() const;                                    
00248                 const CAgentClass *getSuperClass() const;                                                               
00249                 const void getClassPath(std::vector<const CAgentClass *> &path) const;  
00250                 sint32 getNbBaseClass() const;                                                                                  
00251                 virtual const IClassInterpret *getComputeBaseClass();
00253 
00255                 virtual const IClassInterpret *getInheritance(sint32 n) const;
00256 
00257                 sint32 findMethod(const NLAIAGENT::IVarName &name,const CParam &CParam) const;
00258 
00259                 virtual sint32 getChildMessageIndex(const NLAIAGENT::IMessageBase *, sint32);
00260 
00261                 // Static components 
00262                 virtual void initStatics();
00263                 virtual bool setStaticMember(sint32, NLAIAGENT::IObjectIA *);
00264                 virtual void updateStaticMember(sint32, NLAIAGENT::IObjectIA *);
00265                 virtual NLAIAGENT::IObjectIA *getStaticComponentValue(std::string &);
00266 
00267                 virtual NLAIC::CTypeOfObject getTypeClass() const               
00268                 {
00269                         uint b = NLAIC::CTypeOfObject::tObject | NLAIC::CTypeOfObject::tAgent;
00270                         return NLAIC::CTypeOfObject((uint)IClassInterpret::getTypeClass() | b);
00271                 }
00272         };
00273 }
00274 #endif