Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "BTPLayer.h"
#include "BTPPort.h"
void BTPLayer::sendMsg(const BTPA& m, const Params& params){
OCTETSTRING data;
_a.encode(m, data);
sendData(data, Params());
}
void BTPLayer::sendMsg(const BTPB& m, const Params& params){
OCTETSTRING data;
_b.encode(m, data);
sendData(data, Params());
}
void BTPLayer::sendData(const OCTETSTRING& data, const Params& params){
sendToAllLayers(data, params);
}
void BTPLayer::receiveData(const OCTETSTRING& data, const Params& info)
{
BTPB b;
BTPA a;
receiveToAllPorts(a, Params());
receiveToAllPorts(b, Params());
receiveToAllLayers(data, Params()); //a.payload shall be sent!
}
class BTPFactory : public LayerFactory {
static BTPFactory _f;
public:
BTPFactory();
virtual Layer * createLayer(const std::string & type, const std::string & param);
};
BTPFactory::BTPFactory()
{
StackFactory::getInstance()->registerLayerFactory("BTP", this);
// register factory
}
Layer * BTPFactory::createLayer(const std::string & type, const std::string & param)
{
return new BTPLayer();
}
BTPFactory BTPFactory::_f;