BTPLayer.cpp 1.1 KB
Newer Older
filatov's avatar
filatov committed
#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;