Exemple #1
0
static MmsValue*
searchCacheForValue(MmsValueCache self, char* itemId, char* parentId)
{
	MmsValueCacheEntry* cacheEntry;
	MmsValue* value = NULL;

	cacheEntry = (MmsValueCacheEntry*) Map_getEntry(self->map, parentId);

	if (cacheEntry == NULL) {
		char* parentItemId = getParentSubString(parentId);

		if (parentItemId != NULL) {
			value = searchCacheForValue(self, itemId, parentItemId);
		}
	}
	else {

		char* childId = getChildSubString(itemId, parentId);

		MmsVariableSpecification* typeSpec = MmsDomain_getNamedVariable(self->domain, parentId);
		value = MmsVariableSpecification_getChildValue(typeSpec, cacheEntry->value, childId);
	}

	return value;
}
Exemple #2
0
MmsValue*
MmsValueCache_lookupValue(MmsValueCache self, char* itemId)
{
	// get value for first matching key substring!
	// Then iterate the value for the exact value.

	MmsValue* value = NULL;

	MmsValueCacheEntry* cacheEntry;

	cacheEntry = (MmsValueCacheEntry*) Map_getEntry(self->map, itemId);

	if (cacheEntry == NULL) {
		char* itemIdCopy = copyString(itemId);
		char* parentItemId = getParentSubString(itemIdCopy);

		if (parentItemId != NULL) {
			value = searchCacheForValue(self, itemId, parentItemId);
		}

		GLOBAL_FREEMEM(itemIdCopy);
	}

	if (cacheEntry != NULL)
		return cacheEntry->value;
	else
		return value;
}
Exemple #3
0
void
MmsServer_insertIntoCache(MmsServer self, MmsDomain* domain, char* itemId, MmsValue* value)
{
	MmsValueCache cache = Map_getEntry(self->valueCaches, domain);

	if (cache != NULL) {
		MmsValueCache_insertValue(cache, itemId, value);
	}
}
Exemple #4
0
MmsValue*
MmsServer_getValueFromCache(MmsServer self, MmsDomain* domain, char* itemId)
{
	MmsValueCache cache = Map_getEntry(self->valueCaches, domain);

	if (cache != NULL) {
		return MmsValueCache_lookupValue(cache, itemId);
	}

	return NULL;
}