NeuralEngine A Game Engine with embeded Machine Learning algorithms based on Gaussian Processes. |

FgINode.h
1
11#pragma once
12
13#include <NeMachineLearningLib.h>
14#include <MachineLearning/FgIMessage.h>
15#include <set>
16#include <string>
17#include <algorithm>
18#include <MachineLearning/FgArrayFireSerialization.h>
19
20 namespace NeuralEngine
21{
22 namespace MachineLearning
23 {
33 class NE_IMPEXP INode
34 {
35 public:
36
42 INode(std::string name);
43
49 ~INode();
50
58 std::string Name();
59
67 virtual void SendMsg(std::string toNodeName);
68
77 virtual void ReceiveMsg(std::string fromNodeName, IMessage &message);
78
86 virtual void AddIncoming(INode *node);
87
95 virtual void AddOutgoing(INode *node);
96
105 virtual void AddConnection(INode *node, const std::string &tag);
106
116 virtual bool IsSupported(MsgType type) = 0;
117
125 const MsgBox& GetAllMessages() const;
126
132 void ClearMessages();
133
143 //bool operator<(INode &n);
144
154 //bool operator>(INode &n);
155
165 //bool operator<=(INode &n);
166
176 //bool operator>=(INode &n);
177
187 //bool operator!=(INode &n);
188
198 //bool operator==(INode &n);
199
200 protected:
201
210 void SetMessage(std::string fromNodeName, IMessage &msg);
211
226 virtual IMessage ComputeMessage(std::string fromNodeName, MsgBox &neededMessages) = 0;
227
228 std::map<std::string, INode*> mNodes; // dictionary of connected nodes
229 MsgBox mMessageBox; // all incomming messages
230 std::set<std::string> sIncomming; // incomming connections
231 std::set<std::string> sOutgoing; // outgoing connections
232
233 std::map<std::string, std::string> mConnections; // custom connections
234
235 private:
236 friend class boost::serialization::access;
237
238 template<class Archive>
239 void serialize(Archive& ar, unsigned int version)
240 {
241 ar& BOOST_SERIALIZATION_NVP(mNodes);
242 ar& BOOST_SERIALIZATION_NVP(sIncomming);
243 ar& BOOST_SERIALIZATION_NVP(sOutgoing);
244 ar& BOOST_SERIALIZATION_NVP(mMessageBox);
245 ar& BOOST_SERIALIZATION_NVP(sName);
246 }
247
248
249 std::string sName;
250 //int iId;
251 };
252 }
253}
NeuralEngine::MachineLearning::IMessage
Definition: FgIMessage.h:27
NeuralEngine::MachineLearning::INode
Base Class INode.
Definition: FgINode.h:34
NeuralEngine::MachineLearning::INode::SendMsg
virtual void SendMsg(std::string toNodeName)
Sends a message.
NeuralEngine::MachineLearning::INode::IsSupported
virtual bool IsSupported(MsgType type)=0
Query if message type is supported.
NeuralEngine::MachineLearning::INode::GetAllMessages
const MsgBox & GetAllMessages() const
Gets all the messages of this node.
NeuralEngine::MachineLearning::INode::SetMessage
void SetMessage(std::string fromNodeName, IMessage &msg)
Sets a incomming message from specific node.
NeuralEngine::MachineLearning::INode::INode
INode(std::string name)
Default constructor.
NeuralEngine::MachineLearning::INode::AddConnection
virtual void AddConnection(INode *node, const std::string &tag)
Adds a custom connection with the given tag.
NeuralEngine::MachineLearning::INode::~INode
~INode()
Destructor.
NeuralEngine::MachineLearning::INode::ReceiveMsg
virtual void ReceiveMsg(std::string fromNodeName, IMessage &message)
Receives a message.
NeuralEngine::MachineLearning::INode::Name
std::string Name()
Gets the name.
NeuralEngine::MachineLearning::INode::AddOutgoing
virtual void AddOutgoing(INode *node)
Adds outgoing connection to the node.
NeuralEngine::MachineLearning::INode::ClearMessages
void ClearMessages()
Clears all incomming messages for next iteration.
NeuralEngine::MachineLearning::INode::ComputeMessage
virtual IMessage ComputeMessage(std::string fromNodeName, MsgBox &neededMessages)=0
Virtual function to calculate a message to connectd node.
NeuralEngine::MachineLearning::INode::AddIncoming
virtual void AddIncoming(INode *node)
Adds ingoing connection to the node.
NeuralEngine
Definition: NeArray2.h:18