static char* test_object_persistence_with_store(LCStoreRef store, char *storeType) {
  LCContextRef context = contextCreate(store, NULL, 0);
  
  mu_assert("contextStringToType", contextStringToType(context, "LCString") == LCTypeString);
  
  char* string = "abcdef";
  LCStringRef test = LCStringCreate(string);
  objectStore(test, context);
  objectDeleteCache(test, context);
  mu_assert("string persistence", LCStringEqualCString(test, string));
  
  char hash[HASH_LENGTH];
  objectHash(test, hash);
  FILE *fd = storeReadData(store, LCTypeString, hash);
  LCStringRef stringFromFile = objectCreateFromFile(context, fd);
  mu_assert("objectCreateFromFile", LCStringEqualCString(stringFromFile, string));

  LCStringRef string1 = LCStringCreate("abc");
  LCStringRef string2 = LCStringCreate("def");
  LCStringRef string3 = LCStringCreate("ghi");
  LCStringRef stringArray[] = {string1, string2, string3};
  LCArrayRef array = LCArrayCreate(stringArray, 3);
  objectStore(array, context);
  objectDeleteCache(array, context);
  LCStringRef *strings = LCArrayObjects(array);
  mu_assert("array persistence", LCStringEqual(string1, strings[0]) && LCStringEqual(string2, strings[1]) &&
            LCStringEqual(string3, strings[2]));
  
  LCKeyValueRef keyValue = LCKeyValueCreate(string1, array);
  objectStore(keyValue, context);
  objectDeleteCache(keyValue, context);
  objectCache(keyValue);
  mu_assert("keyValue persistence", LCStringEqual(LCKeyValueKey(keyValue), string1));
  
  LCArrayRef mArray = LCMutableArrayCreate(stringArray, 3);
  objectStore(mArray, context);
  objectDeleteCache(mArray, context);
  LCMutableArrayAddObject(mArray, string1);
  objectStore(mArray, context);
  objectDeleteCache(mArray, context);
  objectCache(mArray);
  LCStringRef *strings1 = LCMutableArrayObjects(mArray);
  mu_assert("mutable array persistence", LCStringEqual(string1, strings1[0]) && LCStringEqual(string2, strings1[1]) &&
            LCStringEqual(string3, strings1[2]) && LCStringEqual(string1, strings1[3]));
  
  LCMutableArrayAddObject(mArray, LCStringCreate("test1"));
  objectStoreAsComposite(mArray, context);
  objectDeleteCache(mArray, context);
  LCStringRef *strings2 = LCMutableArrayObjects(mArray);
  mu_assert("composite persistence", LCStringEqual(string1, strings2[0]) && LCStringEqual(string2, strings2[1]) &&
            LCStringEqual(string3, strings2[2]) && LCStringEqual(string1, strings2[3]));

  return 0;
}
AbcObjectCache* addObjectToCache( AbcArchiveCache* fullNameToObjectCache, Abc::IObject &obj, std::string parentIdentifier, CommonProgressBar *pBar ) {
	ESS_PROFILE_SCOPE("addObjectToCache");
	AbcObjectCache objectCache( obj );
	objectCache.parentIdentifier = parentIdentifier;
	for( int i = 0; i < obj.getNumChildren(); i ++ ) {
		if (pBar)
		{
			pBar->incr(1);
			if (!(i % 20) && pBar->isCancelled())	
				return 0;
		}

		Abc::IObject child = obj.getChild( i );
		AbcObjectCache* childObjectCache = addObjectToCache( fullNameToObjectCache, child, objectCache.fullName, pBar );
		if (childObjectCache == 0)
			return 0;

		objectCache.childIdentifiers.push_back( childObjectCache->fullName );
	}
	fullNameToObjectCache->insert( AbcArchiveCache::value_type( objectCache.fullName, objectCache ) );
	return &( fullNameToObjectCache->find( objectCache.fullName )->second );
}
Exemple #3
0
void* objectData(LCObjectRef object) {
  if (!object->data) {
    objectCache(object);
  }
  return object->data;
}