Cleanup: rename treehash -> outliner_treehash

This is an API specifically for the outliner,
not some generic hierarchical hash structure.
This commit is contained in:
Campbell Barton 2015-04-07 11:01:47 +10:00
parent 5217d2bc0e
commit e2eeb46a1b
6 changed files with 37 additions and 37 deletions

View File

@ -19,10 +19,10 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BKE_TREEHASH_H__
#define __BKE_TREEHASH_H__
#ifndef __BKE_OUTLINER_TREEHASH_H__
#define __BKE_OUTLINER_TREEHASH_H__
/** \file BKE_treehash.h
/** \file BKE_outliner_treehash.h
* \ingroup bke
*/
@ -31,21 +31,21 @@ struct BLI_mempool;
struct TreeStoreElem;
/* create and fill hashtable with treestore elements */
void *BKE_treehash_create_from_treestore(struct BLI_mempool *treestore);
void *BKE_outliner_treehash_create_from_treestore(struct BLI_mempool *treestore);
/* full rebuild for already allocated hashtable */
void *BKE_treehash_rebuild_from_treestore(void *treehash, struct BLI_mempool *treestore);
void *BKE_outliner_treehash_rebuild_from_treestore(void *treehash, struct BLI_mempool *treestore);
/* full rebuild for already allocated hashtable */
void BKE_treehash_add_element(void *treehash, struct TreeStoreElem *elem);
void BKE_outliner_treehash_add_element(void *treehash, struct TreeStoreElem *elem);
/* find first unused element with specific type, nr and id */
struct TreeStoreElem *BKE_treehash_lookup_unused(void *treehash, short type, short nr, struct ID *id);
struct TreeStoreElem *BKE_outliner_treehash_lookup_unused(void *treehash, short type, short nr, struct ID *id);
/* find user or unused element with specific type, nr and id */
struct TreeStoreElem *BKE_treehash_lookup_any(void *treehash, short type, short nr, struct ID *id);
struct TreeStoreElem *BKE_outliner_treehash_lookup_any(void *treehash, short type, short nr, struct ID *id);
/* free treehash structure */
void BKE_treehash_free(void *treehash);
void BKE_outliner_treehash_free(void *treehash);
#endif

View File

@ -135,6 +135,7 @@ set(SRC
intern/object_deform.c
intern/object_dupli.c
intern/ocean.c
intern/outliner_treehash.c
intern/packedFile.c
intern/paint.c
intern/particle.c
@ -172,7 +173,6 @@ set(SRC
intern/tracking_solver.c
intern/tracking_stabilize.c
intern/tracking_util.c
intern/treehash.c
intern/unit.c
intern/world.c
intern/writeavi.c
@ -211,6 +211,8 @@ set(SRC
BKE_depsgraph.h
BKE_displist.h
BKE_dynamicpaint.h
BKE_editmesh.h
BKE_editmesh_bvh.h
BKE_effect.h
BKE_fcurve.h
BKE_fluidsim.h
@ -246,6 +248,7 @@ set(SRC
BKE_object.h
BKE_object_deform.h
BKE_ocean.h
BKE_outliner_treehash.h
BKE_packedFile.h
BKE_paint.h
BKE_particle.h
@ -266,12 +269,9 @@ set(SRC
BKE_speaker.h
BKE_subsurf.h
BKE_suggestions.h
BKE_editmesh.h
BKE_editmesh_bvh.h
BKE_text.h
BKE_texture.h
BKE_tracking.h
BKE_treehash.h
BKE_unit.h
BKE_utildefines.h
BKE_world.h

View File

@ -20,7 +20,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
/** \file treehash.c
/** \file outliner_treehash.c
* \ingroup bke
*
* Tree hash for the outliner space.
@ -28,7 +28,7 @@
#include <stdlib.h>
#include "BKE_treehash.h"
#include "BKE_outliner_treehash.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
@ -104,11 +104,11 @@ static void fill_treehash(void *treehash, BLI_mempool *treestore)
BLI_mempool_iter iter;
BLI_mempool_iternew(treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
BKE_treehash_add_element(treehash, tselem);
BKE_outliner_treehash_add_element(treehash, tselem);
}
}
void *BKE_treehash_create_from_treestore(BLI_mempool *treestore)
void *BKE_outliner_treehash_create_from_treestore(BLI_mempool *treestore)
{
GHash *treehash = BLI_ghash_new_ex(tse_hash, tse_cmp, "treehash", BLI_mempool_count(treestore));
fill_treehash(treehash, treestore);
@ -120,14 +120,14 @@ static void free_treehash_group(void *key)
tse_group_free(key);
}
void *BKE_treehash_rebuild_from_treestore(void *treehash, BLI_mempool *treestore)
void *BKE_outliner_treehash_rebuild_from_treestore(void *treehash, BLI_mempool *treestore)
{
BLI_ghash_clear_ex(treehash, NULL, free_treehash_group, BLI_mempool_count(treestore));
fill_treehash(treehash, treestore);
return treehash;
}
void BKE_treehash_add_element(void *treehash, TreeStoreElem *elem)
void BKE_outliner_treehash_add_element(void *treehash, TreeStoreElem *elem)
{
TseGroup *group;
void **val_p;
@ -139,7 +139,7 @@ void BKE_treehash_add_element(void *treehash, TreeStoreElem *elem)
tse_group_add(group, elem);
}
static TseGroup *BKE_treehash_lookup_group(GHash *th, short type, short nr, struct ID *id)
static TseGroup *BKE_outliner_treehash_lookup_group(GHash *th, short type, short nr, struct ID *id)
{
TreeStoreElem tse_template;
tse_template.type = type;
@ -148,9 +148,9 @@ static TseGroup *BKE_treehash_lookup_group(GHash *th, short type, short nr, stru
return BLI_ghash_lookup(th, &tse_template);
}
TreeStoreElem *BKE_treehash_lookup_unused(void *treehash, short type, short nr, struct ID *id)
TreeStoreElem *BKE_outliner_treehash_lookup_unused(void *treehash, short type, short nr, struct ID *id)
{
TseGroup *group = BKE_treehash_lookup_group(treehash, type, nr, id);
TseGroup *group = BKE_outliner_treehash_lookup_group(treehash, type, nr, id);
if (group) {
int i;
for (i = 0; i < group->size; i++) {
@ -162,13 +162,13 @@ TreeStoreElem *BKE_treehash_lookup_unused(void *treehash, short type, short nr,
return NULL;
}
TreeStoreElem *BKE_treehash_lookup_any(void *treehash, short type, short nr, struct ID *id)
TreeStoreElem *BKE_outliner_treehash_lookup_any(void *treehash, short type, short nr, struct ID *id)
{
TseGroup *group = BKE_treehash_lookup_group(treehash, type, nr, id);
TseGroup *group = BKE_outliner_treehash_lookup_group(treehash, type, nr, id);
return group ? group->elems[0] : NULL;
}
void BKE_treehash_free(void *treehash)
void BKE_outliner_treehash_free(void *treehash)
{
BLI_ghash_free(treehash, NULL, free_treehash_group);
}

View File

@ -139,7 +139,7 @@
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sequencer.h"
#include "BKE_treehash.h"
#include "BKE_outliner_treehash.h"
#include "BKE_sound.h"
@ -6041,7 +6041,7 @@ static void lib_link_screen(FileData *fd, Main *main)
}
if (so->treehash) {
/* rebuild hash table, because it depends on ids too */
BKE_treehash_rebuild_from_treestore(so->treehash, so->treestore);
BKE_outliner_treehash_rebuild_from_treestore(so->treehash, so->treestore);
}
}
}
@ -6392,7 +6392,7 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
}
if (so->treehash) {
/* rebuild hash table, because it depends on ids too */
BKE_treehash_rebuild_from_treestore(so->treehash, so->treestore);
BKE_outliner_treehash_rebuild_from_treestore(so->treehash, so->treestore);
}
}
}

View File

@ -66,7 +66,7 @@
#include "BKE_modifier.h"
#include "BKE_sequencer.h"
#include "BKE_idcode.h"
#include "BKE_treehash.h"
#include "BKE_outliner_treehash.h"
#include "ED_armature.h"
#include "ED_screen.h"
@ -114,7 +114,7 @@ static void outliner_storage_cleanup(SpaceOops *soops)
BLI_mempool_destroy(ts);
soops->treestore = NULL;
if (soops->treehash) {
BKE_treehash_free(soops->treehash);
BKE_outliner_treehash_free(soops->treehash);
soops->treehash = NULL;
}
}
@ -133,7 +133,7 @@ static void outliner_storage_cleanup(SpaceOops *soops)
soops->treestore = new_ts;
if (soops->treehash) {
/* update hash table to fix broken pointers */
BKE_treehash_rebuild_from_treestore(soops->treehash, soops->treestore);
BKE_outliner_treehash_rebuild_from_treestore(soops->treehash, soops->treestore);
}
}
}
@ -151,12 +151,12 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty
}
if (soops->treehash == NULL) {
soops->treehash = BKE_treehash_create_from_treestore(soops->treestore);
soops->treehash = BKE_outliner_treehash_create_from_treestore(soops->treestore);
}
/* find any unused tree element in treestore and mark it as used
* (note that there may be multiple unused elements in case of linked objects) */
tselem = BKE_treehash_lookup_unused(soops->treehash, type, nr, id);
tselem = BKE_outliner_treehash_lookup_unused(soops->treehash, type, nr, id);
if (tselem) {
te->store_elem = tselem;
tselem->used = 1;
@ -171,7 +171,7 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty
tselem->used = 0;
tselem->flag = TSE_CLOSED;
te->store_elem = tselem;
BKE_treehash_add_element(soops->treehash, tselem);
BKE_outliner_treehash_add_element(soops->treehash, tselem);
}
/* ********************************************************* */
@ -216,7 +216,7 @@ TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse)
if (tse->id == NULL) return NULL;
/* check if 'tse' is in treestore */
tselem = BKE_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id);
tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id);
if (tselem)
return outliner_find_tree_element(&soops->tree, tselem);

View File

@ -41,7 +41,7 @@
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_scene.h"
#include "BKE_treehash.h"
#include "BKE_outliner_treehash.h"
#include "ED_space_api.h"
#include "ED_screen.h"
@ -464,7 +464,7 @@ static void outliner_free(SpaceLink *sl)
BLI_mempool_destroy(soutliner->treestore);
}
if (soutliner->treehash) {
BKE_treehash_free(soutliner->treehash);
BKE_outliner_treehash_free(soutliner->treehash);
}
}