Ejemplo n.º 1
0
RegionImpl* RegionImplFactory::deserializeRegionImpl(const std::string nodeType, 
                                                     BundleIO& bundle,
                                                     Region* region)
{

  RegionImpl *mn = NULL;

  if (nodeType == "TestNode")
  {
    mn = new TestNode(bundle, region);
  } else if (nodeType == "VectorFileEffector")
  {
    mn = new VectorFileEffector(bundle, region);
  } else if (nodeType == "VectorFileSensor")
  {
    mn = new VectorFileSensor(bundle, region);
  } else if (StringUtils::startsWith(nodeType, "py."))
  {
    if (!pyLib_)
      pyLib_ = boost::shared_ptr<DynamicPythonLibrary>(new DynamicPythonLibrary());
    
    mn = deserializePyNode(pyLib_.get(), nodeType, bundle, region);
  } else
  {
    NTA_THROW << "Unsupported node type '" << nodeType << "'";
  }
  return mn;

}
RegionImpl* RegionImplFactory::deserializeRegionImpl(
    const std::string nodeType,
    capnp::AnyPointer::Reader& proto,
    Region* region)
{
  RegionImpl *impl = nullptr;

  if (cppRegions.find(nodeType) != cppRegions.end())
  {
    impl = cppRegions[nodeType]->deserializeRegionImpl(proto, region);
  }
  else if (StringUtils::startsWith(nodeType, "py."))
  {
    if (!pyLib_)
     pyLib_ = boost::shared_ptr<DynamicPythonLibrary>(new DynamicPythonLibrary());

    impl = deserializePyNode(pyLib_.get(), nodeType, proto, region);
  }
  else
  {
    NTA_THROW << "Unsupported node type '" << nodeType << "'";
  }
  return impl;
}