mxmConfigSection.h

00001 //           ///          //                                  C++ Cross Platform
00002 //          /////        ////
00003 //         /// XXX     XXX ///            ///////////   /////////     ///   ///
00004 //        ///    XXX XXX    ///         ///             ///    ///   ///  ///
00005 //       ///       XXX       ///         /////////     ///      //  //////
00006 //      ///      XXX XXX      ///               ///   ///    ///   ///  ///
00007 //     ////    XXX     XXX    ////    ////////////  //////////    ///   ///
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems //////////////////////////////////////////////
00011 //
00012 //  $Author: khe_admin $
00013 //  $LastChangedBy: khe_admin $
00014 //  $LastChangedDate: 2007-06-29 16:03:10 +0200 (Fri, 29 Jun 2007) $
00015 //  $HeadURL: http://svn.mobotix.net/svn/mxsdk/src/mxm/trunk/include/mxm/core/mxmConfigSection.h $
00016 //
00018      //
00019      //  MOBOTIX MxPEG SDK
00020      //
00021      //  This file belongs to the C++ library released as part of the MxPEG SDK.
00022      //
00023      //  This software is licenced under the BSD licence,
00024      //  http://www.opensource.org/licenses/bsd-license.php
00025      //
00026      //  Copyright (c) 2005 - 2007, MOBOTIX AG
00027      //  All rights reserved.
00028      //
00029      //  Redistribution and use in source and binary forms, with or without
00030      //  modification, are permitted provided that the following conditions are
00031      //  met:
00032      //
00033      //  - Redistributions of source code must retain the above copyright
00034      //    notice, this list of conditions and the following disclaimer.
00035      //
00036      //  - Redistributions in binary form must reproduce the above copyright
00037      //    notice, this list of conditions and the following disclaimer in the
00038      //    documentation and/or other materials provided with the distribution.
00039      //
00040      //  - Neither the name of MOBOTIX AG nor the names of its contributors may
00041      //    be used to endorse or promote products derived from this software
00042      //    without specific prior written permission.
00043      //
00044      //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00045      //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00046      //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00047      //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00048      //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00049      //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00050      //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00051      //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00052      //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00053      //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00054      //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00055      //
00057 
00058 
00059 
00060 #ifndef __MXM_CONFIGSECTION_H__
00061 #define __MXM_CONFIGSECTION_H__
00062 
00063 
00064 
00065 #include <mxm/core/mxmPerlStyleHash.h>
00066 #include <mxm/core/mxm_generic_stuff.h>
00067 
00068 #ifdef MX_PLATFORM_CAMERA
00069   extern "C" {
00070     #include <mxsystem/mx_camera_services.h>
00071   }
00072 #endif
00073 
00074 
00075 
00127 class MXM_CORE_API mxmConfigSection : public mxmObject {
00128  
00129  public:
00130   static const char *LegacyProfileStringKey;
00131   static const char *WhitespaceCharacters;
00132   
00141 
00142     static const mxm::flags HeaderTrailerNone;
00144     static const mxm::flags HeaderLibBuildDate;
00147     static const mxm::flags HeaderSectionName;
00149     static const mxm::flags HeaderSectionOwner;
00151     static const mxm::flags HeaderTimestamp;
00153     static const mxm::flags TrailerProfileSummary;
00156     static const mxm::flags SingleLineProfiles;
00157 
00159   
00160  public:
00162 
00165   class Profile : public mxmObject {
00166    private:
00167     mxmString Name;
00168     mxmPerlStyleHash Keys;
00169    public:
00170     Profile(const mxmString &profile_name, bool case_insensitive_keys);
00171    public:
00172     const mxmString &name(void);
00173     void setName(mxmString const & new_name);
00174     mxmPerlStyleHash &keys(void);
00175     int size(void);
00176   };
00177  private:
00178   class ProfileSet : public mxmObject {
00179    private:
00180     mxmString ProfileTypeId;
00181     mxmList Profiles;
00182     bool CaseInsensitiveKeys;
00183    public:
00184     ProfileSet(const mxmString &type_id, bool case_insensitive_keys);
00185    public:
00186     const mxmString &profileTypeId(void);
00188     Profile &addorgetProfile(const mxmString &profile_name);
00190     Profile &getProfile(int const profile_index);
00192     Profile *lookupProfile(const mxmString &profile_name);
00194     mxmStringList *enumerateProfiles(void);
00196     void moveProfileToTop(const mxmString &profile_name);
00198     mxmList::Iterator iterator(void);
00200     int size(void);
00201   };
00202   
00203  private:
00204   mxmString SectionName;
00205   mxmString SectionOwner;
00206   mxmPerlStyleHash OwnKeys;
00207   mxmList ProfileSets;
00208   bool CaseInsensitiveKeys;
00209   bool IsInternal;
00210   void *StableABIDataExtension;
00211   
00212  public:
00213   mxmConfigSection();
00214   
00215  public:
00217   void setName(const mxmString &section_name);
00218 #ifdef MX_PLATFORM_CAMERA
00219 
00220   void setOwner(const mxCameraService_t owner);
00221 #endif
00222 
00223   void setOwner(const mxmString &section_owner);
00226   void setInternalMode(bool enable);
00229   bool load(const mxmStringList &config_section_file,
00230             const char **profile_type_ids = 0,
00231             bool allow_multi_line = false);
00232 /*
00234   bool load(const mxmString &section_name,
00235             const char **profile_type_ids = 0,
00236             bool allow_multi_line = false,
00237             const mxmString &filename_override = "");
00240   bool save(mxm::flags header_style = HeaderLibBuildDate
00241                                        | HeaderSectionName
00242                                        | TrailerProfileSummary,
00243             const mxmString &filename_override = "",
00244             bool dont_use_tempfile = false);
00245 */
00247   void clear();
00251   void purgeValueCharacters(const mxmString &key,
00252                             const mxmString &characters_to_purge);
00254   void dump(std::FILE *outfile = stdout);
00255   
00257   mxmString &operator[](const mxmString &key);
00259   mxmPerlStyleHash & getKeys(void);
00262   mxmPerlStyleHash &profile(const mxmString &profile_type_id,
00263                             const mxmString &profile_name);
00266   mxmPerlStyleHash &profile(const mxmString &profile_type_id,
00267                             int const profile_index,
00268                             mxmString &profile_name) const;
00271   mxmPerlStyleHash *lookupProfile(const mxmString &profile_type_id,
00272                                   const mxmString &profile_name) const;
00274   mxm::smart<mxmStringList> enumerateProfiles(const mxmString
00275                                                      &profile_type_id);
00277   void deleteProfile(const mxmString &profile_type_id,
00278                      const mxmString &profile_name);
00280   bool renameProfile(mxmString const & profile_type_id,
00281                      mxmString const & profile_name_old,
00282                      mxmString const & profile_name_new);
00285   int profileSetSize(const mxmString &profile_type_id,
00286                      mxmList::Iterator *profile_iterator = 0) const;
00288   void deleteProfileSet(const mxmString &profile_type_id);
00290   void moveProfileToTop(const mxmString &profile_type_id,
00291                         const mxmString &profile_name);
00292   
00293  private:
00295   ProfileSet &profileSet(const mxmString &type_id);
00298   ProfileSet *lookupProfileSet(const mxmString &type_id,
00299                                mxmList::Iterator *profile_set_iterator = 0)
00300               const;
00302   void announceChange(void);
00303 };
00304 
00305 
00306 
00307 #endif   // __MXM_CONFIGSECTION_H__
00308 

Generated on Fri Jun 29 17:21:04 2007 for MxPEG SDK by  doxygen 1.4.6