Add an interface for locating a variable by key.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1811 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
DrZiplok 2011-03-25 02:46:45 +00:00
parent 5a841e41c0
commit 0431b6dc69
2 changed files with 24 additions and 0 deletions

View File

@ -159,6 +159,22 @@ AP_Var::find(const char *name)
return NULL;
}
// Find a variable by key.
//
AP_Var *
AP_Var::find(Key key)
{
AP_Var *vp;
for (vp = first(); vp; vp = vp->next()) {
if (key == vp->key()) {
return vp;
}
}
return NULL;
}
// Save the variable to EEPROM, if supported
//

View File

@ -214,6 +214,14 @@ public:
///
static AP_Var *find(const char *name);
/// Find a variable by key.
///
/// @param key The key being looked up.
/// @return A pointer to the variable, or NULL if
/// it does not exist.
///
static AP_Var *find(Key key);
/// Save the current value of the variable to EEPROM.
///
/// This interface works for any subclass that implements