Example #1
0
void ServiceListeners::GetMatchingServiceListeners(const ServiceEvent& evt, ServiceListenerEntries& set,
                                                   bool lockProps)
{
  US_UNUSED(Lock(this));

  // Filter the original set of listeners
  ServiceListenerEntries receivers = serviceSet;
  coreCtx->serviceHooks.FilterServiceEventReceivers(evt, receivers);

  // Check complicated or empty listener filters
  for (std::list<ServiceListenerEntry>::const_iterator sse = complicatedListeners.begin();
       sse != complicatedListeners.end(); ++sse)
  {
    if (receivers.count(*sse) == 0) continue;
    const LDAPExpr& ldapExpr = sse->GetLDAPExpr();
    if (ldapExpr.IsNull() ||
        ldapExpr.Evaluate(evt.GetServiceReference().d->GetProperties(), false))
    {
      set.insert(*sse);
    }
  }

  //US_DEBUG << "Added " << set.size() << " out of " << n
  //         << " listeners with complicated filters";

  // Check the cache
  const std::vector<std::string> c(any_cast<std::vector<std::string> >
                                 (evt.GetServiceReference().d->GetProperty(ServiceConstants::OBJECTCLASS(), lockProps)));
  for (std::vector<std::string>::const_iterator objClass = c.begin();
       objClass != c.end(); ++objClass)
  {
    AddToSet(set, receivers, OBJECTCLASS_IX, *objClass);
  }

  long service_id = any_cast<long>(evt.GetServiceReference().d->GetProperty(ServiceConstants::SERVICE_ID(), lockProps));
  std::stringstream ss;
  ss << service_id;
  AddToSet(set, receivers, SERVICE_ID_IX, ss.str());
}
Example #2
0
void ServiceListeners::GetMatchingServiceListeners(const ServiceReferenceBase& sr, ServiceListenerEntries& set,
                                                   bool lockProps)
{
  MutexLocker lock(mutex);

  // Check complicated or empty listener filters
  int n = 0;
  for (std::list<ServiceListenerEntry>::const_iterator sse = complicatedListeners.begin();
       sse != complicatedListeners.end(); ++sse)
  {
    ++n;
    const LDAPExpr& ldapExpr = sse->GetLDAPExpr();
    if (ldapExpr.IsNull() ||
        ldapExpr.Evaluate(sr.d->GetProperties(), false))
    {
      set.insert(*sse);
    }
  }

  //US_DEBUG << "Added " << set.size() << " out of " << n
  //         << " listeners with complicated filters";

  // Check the cache
  const std::vector<std::string> c(any_cast<std::vector<std::string> >
                                 (sr.d->GetProperty(ServiceConstants::OBJECTCLASS(), lockProps)));
  for (std::vector<std::string>::const_iterator objClass = c.begin();
       objClass != c.end(); ++objClass)
  {
    AddToSet(set, OBJECTCLASS_IX, *objClass);
  }

  long service_id = any_cast<long>(sr.d->GetProperty(ServiceConstants::SERVICE_ID(), lockProps));
  std::stringstream ss;
  ss << service_id;
  AddToSet(set, SERVICE_ID_IX, ss.str());
}
int numDistinctIslands(int**g, int gridSz, int grid0sz){
    grid = g;
    grid_length = gridSz;
    grid0length = grid0sz;
    Set*visited = CreateSet(1024);
    int t = 0;
    for(int i=0; i<gridSz; ++i) {
        for(int j=0; j< grid0sz; ++j) {
            if(grid[i][j]==1) {
                int c=dfs(i, j);
                if(!isElementInSet(visited, c)) {
                    AddToSet(visited, c);
                    ++t;
                }
            }
        }
    }
    return t;
}
Example #4
0
void BioSeq::SearchFront(std::fstream &myfile)
{
    int count = 0;
    for(auto &bsv : m_bSeqV)
        for(auto &bs : bsv)
        {
            count++;
            if(IsMotifFront(bs))
            {
                Motif m;
                m.bs = bs;
                m_motifs_a.push_back(m);
                AddToSet(bs.a);
            }
            if(count%10000==0)
                WriteSomethingToFile(myfile, TimeStamp()+"...processed "+
                        std::to_string(count)+" sequences.\n");
        }
    WriteSomethingToFile(myfile, TimeStamp()+"...finished searching front sequences, found "+
        std::to_string(m_unique_motifs.size())+" unique  motifs.\n");
}
Example #5
0
StringSet& RTFFileContext::GetSetToChangeToText()
{
	if(m_setToChangeToText.empty())
	{
			// this should be thread safe
 			AddToSet(L"TOC");		
 			AddToSet(L"REF");		
 			AddToSet(L"TOA");		
 			AddToSet(L"TA");		
 			AddToSet(L"DATE");		
 			AddToSet(L"TIME");		
 			AddToSet(L"COMMENTS");	
 			AddToSet(L"KEYWORDS");	
 			AddToSet(L"AUTHOR");	
 			AddToSet(L"FILENAME");	
 			AddToSet(L"SAVEDATE");	
// 			AddToSet(L"HYPERLINK");	
 			AddToSet(L"CREATEDATE");
 			AddToSet(L"PAGEREF");	
 			AddToSet(L"INDEX");		
 			AddToSet(L"DOCPROPERTY");
 			AddToSet(L"TITLE");		
 			AddToSet(L"MERGEFIELD");
 			AddToSet(L"NOTEREF");	
 			AddToSet(L"SHAPE");	
 			AddToSet(L"QUOTE");	
		}
	return m_setToChangeToText;
}
Example #6
0
void NetworkWatch::AddSocket(WSocket *socket){
    assert(!IsPartOfSet(socket, socket_set));
    AddToSet(socket, socket_set);
    assert(IsPartOfSet(socket, socket_set));
}