-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1980 from jphickey/fix-1979-generic-config-registry
Fix #1979, implement abstract config registry module
- Loading branch information
Showing
25 changed files
with
1,754 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
################################################################## | ||
# | ||
# cFE Configuration Service (CONFIG) module CMake build recipe | ||
# | ||
################################################################## | ||
|
||
project(CFE_CONFIG C) | ||
|
||
# Executive services source files | ||
set(config_SOURCES | ||
fsw/src/cfe_config_init.c | ||
fsw/src/cfe_config_lookup.c | ||
fsw/src/cfe_config_get.c | ||
fsw/src/cfe_config_set.c | ||
) | ||
add_library(config STATIC | ||
${config_SOURCES} | ||
${MISSION_BINARY_DIR}/src/cfe_config_map.c | ||
) | ||
|
||
# need to include the "src" dir explicitly here, in order to compile | ||
# the generated tables under ${MISSION_BINARY_DIR} | ||
target_include_directories(config PRIVATE fsw/src) | ||
target_link_libraries(config PRIVATE core_private) | ||
|
||
# Add unit test coverage subdirectory | ||
if (ENABLE_UNIT_TESTS) | ||
add_subdirectory(ut-coverage) | ||
endif (ENABLE_UNIT_TESTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* This file is auto-generated from CMake build system. Do not manually edit! */ | ||
#ifndef CFE_CONFIG_IDS_H | ||
#define CFE_CONFIG_IDS_H | ||
|
||
#include "cfe_config_api_typedefs.h" | ||
#include "cfe_resourceid.h" | ||
#include "cfe_core_resourceid_basevalues.h" | ||
|
||
/* Value offsets from base (needed for macros; do not use directly) */ | ||
enum CFE_ConfigIdOffset | ||
{ | ||
@GENERATED_ENUM_OFFSET_LIST@ | ||
CFE_ConfigIdOffset_MAX | ||
}; | ||
|
||
/* | ||
* Set of actual CONFIGID constants - | ||
* these may be used in application code | ||
*/ | ||
@GENERATED_CONSTANT_DEFINE_LIST@ | ||
|
||
#endif /* CFE_CONFIG_IDS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* This file is auto-generated from CMake build system. Do not manually edit! */ | ||
#include "cfe_config_map.h" | ||
|
||
/* Map of configuration key IDs to printable names */ | ||
const CFE_Config_IdNameEntry_t CFE_CONFIG_IDNAME_MAP[CFE_ConfigIdOffset_MAX] = | ||
{ | ||
@GENERATED_IDNAME_MAP_LIST@ | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
/* | ||
** GSC-18128-1, "Core Flight Executive Version 6.7" | ||
** | ||
** Copyright (c) 2006-2019 United States Government as represented by | ||
** the Administrator of the National Aeronautics and Space Administration. | ||
** All Rights Reserved. | ||
** | ||
** Licensed under the Apache License, Version 2.0 (the "License"); | ||
** you may not use this file except in compliance with the License. | ||
** You may obtain a copy of the License at | ||
** | ||
** http://www.apache.org/licenses/LICENSE-2.0 | ||
** | ||
** Unless required by applicable law or agreed to in writing, software | ||
** distributed under the License is distributed on an "AS IS" BASIS, | ||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
** See the License for the specific language governing permissions and | ||
** limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* | ||
* API definition for configuration registry | ||
* | ||
* This defines the "getter" functions, which are publicly available | ||
*/ | ||
|
||
/* | ||
** Required header files. | ||
*/ | ||
#include "cfe_config_priv.h" | ||
#include "cfe_config_map.h" | ||
|
||
#include <string.h> | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: CFE_Config_GetValue | ||
* | ||
* Defined per public API | ||
* See description in header file for argument/return detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
uint32 CFE_Config_GetValue(CFE_ConfigId_t ConfigId) | ||
{ | ||
const CFE_Config_ValueEntry_t *Entry; | ||
|
||
Entry = CFE_Config_LocateConfigRecordByID(ConfigId); | ||
if (Entry == NULL || Entry->ActualType != CFE_ConfigType_VALUE) | ||
{ | ||
return 0; | ||
} | ||
|
||
return Entry->Datum.AsInteger; | ||
} | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: CFE_Config_GetObjPointer | ||
* | ||
* Defined per public API | ||
* See description in header file for argument/return detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
const void *CFE_Config_GetObjPointer(CFE_ConfigId_t ConfigId) | ||
{ | ||
const CFE_Config_ValueEntry_t *Entry; | ||
|
||
Entry = CFE_Config_LocateConfigRecordByID(ConfigId); | ||
if (Entry == NULL || (Entry->ActualType != CFE_ConfigType_POINTER && Entry->ActualType != CFE_ConfigType_STRING)) | ||
{ | ||
return NULL; | ||
} | ||
|
||
return Entry->Datum.AsPointer; | ||
} | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: CFE_Config_GetObjPointer | ||
* | ||
* Defined per public API | ||
* See description in header file for argument/return detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
const char *CFE_Config_GetString(CFE_ConfigId_t ConfigId) | ||
{ | ||
const CFE_Config_ValueEntry_t *Entry; | ||
|
||
Entry = CFE_Config_LocateConfigRecordByID(ConfigId); | ||
if (Entry == NULL || Entry->ActualType != CFE_ConfigType_STRING) | ||
{ | ||
return CFE_Config_Global.UnknownString; | ||
} | ||
|
||
return Entry->Datum.AsPointer; | ||
} | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: CFE_Config_GetName | ||
* | ||
* Defined per public API | ||
* See description in header file for argument/return detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
const char *CFE_Config_GetName(CFE_ConfigId_t ConfigId) | ||
{ | ||
uint32 OffsetVal; | ||
|
||
OffsetVal = CFE_Config_IdToOffset(ConfigId); | ||
|
||
if (OffsetVal >= CFE_ConfigIdOffset_MAX) | ||
{ | ||
return CFE_Config_Global.UnknownString; | ||
} | ||
|
||
return CFE_CONFIG_IDNAME_MAP[OffsetVal].Name; | ||
} | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: CFE_Config_GetIdByName | ||
* | ||
* Defined per public API | ||
* See description in header file for argument/return detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
CFE_ConfigId_t CFE_Config_GetIdByName(const char *Name) | ||
{ | ||
const CFE_Config_IdNameEntry_t *NamePtr; | ||
uint32 OffsetVal; | ||
|
||
NamePtr = CFE_CONFIG_IDNAME_MAP; | ||
for (OffsetVal = 0; OffsetVal < CFE_ConfigIdOffset_MAX; ++OffsetVal) | ||
{ | ||
if (NamePtr->Name != NULL && strcmp(NamePtr->Name, Name) == 0) | ||
{ | ||
break; | ||
} | ||
++NamePtr; | ||
} | ||
|
||
if (OffsetVal >= CFE_ConfigIdOffset_MAX) | ||
{ | ||
return CFE_CONFIGID_UNDEFINED; | ||
} | ||
|
||
return CFE_Config_OffsetToId(OffsetVal); | ||
} | ||
|
||
/*---------------------------------------------------------------- | ||
* | ||
* Function: CFE_Config_GetIdByName | ||
* | ||
* Defined per public API | ||
* See description in header file for argument/return detail | ||
* | ||
*-----------------------------------------------------------------*/ | ||
void CFE_Config_IterateAll(void *Arg, CFE_Config_Callback_t Callback) | ||
{ | ||
const CFE_Config_IdNameEntry_t *NamePtr; | ||
uint32 OffsetVal; | ||
|
||
NamePtr = CFE_CONFIG_IDNAME_MAP; | ||
for (OffsetVal = 0; OffsetVal < CFE_ConfigIdOffset_MAX; ++OffsetVal) | ||
{ | ||
if (CFE_Config_Global.Table[OffsetVal].ActualType != CFE_ConfigType_UNDEFINED) | ||
{ | ||
Callback(Arg, CFE_Config_OffsetToId(OffsetVal), NamePtr->Name); | ||
} | ||
++NamePtr; | ||
} | ||
} |
Oops, something went wrong.