bool ServiceDescription::operator==(const ServiceDescription& other) const
{
        if(!compareWithoutTXT(other))
            return false;

	std::vector<std::string> labels = this->getLabels();

        int labelsSize = labels.size();

        for(int i = 0; i < labelsSize; i++)
        {  
		std::string label = labels_[i];

                if(this->getDescription(label) != other.getDescription(label))
                        return false;
        }   
	return true;
}
std::vector<ServiceDescription> ServiceDiscovery::findServices(const ServicePattern& pattern, const std::string& name_space) const
{
    std::vector<ServiceDescription> result;
    List<ServiceDescription>::const_iterator it;

    boost::unique_lock<boost::mutex> lock(mServicesMutex);

    for (it = mServices.begin(); it != mServices.end(); it++) 
    {
        ServiceDescription description = *it;
        std::string serviceprop = description.getDescription("service");
      
        size_t namespace_begin = serviceprop.find_first_of(":") + 1;
        
        if((name_space == "*" || serviceprop.compare(namespace_begin, name_space.size(), name_space) == 0) 
            && pattern.matchDescription(description) ) 
        {
          result.push_back(description);
        }
    }

    return result;
}
void ServiceDiscovery::updatedService(const RemoteService& service)
{
    ServiceDescription desc = service.getConfiguration();

    boost::unique_lock<boost::mutex> lock(mServicesMutex);

    List<ServiceDescription>::iterator it;

    for(it = mServices.begin(); it != mServices.end(); it++) 
    {
       if( desc.compareWithoutTXT(*it) ) 
       {
           std::vector<std::string> labels = desc.getLabels();

           for(unsigned int i = 0; i < labels.size(); i++) 
           {
               it->setDescription(labels[i], desc.getDescription(labels[i]));
           }

           LOG_INFO("Updated service: %s", service.getName().c_str());
       }
    }
}