True Axis Physics SDK 1.2.0.1 Beta Documentation
www.trueaxis.com

DescriptorLanguage.h

00001 //---------------------------------------------------------------------------------
00002 // File Name: DescriptorLanguage.h
00003 // Description:
00004 //
00005 // Copyright (C) 2004 True Axis Pty Ltd, Australia. 
00006 // All Rights Reserved.
00007 //
00008 // History:
00009 //      Created File.
00010 //---------------------------------------------------------------------------------
00011 
00012 #ifndef TA_DESCRIPTORLANGUAGE_H
00013 #define TA_DESCRIPTORLANGUAGE_H
00014 
00015 #ifndef TA_TYPES_H
00016 #include "Types.h"
00017 #endif // TA_TYPES_H
00018 
00019 #ifndef TA_STRING_H
00020 #include "String.h"
00021 #endif // TA_STRING_H
00022 
00023 #ifndef TA_DEBUG_H
00024 #include "Debug.h"
00025 #endif // TA_DEBUG_H
00026 
00027 #ifndef TA_MEMORYMGR_H
00028 #include "MemoryMgr.h"
00029 #endif // TA_MEMORYMGR_H
00030 
00031 #ifndef TA_DESCRIPTORITEMNUMERIC_H
00032 #include "DescriptorItemNumeric.h"
00033 #endif // TA_DESCRIPTORITEMNUMERIC_H
00034 
00035 #ifndef TA_DESCRIPTORITEMLIST_H
00036 #include "DescriptorItemList.h"
00037 #endif // TA_DESCRIPTORITEMLIST_H
00038 
00039 namespace TA
00040 {
00041 
00042 class Descriptor;
00043 class DescriptorItem;
00044 class DescriptorItemLabel;
00045 
00046 class TACOMMON_CLASS DescriptorLanguage
00047 {
00048 public:
00049     DescriptorLanguage();
00050     virtual ~DescriptorLanguage();
00051 
00052     void Initialise(const String& strName, const String& strFileName);
00053     void Finalise();
00054 
00055     bool IsInitialised() const { return m_bIsInitialised; }
00056 
00057     void InitialiseDescriptor(Descriptor& descriptor);
00058 
00059     DescriptorItem* GetRootItem() { TA_ASSERT(m_pParent); TA_ASSERT((u32)m_pParent == (u32)m_pRoot); return m_pParent; }
00060         
00061     void BeginDescGroup(const Char* szGroupName);
00062     void EndDescGroup();
00063 
00064     void AddDescItem(
00065         const Char* szName,                         // Name
00066         Descriptor* pDescriptor,
00067         String& strVar,                             // Editable variable
00068         const Char* szDefault,                      // Default value
00069         const Char* szDescription);                 // Description
00070 
00071     void AddDescItem(
00072         const Char* szName,                         // Name
00073         void (*SetVar)(const String&, void* pData), // Set function
00074         const String& (*GetVar)(void* pData),       // Get function
00075         const Char* szDefault,                      // Default value
00076         const Char* szDescription);                 // Description
00077 
00078     template <class Type>
00079     void AddDescItem(
00080         const Char* szName,                         // Name
00081         Descriptor* pDescriptor,
00082         Type& var,                                  // Reference to the editable variable
00083         Type defaultValue,                          // Default value
00084         Type min,                                   // Min value
00085         Type max,                                   // Max value
00086         const Char* szDescription)                  // Description
00087     {           
00088     //  DescriptorItemNumericOfType<Type>* pItem = new DescriptorItemNumericOfType<Type>();
00089         DescriptorItemNumericOfType<Type>* pItem;
00090         TA_MEMORY_MGR_NEW(pItem, DescriptorItemNumericOfType<Type>);
00091         pItem->Initialise(
00092             szName,
00093             pDescriptor,
00094             var,
00095             defaultValue,
00096             min,
00097             max,
00098             szDescription);
00099         TA_ASSERT(m_pParent);
00100         m_pParent->AddChild(pItem);
00101     }
00102 
00103 /*  template <class Type>
00104     void AddDescItem2(
00105         const Char* szName,                         // Name
00106         void (*SetVar)(Type, void* pData),          // Set function
00107         Type (*GetVar)(void* pData),                // Get function
00108         Type defaultValue,                          // Default value
00109         Type min,                                   // Min value
00110         Type max,                                   // Max value
00111         const Char* szDescription)                  // Description
00112     {
00113     //  DescriptorItemNumeric<Type>* pItem = new DescriptorItemNumeric<Type>();
00114         DescriptorItemNumeric<Type>* pItem;
00115         TA_MEMORY_MGR_NEW(pItem, DescriptorItemNumeric<Type>());
00116         pItem->Initialise(
00117             szName, 
00118             SetVar,     
00119             GetVar,     
00120             defaultValue,
00121             min,
00122             max,
00123             szDescription);
00124         TA_ASSERT(m_pParent);
00125         m_pParent->AddChild(pItem);
00126     }*/
00127     void AddDescItem(
00128         const Char* szName,                         // Name
00129         void (*SetVar)(float, void* pData),         // Set function
00130         float (*GetVar)(void* pData),               // Get function
00131         float defaultValue,                         // Default value
00132         float min,                                  // Min value
00133         float max,                                  // Max value
00134         const Char* szDescription);                 // Description
00135 
00136     void AddDescItem(
00137         const Char* szName,                         // Name
00138         void (*SetVar)(int, void* pData),           // Set function
00139         int (*GetVar)(void* pData),                 // Get function
00140         int defaultValue,                           // Default value
00141         int min,                                    // Min value
00142         int max,                                    // Max value
00143         const Char* szDescription);                 // Description  template <class Type>
00144 
00145     template <class Type>
00146     void AddDescItem(
00147         const Char* szName,                         // Name
00148         Descriptor* pDescriptor,
00149         DescriptorList<Type>& var,                  // Reference to the editable variable
00150         const Char* szDescription)                  // Description
00151     {       
00152     //  DescriptorItemListOfType<Type>* pItem = new DescriptorItemListOfType<Type>();
00153         DescriptorItemListOfType<Type>* pItem; 
00154         TA_MEMORY_MGR_NEW(pItem, DescriptorItemListOfType<Type>);
00155         pItem->Initialise(
00156             szName,
00157             pDescriptor,
00158             var,
00159             szDescription);
00160         TA_ASSERT(m_pParent);
00161         m_pParent->AddChild(pItem);
00162     }
00163 
00164 
00165 
00166 private:
00167     bool m_bIsInitialised;
00168     String m_strFileName;
00169     DescriptorItemLabel* m_pRoot;
00170     DescriptorItem* m_pParent; // used in initialising the language
00171 
00172     void InitialiseDescriptorInternal(DescriptorItem* pRoot, Descriptor& descriptor);   
00173 };
00174 
00175 };
00176 
00177 //#include "DescriptorLanguage.inl"
00178 
00179 
00180 #endif // TA_DESCRIPTORLANGUAGE_H


© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.