IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 11, 2009, 4:51:19 PM (17 years ago)
Author:
Paul Price
Message:

config->recipes should hold the recipes that are in the SYSTEM definition. That way, we can write them out in the configuration dump, and load them back in.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfigRecipes.c

    r21387 r23286  
    1111#include "pmConfigRecipes.h"
    1212
    13 static bool loadRecipeSystem(bool *status, pmConfig *config, psMetadata *source);
     13static bool loadRecipeSystem(bool *status, pmConfig *config);
    1414static bool loadRecipeCamera(bool *status, pmConfig *config, psMetadata *source);
    1515static bool loadRecipeSymbols(bool *status, pmConfig *config, pmRecipeSource source);
     
    5656    PS_ASSERT_PTR_NON_NULL(config, false);
    5757
    58     if (!config->recipes) {
    59         config->recipes = psMetadataAlloc();
    60     }
    61 
    6258    // Read the recipe file names from the system configuration and camera configuration
    6359    // It is an error for config->system:recipes not to exist.  all programs install their
    6460    // master recipe files in the system:recipe location when they are built.
    6561    psAssert(config->system, "base config data defined");
    66     if (source & PM_RECIPE_SOURCE_SYSTEM) {
    67         if (!loadRecipeSystem(&status, config, config->system)) {
     62    if (!config->recipes || (source & PM_RECIPE_SOURCE_SYSTEM)) {
     63        if (!loadRecipeSystem(&status, config)) {
    6864            psError(PS_ERR_IO, false, "Failed to read recipes from system config");
    6965            return false;
     
    321317// Load the recipe files for SYSTEM : REQUIRED
    322318static bool loadRecipeSystem(bool *status,
    323                            pmConfig *config, // The configuration into which to read the recipes
    324                            psMetadata *source // The source configuration, from which to read the filenames
     319                           pmConfig *config // The configuration into which to read the recipes
    325320    )
    326321{
     
    329324    *status = false;
    330325
    331     if (!source) {
     326    if (!config->system) {
    332327        psError(PS_ERR_IO, true,
    333328                "The system configuration has not been read --- cannot read recipes from this location.\n");
     
    336331    }
    337332
    338     psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes
    339     if (!recipes) {
    340         psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");
    341         return false;
    342     }
    343 
    344     // Copy contents of the filenames to config->recipes from the "RECIPES" metadata in the source.
    345     // We could use psMetadataCopy for this, but it's better to check that everything's of the correct type.
    346     // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.
    347     psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator
     333    if (!config->recipes) {
     334        config->recipes = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->system, "RECIPES")); // The list of recipes
     335        if (!config->recipes) {
     336            psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");
     337            return false;
     338        }
     339    }
     340
     341    // Read in the component recipes
     342    psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipes, PS_LIST_HEAD, NULL); // Iterator
    348343    psMetadataItem *item = NULL;        // MD item containing the filename, from recipe iteration
    349344    while ((item = psMetadataGetAndIncrement(recipesIter))) {
     
    353348            psFree(recipesIter);
    354349            return false;
    355         }
    356 
    357         // add the contents of this recipe file to config->recipes
    358         psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE,
    359                       item->comment, item->data.md);
     350        }
    360351    }
    361352    psFree(recipesIter);
Note: See TracChangeset for help on using the changeset viewer.