mxmConfigSection Class Reference
[modularMX Runtime Platform Core]

In-RAM representation of a camera configuration file section featuring convenient access methods. More...

#include <mxmodularMX/mxmConfigSection.h>

Inheritance diagram for mxmConfigSection:

mxmObject List of all members.

Public Member Functions

void setName (const mxmString &section_name)
 Renames the config section.
void setOwner (const mxmString &section_owner)
 Sets owner of the config section.
void setInternalMode (bool enable)
 Specifies whether or not the config section is an internal one (alternate directory in filesystem).
bool load (const mxmStringList &config_section_file, const char **profile_type_ids=0, bool allow_multi_line=false)
 Loads the config section from a string list holding a config section file in memory.
void clear ()
 Deletes all key/value pairs, those in profiles as well as the direct ones.
void purgeValueCharacters (const mxmString &key, const mxmString &characters_to_purge)
 In all profiles, and in the config section's set of own direct keys, this method visits all key/value pairs mathing the key specified, and removes from their value strings the specified characters.
void dump (std::FILE *outfile=stdout)
 For testing purposes.
mxmStringoperator[] (const mxmString &key)
 Returns a reference to the value for one of the config section's own keys.
mxmPerlStyleHashgetKeys (void)
 Returns a reference to the list of key / value pairs (w/o profile data).
mxmPerlStyleHashprofile (const mxmString &profile_type_id, const mxmString &profile_name)
 The profile and respective profile set are transparently created if not already present.
mxmPerlStyleHashprofile (const mxmString &profile_type_id, int const profile_index, mxmString &profile_name) const
 Returns the profile referenced through profile_type_id and profile_index (starting with 0).
mxmPerlStyleHashlookupProfile (const mxmString &profile_type_id, const mxmString &profile_name) const
 Returns the specified profile stored in the config section, or 0 in case such is not present.
mxm::smart< mxmStringListenumerateProfiles (const mxmString &profile_type_id)
 Returns the list of currently present profiles for the given profile type.
void deleteProfile (const mxmString &profile_type_id, const mxmString &profile_name)
 Removes the specified profile if present.
bool renameProfile (mxmString const &profile_type_id, mxmString const &profile_name_old, mxmString const &profile_name_new)
 Rename the specified profile if present and return true on success.
int profileSetSize (const mxmString &profile_type_id, mxmList::Iterator *profile_iterator=0) const
 Returns the number of profiles in the specified profile set, or -1 if the set is not present.
void deleteProfileSet (const mxmString &profile_type_id)
 Removes the profile set for the specified profile type (if present).
void moveProfileToTop (const mxmString &profile_type_id, const mxmString &profile_name)
 Move the specified profile to the beginning of its profile set.

Static Public Attributes

static const char * LegacyProfileStringKey = "_legacy_profile_string_"
static const char * WhitespaceCharacters = mxm::WhitespaceCharacters
Format Style Flags
When saving the configuration to a file using save(), you can control the format and have various information written to the configuration file as comments. These flags describe how control the configuration file format.

static const mxm::flags HeaderTrailerNone = 1
 No comments.
static const mxm::flags HeaderLibBuildDate = 2
 Library build date.
static const mxm::flags HeaderSectionName = 4
 Section name, set with setName() or with constructor mxmConfigSection().
static const mxm::flags HeaderSectionOwner = 8
 Section owner, set with setOwner().
static const mxm::flags HeaderTimestamp = 16
 Time of writing of configuration file.
static const mxm::flags TrailerProfileSummary = 32
 Internal debugging data.
static const mxm::flags SingleLineProfiles = 64
 Write Profiles in single lines (instead of multiple, which is the default).

Private Member Functions

ProfileSet & profileSet (const mxmString &type_id)
 This method adds the profile set if not already present.
ProfileSet * lookupProfileSet (const mxmString &type_id, mxmList::Iterator *profile_set_iterator=0) const
 Private helper method, returns 0 if the profile set is not present.
void announceChange (void)
 Announces change to the config section in a system-wide fashion.

Private Attributes

mxmString SectionName
mxmString SectionOwner
mxmPerlStyleHash OwnKeys
mxmList ProfileSets
bool CaseInsensitiveKeys
bool IsInternal
void * StableABIDataExtension

Classes

class  Profile
 Represents a single profile within a config section. More...
class  ProfileSet

Detailed Description

In-RAM representation of a camera configuration file section featuring convenient access methods.

In order to be able to read in and process MX camera configuration files from a C++ application, a convenient and sufficiently comfortable mechanism was needed. This class is it.

The class was also introduced to work towards a unification of configuration file format and access. Sadly, as of May 08, 2006, there are numerous variants of configuration file formats in use on MX cameras. As a result, the class' parser was designed to be configurable, so that it can actually deal with most of them. However, it is most desirable to have a unified file format for camera configuration, so maybe we will continually switch the older files to the new, unified format.

Configuration File Structure

The abstract conceptional structure of the camera configuration file is as follows.

Author:
[khe] Kai Hergenroether


Member Function Documentation

void mxmConfigSection::announceChange void   )  [private]
 

Announces change to the config section in a system-wide fashion.

If the config section is an internal one, the method does nothing.

void mxmConfigSection::dump std::FILE *  outfile = stdout  ) 
 

For testing purposes.

Prints out the current config section RAM image (to stdout).

bool mxmConfigSection::load const mxmStringList config_section_file,
const char **  profile_type_ids = 0,
bool  allow_multi_line = false
 

Loads the config section from a string list holding a config section file in memory.

If profile_type_ids is non-0, any string in this array is used as profile type identifier, enabling alternate parsing of input lines having a regular key matching one of those ids.

If allow_multi_line is set to true, the method will allow lines that span multiple text file lines separated by backslashes.

Returns:
If anything goes wrong, the config section RAM object is cleared of all keys and profiles and false is returned. Otherwise, the method returns true.

mxmPerlStyleHash * mxmConfigSection::lookupProfile const mxmString profile_type_id,
const mxmString profile_name
const
 

Returns the specified profile stored in the config section, or 0 in case such is not present.

The config section retains ownership over the profile.

mxmString & mxmConfigSection::operator[] const mxmString key  ) 
 

Returns a reference to the value for one of the config section's own keys.

If returned string is null-string, the queried key is not present.

Simply relays the call to the repective operator of the encapsuled mxmPerlStyleHash holding the config section's own keys. Consult that operator's documetnation for details.

mxmPerlStyleHash & mxmConfigSection::profile const mxmString profile_type_id,
int const   profile_index,
mxmString profile_name
const
 

Returns the profile referenced through profile_type_id and profile_index (starting with 0).

The name of the profile found is stored in profile_name.

int mxmConfigSection::profileSetSize const mxmString profile_type_id,
mxmList::Iterator profile_iterator = 0
const
 

Returns the number of profiles in the specified profile set, or -1 if the set is not present.

In case the profile set is present, and profile_iterator is given, an iterator for the respective profiles is copied to this location. This is an mxmList::Iterator for a list holding mxmConfigSection::Profile objects.

void mxmConfigSection::setInternalMode bool  enable  ) 
 

Specifies whether or not the config section is an internal one (alternate directory in filesystem).

Internal mode defaults to off.

Only affects generation of correct path to configfile.

void mxmConfigSection::setOwner const mxmString section_owner  ) 
 

Sets owner of the config section.

The owner of the configuration section. Can be written to the configuration file when appropriate HeaderTrailer flags are passed into save().


The documentation for this class was generated from the following files:
Generated on Fri Jun 29 17:21:04 2007 for MxPEG SDK by  doxygen 1.4.6