From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/agent__input_8cpp-source.html | 186 +++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 docs/doxygen/nel/agent__input_8cpp-source.html (limited to 'docs/doxygen/nel/agent__input_8cpp-source.html') diff --git a/docs/doxygen/nel/agent__input_8cpp-source.html b/docs/doxygen/nel/agent__input_8cpp-source.html new file mode 100644 index 00000000..ef212a16 --- /dev/null +++ b/docs/doxygen/nel/agent__input_8cpp-source.html @@ -0,0 +1,186 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# 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  
+

agent_input.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2001 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 #include "nel/ai/agent/agent_input.h"
+00027 
+00028 
+00029 namespace NLAIAGENT
+00030 {
+00031         IAgentInput::IAgentInput():_ActiveInput(false),_LocalValue(NULL)
+00032         {        
+00033         }
+00034 
+00035         IAgentInput::IAgentInput(IObjectIA *o):_ActiveInput(false),_LocalValue(o)
+00036         {        
+00037         }
+00038 
+00039         IAgentInput::IAgentInput(const IAgentInput &c):_ActiveInput(c._ActiveInput),_LocalValue(c._LocalValue != NULL? (IObjectIA *)c._LocalValue->clone() : NULL)
+00040         {
+00041         }
+00042 
+00043         IAgentInput::~IAgentInput()
+00044         {
+00045                 if(_LocalValue != NULL) _LocalValue->release();
+00046         }
+00047 
+00048         void IAgentInput::addInputConnection(IConnectIA* obj)
+00049         {
+00050                 _ActiveInput = true; // The Input become active when an IconnectIA is interested by the change of the value.
+00051                 connect(obj);
+00052                 _ConnexionList.push(obj);
+00053         }
+00054 
+00055         void IAgentInput::releaseInputConnexion(IConnectIA* obj)
+00056         {
+00057                 removeConnection(obj);
+00058                 _ConnexionList.erase(obj);
+00059                 if (_ConnexionList.size() == 0)
+00060                 {
+00061                         _ActiveInput = false;
+00062                 }
+00063         }
+00064 
+00065         void IAgentInput::onKill(IConnectIA* c)
+00066         {
+00067                 releaseInputConnexion(c);
+00068         }
+00069 
+00070         const IObjectIA::CProcessResult IAgentInput::runMsg(COnChangeMsg &msg)
+00071         {
+00072                 return IAgentInput::_ConnexionList.sendMessage(&msg);
+00073         }
+00074 
+00075         void IAgentInput::setValue(IObjectIA *o)
+00076         {
+00077                 if(_LocalValue != NULL) _LocalValue->release();
+00078                 _LocalValue = o;
+00079         }
+00080 
+00081         const IObjectIA::CProcessResult&  IAgentInput::run ()
+00082         {
+00083                 if (IAgentInput::_ActiveInput)
+00084                 {
+00085                         const IObjectIA* value = IAgentInput::getValue();
+00086                         if (!(*value == *_LocalValue))
+00087                         {
+00088                                 // If the component value has changed, we send a message to the list of interested IConnectIA.
+00089                                 setValue((IObjectIA*) value);
+00090                                 COnChangeMsg msg;
+00091                                 IAgentInput::_ConnexionList.sendMessage(&msg);
+00092                         }
+00093                 }
+00094                 return IObjectIA::ProcessRun;
+00095         }
+00096 
+00097         void IAgentInput::save(NLMISC::IStream &os)
+00098         {
+00099                 IConnectIA::save(os);
+00100                 os.serial(_ActiveInput);
+00101                 os.serial(_ConnexionList);
+00102         }
+00103 
+00104         void IAgentInput::load(NLMISC::IStream &is)
+00105         {
+00106                 IConnectIA::load(is);
+00107                 is.serial(_ActiveInput);
+00108                 is.serial(_ConnexionList);
+00109         }
+00110 
+00111 
+00112         bool IAgentInput::isEqual(const IBasicObjectIA &a) const
+00113         {
+00114                 if(_LocalValue != NULL) return _LocalValue->isEqual(a);
+00115                 return false;
+00116         }
+00117 } // NLAIAGENT
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1