Exemplo n.º 1
0
void CacheMap::setMapEntryValueByPosition(string cacheKey, int position, string value) {
	if(checkExistance(cacheKey, MAP))
	{
		instance->mutex.lock();
		map<string, string>* valueMap = (map<string, string>*)instance->cacheMap[cacheKey];
		instance->mutex.unlock();

		instance->valueLocks[cacheKey]->lock();
		if(position<(int)valueMap->size())
		{
			map<string, string>::iterator it = valueMap->begin();
			advance(it, position);
			it->second = value;
		}
		else
		{
			throw ERR_INDGRTCONTSIZ;
		}
		instance->valueLocks[cacheKey]->unlock();
	}
	else
	{
		throw ERR_NOKEYCACHEMAP;
	}
}
Exemplo n.º 2
0
string CacheMap::getMapEntryValue(string cacheKey, string key) {
	string value;
	if(checkExistance(cacheKey, MAP))
	{
		instance->mutex.lock();
		map<string, string>* valueMap = (map<string, string>*)instance->cacheMap[cacheKey];
		instance->mutex.unlock();

		instance->valueLocks[cacheKey]->lock();
		if(valueMap->find(key)!=valueMap->end())
		{
			value = valueMap->find(key)->second;
		}
		else
		{
			throw ERR_NOVALUEFOUND;
		}
		instance->valueLocks[cacheKey]->unlock();
	}
	else
	{
		throw ERR_NOKEYCACHEMAP;
	}
	return value;
}
Exemplo n.º 3
0
void CacheMap::deallocate(string cacheKey) {
	if(checkExistance(cacheKey))
	{
		instance->mutex.lock();
		delete instance->valueLocks[cacheKey];
		delete instance->cacheMap[cacheKey];
		instance->cacheMap.erase(cacheKey);
		instance->valueLocks.erase(cacheKey);
		instance->valueTypes.erase(cacheKey);
		instance->mutex.unlock();
	}
	else
	{
		throw ERR_NOKEYCACHEMAP;
	}
}
Exemplo n.º 4
0
void CacheMap::removeMapEntry(string cacheKey, string key) {
	if(checkExistance(cacheKey, MAP))
	{
		instance->mutex.lock();
		map<string, string>* valueMap = (map<string, string>*)instance->cacheMap[cacheKey];
		instance->mutex.unlock();

		instance->valueLocks[cacheKey]->lock();
		valueMap->erase(key);
		instance->valueLocks[cacheKey]->unlock();
	}
	else
	{
		throw ERR_NOTAMAPCONT;
	}
}
Exemplo n.º 5
0
void CacheMap::addMapEntry(string cacheKey, string key, string value) {
	if(checkExistance(cacheKey, MAP))
	{
		instance->mutex.lock();
		map<string, string>* valueMap = (map<string, string>*)instance->cacheMap[cacheKey];
		instance->mutex.unlock();

		instance->valueLocks[cacheKey]->lock();
		valueMap->insert(pair<string, string>(key, value));
		instance->valueLocks[cacheKey]->unlock();
	}
	else
	{
		throw ERR_NOTAMAPCONT;
	}
}
Exemplo n.º 6
0
void
LogisticDao::connect() {
	load();
	checkDriver();
	db = QSqlDatabase::addDatabase(dbDriver);
	db.setDatabaseName(dbName);
	db.setUserName(dbUserName);
	db.setPassword(dbUserPassword);
	checkExistance();
	checkOpenConnection();

	dbWaybillModel = new QSqlTableModel();
	dbWaybillModel->setTable("Requisition");
	dbWaybillModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
	dbWaybillModel->select();

	dbActivedWaybillModel = 0;
}
Exemplo n.º 7
0
void CacheMap::allocate(string cacheKey, string type) {
	if(checkExistance(cacheKey))
	{
		throw ERR_ALLOCENTEXISTS;
	}

	void *entry = NULL;
	if(type==MAP)
	{
		entry = new map<string, string>;
	}
	else if(type==SET)
	{
		entry = new set<string>;
	}
	else if(type==LIST)
	{
		entry = new list<string>;
	}
	else if(type==VECTOR)
	{
		entry = new vector<string>;
	}
	else if(type==QUEUE)
	{
		entry = new queue<string>;
	}
	else if(type==DEQUE)
	{
		entry = new deque<string>;
	}
	else
	{
		throw ERR_INVCONTAINER;
	}
	if(entry!=NULL)
	{
		instance->mutex.lock();
		instance->cacheMap[cacheKey] = entry;
		instance->valueTypes[cacheKey] = type;
		instance->valueLocks[cacheKey] = new Mutex;
		instance->mutex.unlock();
	}
}
Exemplo n.º 8
0
ACE_UINT32 devEthernet::index() {
	ACE_TRACE("devEthernet::index");
	checkExistance();

	return if_nametoindex(getIfaceName().c_str());
}