v8::Handle<Value> HoneydProfileBinding::New(const Arguments& args)
{
	v8::HandleScope scope;

	HoneydProfileBinding* obj = new HoneydProfileBinding();
	obj->m_pfile = new NodeProfile();
	obj->Wrap(args.This());

	return args.This();
}
v8::Handle<Value> HoneydProfileBinding::New(const Arguments& args)
{
	if(args.Length() != 2)
	{
		return ThrowException(Exception::TypeError(String::New("Must be invoked with at exactly two parameters")));
	}

	std::string parentName = cvv8::CastFromJS<std::string>(args[0]);
	std::string profileName = cvv8::CastFromJS<std::string>(args[1]);

	HoneydProfileBinding* binding = new HoneydProfileBinding(parentName, profileName);
	binding->Wrap(args.This());
	return args.This();
}
Handle<Value> HoneydProfileBinding::SetVendors(const Arguments& args)
{ 
  if(args.Length() != 2)
  {
    return ThrowException(Exception::TypeError(String::New("Must be invoked with at exactly two parameters")));
  }
  
  HandleScope scope;
  HoneydProfileBinding* obj = ObjectWrap::Unwrap<HoneydProfileBinding>(args.This());
  
  std::cout << "In SetVendors" << std::endl;
  
  std::vector<std::string> ethVendors = cvv8::CastFromJS<std::vector<std::string> >(args[0]);
  std::vector<double> ethDists = cvv8::CastFromJS<std::vector<double> >(args[1]);
  
  std::cout << "ethVendors length == " << ethVendors.size() << '\n';
  std::cout << "ethDists length == " << ethDists.size() << std::endl;  
  
  std::vector<std::pair<std::string, double> > set;
  
  if(ethVendors.size() == 0)
  {
    HoneydConfiguration *conf = new HoneydConfiguration();
    conf->LoadAllTemplates();
    std::cout << "clearing m_ethernetVendors." << std::endl;
  	obj->m_pfile->m_ethernetVendors.clear();
  	std::cout << "m_ethernetVendors.size() == " << obj->m_pfile->m_ethernetVendors.size() << std::endl;
  	conf->m_profiles[obj->m_pfile->m_name].m_ethernetVendors.clear();
  	conf->UpdateProfile(obj->m_pfile->m_name);
  	conf->SaveAllTemplates();
  	return args.This();
  }
  else
  {
  	for(uint i = 0; i < ethVendors.size(); i++)
  	{
	    std::pair<std::string, double> vendorDists;
	    vendorDists.first = ethVendors[i];
	    vendorDists.second = ethDists[i];
	    set.push_back(vendorDists);
  	}
	  
  	for(uint i = 0; i < set.size(); i++)
  	{
	    std::cout << "set[" << i << "] = {" << set[i].first << ", " << set[i].second << "}\n";
  	}
  	
  	return scope.Close(Boolean::New(obj->GetChild()->SetVendors(set)));
  }
}
Handle<Value> HoneydProfileBinding::AddPort(const Arguments& args) 
{
	HandleScope scope;
	HoneydProfileBinding* obj = ObjectWrap::Unwrap<HoneydProfileBinding>(args.This());

	if( args.Length() != 2 )
	{
		return ThrowException(Exception::TypeError(String::New("Must be invoked with two parameters")));
	}

	string portName = cvv8::CastFromJS<string>( args[0] );
	bool isInherited = cvv8::CastFromJS<bool>( args[1] );

	return scope.Close(Boolean::New(obj->GetChild()->AddPort(portName, isInherited, 0)));
}