|
/************************************************************************
*
* Resource ID Organiser Core Library
*
* (c) Copyright 2000-2004 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
* All rights reserved.
*
************************************************************************
*
* Filename : ResourceSymbolManager.h
*
* Description : CResourceSymbolManager - manager class for resource
* symbols
*
* Compiler : Microsoft Visual C++ 6.0, Service Pack 3 or later
* Microsoft Visual C++ .NET 2003
*
* Target
* Environment : Windows 98/NT/2000/XP
*
* NOTE:
*
* This software is provided "as is" free for personal use. All
* title and copyrights in and to the software, including but not
* limited to any images, text, etc. incorporated into it, are
* owned by Anna-Jayne Metcalfe, except where acknowledged otherwise.
*
* Your may freely to use this code in your own products, PROVIDED
* this notice is not removed or modified.
*
*
* Visit http://www.annasplace.me.uk/resorg for latest updates
*
************************************************************************
*
* MODIFICATION HISTORY:
*
* This is a controlled document. See project configuration
* control tool for latest version and full version history.
*
* $Archive: /Projects/AddIns/ResOrg/ResOrgCore/ResourceSymbolManager.h $
* $Revision: 36 $
* $Date: 29/08/04 10:46 $
* $Author: Anna $
*
* $History: ResourceSymbolManager.h $
*
* ***************** Version 36 *****************
* User: Anna Date: 29/08/04 Time: 10:46
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* CResourceSymbolManager::GetSymbolCount() now supports toolbars and
* accelerators
*
* ***************** Version 35 *****************
* User: Anna Date: 23/08/04 Time: 21:36
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Added support for out of range symbol detection
*
* ***************** Version 34 *****************
* User: Anna Date: 11/07/04 Time: 16:15
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Added support for detection of out of range symbols
*
* ***************** Version 33 *****************
* User: Anna Date: 11/05/04 Time: 0:22
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* By popular request...added support for "Fixed" symbols
*
* ***************** Version 32 *****************
* User: Anna Date: 26/06/03 Time: 20:17
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Added CResourceSymbolManager::GetBaseSymbolValue() to allow the
* "Fix Conflicts" command in the Symbols Display to choose more
* appropriate values.
* 2. Replaced hardcoded base symbol values with #defines
*
* ***************** Version 31 *****************
* User: Anna Date: 20/04/03 Time: 15:33
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* CResourceSymbolManager::AreNextSymbolValuesInUse() and
* FixNextSymbolValues() are now virtual
*
* ***************** Version 30 *****************
* User: Anna Date: 15/04/03 Time: 20:50
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Improved support for base values
* 2. Removed unnecessary file guards (#pragma once works well enough)
*
* ***************** Version 29 *****************
* User: Anna Date: 3/04/03 Time: 13:31
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Added symbol base value attributes (not used yet)
*
* ***************** Version 28 *****************
* User: Anna Date: 3/03/03 Time: 20:10
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Moved XML code to its own class (CResOrgXmlWriter)
*
* ***************** Version 27 *****************
* User: Anna Date: 25/02/03 Time: 21:26
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* CResourceSymbolManager::SaveXml() is now virtual
*
* ***************** Version 26 *****************
* User: Anna Date: 19/02/03 Time: 19:20
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Started adding XML export and HTML reports
*
* ***************** Version 25 *****************
* User: Anna Date: 15/02/03 Time: 20:50
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed big BOOLs into little bools
*
* ***************** Version 24 *****************
* User: Anna Date: 3/01/03 Time: 7:38
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* CResourceSymbolManager doesn't need dynamic creation support
* (DECLARE_DYNCREATE) - changed to runtime class info support
* (DECLARE_DYNAMIC)
*
* ***************** Version 23 *****************
* User: Anna Date: 3/01/03 Time: 0:09
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Speeded up multi-file loading slightly
*
* ***************** Version 22 *****************
* User: Anna Date: 2/01/03 Time: 0:09
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Mods for compatibility with multi-file symbol editing
*
* ***************** Version 21 *****************
* User: Anna Date: 17/12/02 Time: 15:39
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* CResourceSymbolManager::Set() is now virtual
*
* ***************** Version 20 *****************
* User: Anna Date: 25/11/02 Time: 15:19
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed website address in banner
*
* ***************** Version 19 *****************
* User: Anna Date: 22/10/02 Time: 13:24
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed name/mail address (at last!)
*
* ***************** Version 18 *****************
* User: Andy Date: 1/08/02 Time: 16:28
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Added CResourceSymbolManager::m_sPathName and corresponding access
* methods
* 2. CResourceSymbolManager is now derived directly from CObject
*
* ***************** Version 17 *****************
* User: Andy Date: 7/06/02 Time: 22:22
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Eliminate warnings when compiled with VC.NET
*
* ***************** Version 16 *****************
* User: Andy Date: 7/06/02 Time: 17:04
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Renamed the ResOrgUtils module to ResOrgCore. Updated file banners
* accordingly
*
* ***************** Version 15 *****************
* User: Andy Date: 27/05/02 Time: 13:33
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Renamed CResourceSymbolBuffer as CResourceSymbolManager
* 2. Moved header file parsing/writing code to a new class
* (CResourceSymbolFileBuffer)
*
* ***************** Version 14 *****************
* User: Andy Date: 12/28/01 Time: 12:55a
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Changes to support new options and Wizard functionality
*
* ***************** Version 13 *****************
* User: Andy Date: 10/03/01 Time: 12:37p
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added CResourceSymbolBuffer::AreNextSymbolValuesInUse() and
* CalculateNextSymbolValues()
*
* ***************** Version 12 *****************
* User: Andy Date: 15/08/01 Time: 9:47
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Added extra metrics to CResourceSymbolCounts
* 2. CResourceSymbolBuffer attributes are now protected
* 3. Added access methods for "Next Symbol" values to
* CResourceSymbolBuffer
*
* ***************** Version 11 *****************
* User: Andy Date: 22/06/01 Time: 9:42
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Made class declaration "Rose friendly"
*
* ***************** Version 10 *****************
* User: Andy Date: 4/05/01 Time: 22:34
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Renumber() no longer takes the "editable symbol" base value as a
* parameter (it was never used anyway)
*
* ***************** Version 9 *****************
* User: Andy Date: 23/04/01 Time: 21:17
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Consolidated Renumber() methods
* 2. Speeded up symbol loading
*
* ***************** Version 8 *****************
* User: Andy Date: 21/04/01 Time: 7:29
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added new exported methods
*
* ***************** Version 7 *****************
* User: Andy Date: 2/04/01 Time: 17:32
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Check for name conflicts as well as value conflicts
* 2. Added IsUnique(Name/Value) methods
* 3. Added GetUnusedName() metho
*
* ***************** Version 6 *****************
* User: Andy Date: 27/03/01 Time: 15:39
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Added the capability to check resource symbol names for conflicts
* 2. Removed unused (and stubbed) Lookup() methods
*
* ***************** Version 5 *****************
* User: Andy Date: 2/03/01 Time: 16:43
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Added a CResourceSymbolValuesMap object to keep track of symbol
* values
* 2. Removed CResourceSymbolBuffer::EditReservedSymbols() [this is now
* the responsibility of CResOrgSymbolsDoc]
*
* ***************** Version 4 *****************
* User: Andy Date: 19/02/01 Time: 8:30
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added better tracking of values (alongside the existing method for
* now..)
*
* ***************** Version 3 *****************
* User: Andy Date: 17/02/01 Time: 6:54
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Added CResourceSymbolBuffer::GetDisplayedStatus() and GetSymbols()
* 2. Added support for read only symbols (the values of which saved in
* hexadecimal)
*
* ***************** Version 2 *****************
* User: Andy Date: 29/11/00 Time: 18:38
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added file banners
*
* $Nokeywords: $
*
************************************************************************/
#pragma once
#include "ResourceSymbolList.h"
#include "ResourceSymbolNamesMap.h"
#include "ResourceSymbolValuesMap.h"
class CResourceSymbol;
class CResourceSymbolManager;
typedef CTypedPtrArray<CObArray, CResourceSymbolManager*> CSymbolManagerPtrArray;
/// Helper used to to count the number of symbols of various types
///
struct RESORGCORE_EXT_CLASS CResourceSymbolCounts
{
CResourceSymbolCounts(void)
{
m_nControls = 0;
m_nResources = 0;
m_nAccelerators = 0;
m_nBitmaps = 0;
m_nIcons = 0;
m_nMenus = 0;
m_nPrompts = 0;
m_nStrings = 0;
m_nDialogs = 0;
m_nToolbars = 0;
m_nOtherResources = 0;
m_nCommands = 0;
m_uMinResource = 0;
m_uMaxResource = 0;
m_uMinCommand = 0;
m_uMaxCommand = 0;
}
int m_nControls;
int m_nResources;
int m_nAccelerators;
int m_nBitmaps;
int m_nIcons;
int m_nMenus;
int m_nPrompts;
int m_nStrings;
int m_nDialogs;
int m_nToolbars;
int m_nOtherResources;
int m_nCommands;
UINT m_uMinResource;
UINT m_uMaxResource;
UINT m_uMinCommand;
UINT m_uMaxCommand;
};
/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolManager class
#define CResourceSymbolManager_BASE CObject
class RESORGCORE_EXT_CLASS CResourceSymbolManager : public CObject
{
DECLARE_DYNAMIC(CResourceSymbolManager)
public:
CResourceSymbolManager(bool bAutoDelete = false);
CResourceSymbolManager(const CResourceSymbolManager& src);
virtual ~CResourceSymbolManager(void);
// Attributes
protected:
bool m_bAutoDelete; ///< Only used if created by CResourceSymbolConflictManager. Normally false
CString m_sResourceFileName; ///< The pathname of the resource file directly associated with this symbol
CString m_sPathName; ///< The pathname of the resource symbol file in which this symbol is defined
int m_nConflicts; ///< How many symbols with conflicting values
int m_nOutOfRangeSymbols; ///< Count of symbols whose value is outside defined ranges
int m_nProblemSymbols; ///< The total number of symbols with "problems"
bool m_bCheckForOutOfRangeSymbols; ///< Determines whether the range of values of symbols is validated
bool m_bModified;
bool m_b3dControls;
UINT m_uBaseResourceValue;
UINT m_uBaseControlValue;
UINT m_uBaseCommandValue;
UINT m_uNextResourceValue;
UINT m_uNextControlValue;
UINT m_uNextSymedValue;
UINT m_uNextCommandValue;
protected:
// The main list of symbols
CResourceSymbolList m_listSymbols;
// Used to keep track of how many symbols are using a given name/value
CResourceSymbolNamesMap m_mapNames;
CResourceSymbolValuesMap m_mapValues;
// Operators
public:
void operator=(const CResourceSymbolManager& src);
// Operations
public:
bool AutoDelete(void) const
{ return m_bAutoDelete; }
CString GetPathName(void) const
{ return m_sPathName; }
CString GetFileName(void) const;
CString GetResourceFileName(void) const
{ return m_sResourceFileName; }
int GetSymbols(CResourceSymbolList& rlistSymbols) const;
int GetSymbols( const CString& sName,
CResourceSymbolList& rlistSymbols) const;
int GetSymbols( UINT uValue,
CResourceSymbolList& rlistSymbols) const;
bool ReadSymbolFile(const CString& sPathName);
virtual bool Set( CResourceSymbol* pSymbol,
const CString& sName,
UINT uValue,
bool bReadOnly = false);
bool SetModifiedFlag(bool bModified);
bool IsModified(void) const
{ return m_bModified; }
bool Renumber( CResourceSymbolList* plistSymbols,
UINT uBaseResource,
UINT uBaseCommand,
UINT uBaseControl,
bool bIgnoreFixedStatus = false,
bool bSortByName = true);
bool Renumber( UINT uBaseResource,
UINT uBaseCommand,
UINT uBaseControl,
bool bIgnoreFixedStatus = false,
bool bSortByName = true);
bool CalculateBaseValues(UINT& ruBaseResource,
UINT& ruBaseCommand,
UINT& ruBaseControl) const;
virtual bool AreNextSymbolValuesInUse(void) const;
virtual bool FixNextSymbolValues(void);
bool CalculateNextSymbolValues( UINT& ruNextResourceValue,
UINT& ruNextControlValue,
UINT& ruNextCommandValue,
UINT& ruNextSymedValue);
bool UpdateNextSymbolValues(void);
void CountConflicts(void);
UINT GetBaseValue(int eSymbolType) const;
UINT GetBaseResourceValue(void) const
{ return m_uBaseResourceValue; }
UINT GetBaseControlValue(void) const
{ return m_uBaseControlValue; }
UINT GetBaseCommandValue(void) const
{ return m_uBaseCommandValue; }
UINT GetBaseSymbolValue(int eSymbolType) const;
bool Get3dControlsValue(void) const
{ return m_b3dControls; }
bool Set3dControlsValue(bool b3dControls);
UINT GetNextResourceValue(void) const
{ return m_uNextResourceValue; }
UINT GetNextCommandValue(void) const
{ return m_uNextCommandValue; }
UINT GetNextControlValue(void) const
{ return m_uNextControlValue; }
UINT GetNextSymedValue(void) const
{ return m_uNextSymedValue; }
bool SetBaseResourceValue(UINT uValue);
bool SetBaseControlValue(UINT uValue);
bool SetBaseCommandValue(UINT uValue);
bool SetNextResourceValue(UINT uValue);
bool SetNextCommandValue(UINT uValue);
bool SetNextControlValue(UINT uValue);
bool SetNextSymedValue(UINT uValue);
bool CheckForOutOfRangeSymbols(void) const
{ return m_bCheckForOutOfRangeSymbols; }
bool CheckForOutOfRangeSymbols(bool bCheck);
CResourceSymbol* Add( const CString& sSymbolName,
UINT uSymbolValue,
int nLineNo,
bool bUpdateMetrics = true);
bool Add( CResourceSymbol* pSymbol,
bool bUpdateMetrics = true);
bool Remove( CResourceSymbol* pSymbol,
bool bUpdateMetrics = true);
virtual void RemoveAll(void);
POSITION GetFirstSymbolPosition(void) const
{ return m_listSymbols.GetHeadPosition(); }
CResourceSymbol* GetNextSymbol(POSITION& rPos) const
{ return m_listSymbols.GetNext(rPos); }
int GetSymbolCount(void) const
{ return (int)m_listSymbols.GetCount(); }
int GetSymbolCount(CResourceSymbolCounts& rInfo) const;
void SortByName(void)
{ m_listSymbols.SortByName(); }
void SortByValue(void)
{ m_listSymbols.SortByValue(); }
CString GetDisplayedStatus(CResourceSymbol* pSymbol) const;
// Methods for dealing with symbols with "problems"
int GetConflicts(CResourceSymbolList& rlistConflicts) const;
int GetConflicts( CResourceSymbol* pSymbol,
CResourceSymbolList& rlistConflicts) const;
int GetConflictCount(void) const
{ return m_nConflicts; }
int GetOutOfRangeSymbols(CResourceSymbolList& rlistSymbols) const;
int GetOutOfRangeSymbolCount(void) const
{ return m_nOutOfRangeSymbols; }
int GetProblemSymbolCount(void) const
{ return m_nProblemSymbols; }
virtual bool IsOutOfRange(CResourceSymbol* pSymbol) const;
bool IsOutOfRange(int eSymbolType, UINT uValue) const;
bool IsUnique(const CString& sName) const;
bool IsUnique(UINT uValue) const;
bool IsInUse(const CString& sName) const;
bool IsInUse(UINT uValue) const;
CString GetUnusedName(int eType) const;
UINT GetNextFreeValue(UINT uValue) const;
// Virtual Overrides
public:
virtual void Serialize(CArchive& ar);
// Implementation
protected:
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I haven't always written software for a living. When I graduated from Surrey University in 1989, it was with an Electronic Engineering degree, but unfortunately that never really gave me the opportunity to do anything particularly interesting (with the possible exception of designing
Darth Vader's Codpiece * for the UK Army in 1990).
* Also known as the Standard Army Bootswitch. But that's another story...
Since the opportunity arose to lead a software team developing C++ software for
Avionic Test Systems in 1996, I've not looked back. More recently I've been involved in the development of subsea acoustic navigation systems, digital TV broadcast systems, port security/tracking systems, and most recently software development tools with my own company,
Riverblade Ltd.
One of my personal specialities is IDE plug-in development.
ResOrg was my first attempt at a plug-in, but my day to day work is with
Visual Lint, an interactive code analysis tool environment with works within the Visual Studio and Eclipse IDEs or on build servers.
I love lots of things, but particularly music, photography and anything connected with history or engineering. I
despise ignorant, intolerant and obstructive people - and it shows...I can be a bolshy cow if you wind me up the wrong way...
I'm currently based 15 minutes walk from the beach in Bournemouth on the south coast of England. Since I moved here I've grown to love the place - even if it is full of grockles in Summer!