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
20namespace NeuralEngine
21{
22 namespace MachineLearning
23 {
33 class NE_IMPEXP INode
34 {
35 public:
36
42 INode(std::string name);
43
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
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}
virtual void SendMsg(std::string toNodeName)
Sends a message.
virtual bool IsSupported(MsgType type)=0
Query if message type is supported.
const MsgBox & GetAllMessages() const
Gets all the messages of this node.
void SetMessage(std::string fromNodeName, IMessage &msg)
Sets a incomming message from specific node.
INode(std::string name)
Default constructor.
virtual void AddConnection(INode *node, const std::string &tag)
Adds a custom connection with the given tag.
virtual void ReceiveMsg(std::string fromNodeName, IMessage &message)
Receives a message.
std::string Name()
Gets the name.
virtual void AddOutgoing(INode *node)
Adds outgoing connection to the node.
void ClearMessages()
Clears all incomming messages for next iteration.
virtual IMessage ComputeMessage(std::string fromNodeName, MsgBox &neededMessages)=0
Virtual function to calculate a message to connectd node.
virtual void AddIncoming(INode *node)
Adds ingoing connection to the node.