コード例 #1
0
void StoragesAssigner::getAvailableStoreAssignments(Element* element, std::map<Store*, std::vector<Store*> >& STsOnStore, std::map<Store*, Assignment* >& stAssignment, Assignment* assignment)
{
    Stores::iterator storesIt = network->getStores().begin();
    Stores::iterator storesItEnd = network->getStores().end();
    for ( ; storesIt != storesItEnd; ++storesIt )
    {
        if ( (*storesIt)->getTypeOfStore() == static_cast<Store*>(element)->getTypeOfStore() )
        {
            // inserting only vms with capacity less then the element's one
            STsOnStore[*storesIt] = std::vector<Store *>();

            // going through all other assigned requests
            RequestAssignment::iterator it = requestAssignment.begin();
            RequestAssignment::iterator itEnd = requestAssignment.end();
            for ( ; it != itEnd; ++it )
            {
                Stores storages = it->second->GetAssigned(*storesIt);
                Stores::iterator stIt = storages.begin();
                Stores::iterator stItEnd = storages.end();
                for ( ; stIt != stItEnd; ++stIt )
                {
                    STsOnStore[*storesIt].push_back(*stIt);
                    stAssignment[*stIt] = it->second;
                }
            }
        }
    }
}
コード例 #2
0
ファイル: StoresMgr.cpp プロジェクト: azcbuell/OpenEaagles
//------------------------------------------------------------------------------
// Search all of the objects in the main list for objects of 'type' and add
// them to the sublist.  Also check all Stores type objects for any 'type' objects.
//------------------------------------------------------------------------------
void StoresMgr::searchAndAdd(Basic::PairStream* const mainList, const std::type_info& type, Basic::PairStream* sublist)
{
   if (mainList != 0 && sublist != 0) {

      const Basic::List::Item* item = mainList->getFirstItem();
      while (item != 0) {

         Basic::Pair* pair = (Basic::Pair*)(item->getValue());
         Basic::Component* p = (Basic::Component*)( pair->object() );

         // Check the type and add to the list
         bool isType = p->isClassType(type);
         if (isType) sublist->put(pair);

         // If this is a Stores object then check its stores for 'type' objects as well
         Stores* sp = dynamic_cast<Stores*>(p);
         if ( sp != 0 ) {
            Basic::PairStream* pstores = sp->getStores();
            searchAndAdd(pstores, type, sublist);
            pstores->unref();
         }

         item = item->getNext();
      }
   }  
}
コード例 #3
0
int main(int argc, char **argv)
{
	assert(argc > 1);
	// each element in files holds the transactions for a particular store
	Stores files;
	for (int cnt = 1; cnt != argc; ++cnt)
		files.push_back(build_store(argv[cnt]));

	ifstream in("../data/findbook.in");  // ISBNs to search for
	reportResults(in, cout, files);
}
コード例 #4
0
// files holds the transactions for every store 
// findBook returns a vector with an entry for each store that sold the given book
vector<matches>
findBook(const Stores &files, const string &book)
{
	vector<matches> ret;  // initially empty
	// for each store find the range of matching books, if any
	for (Stores::const_iterator it = files.begin(); 
				it != files.end(); ++it) {
		// find the range of Sales_data that have the same ISBN
		pair<vector<Sales_data>::const_iterator,
		     vector<Sales_data>::const_iterator> found = 
			equal_range(it->begin(), it->end(), book, compareIsbn);
		if (found.first != found.second)  // this store had sales
			// remember the index of this store and the matching range 
			ret.push_back(make_tuple(it - files.begin(), 
                                  found.first, found.second));
	}
	return ret; // empty if no matches found
}
コード例 #5
0
// Default function to get the current weapon (Pre-ref()'d)
Weapon* StoresMgr::getCurrentWeapon()
{
   // Get the selected station's weapon
   Weapon* wpn = getWeapon();

   if (wpn == nullptr) {
      // If not found then check to see if the selected station
      // was really a Stores class object.  If so then ask it
      // for its selected station's weapon
      ExternalStore* es = getExternalStore();
      if (es != nullptr) {
         Stores* ss = dynamic_cast<Stores*>( es );
         if (ss != nullptr) wpn = ss->getWeapon();
         es->unref();
      }
   }

   return wpn;
}
コード例 #6
0
ファイル: networkManager.cpp プロジェクト: artacc/DataCenters
Stores NetworkManager::getStoreCandidates()
{
    Stores result;

    while( !depthSearcher->isExhausted() )
    {
        Elements elements = depthSearcher->getElementCandidates();
        cerr << "[NM]\tDepth search returned " << elements.size() << endl;

        for ( Elements::iterator i = elements.begin(); i != elements.end(); i++ )
        {
            Element * element = *i;
            if ( ! element->isStore() )
                continue;

            Store * store = (Store *) element;
            
            if ( rejectedStores.find(store) != rejectedStores.end() )
                continue;
            
            result.insert(store);
        }

        depthSearcher->increaseSearchSpace();

        if ( !result.empty()  )
            break;
    }

    rejectedStores.insert(result.begin(), result.end());
    cerr << "[NM]\tPrepared " << result.size() << " candidates" << endl;
    return result;
}
コード例 #7
0
ファイル: serialize.cpp プロジェクト: ueverything/SyGame
void Object::__store__(Stream & ss,unsigned char tag)
{
    Stores sts;
    if (tag == __LOAD__)
    {
        preLoad();
        sts.parseRecord(ss);
    }
    else
    {
        preStore();
    }
    __v_store__(sts,tag);
    if (tag == __LOAD__)
    {
        beLoaded();
    }
    else
    {
        ss = sts.toRecord();
        beStored();
    }
}