CRWObjectModel.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef __CRWOBJECTMODEL_H__
  2. #define __CRWOBJECTMODEL_H__
  3. #include "Crown.h"
  4. using namespace Crown;
  5. class CRWObjectModel;
  6. class CRWDescriptor: public WithProperties
  7. {
  8. public:
  9. CRWDescriptor(CRWObjectModel* crwObjectModel, CRWDescriptor* parent, const Descriptor& descriptor, uint offset);
  10. virtual ~CRWDescriptor();
  11. const List<CRWDescriptor*>& GetChildren();
  12. Str GetFullName();
  13. CRWObjectModel* GetCRWObjectModel();
  14. inline ushort GetType()
  15. { return mType; }
  16. Str ToStr() const;
  17. virtual void OnGetProperty(const Str& name);
  18. virtual Generic GetPropertyValue(const Str& name) const;
  19. private:
  20. CRWObjectModel* mCRWObjectModel;
  21. CRWDescriptor* mParent;
  22. List<CRWDescriptor*>* mChildren;
  23. Shared<IList<Generic> > mChildrenGenericWrapper;
  24. //Descriptor Properties
  25. uint mID;
  26. ushort mType;
  27. Str mName;
  28. uint mContentOffset;
  29. uint mContentSize;
  30. //TODO: Use uchar
  31. ushort mFlags;
  32. uint mDescriptorOffset;
  33. friend class CRWObjectModel;
  34. };
  35. class CRWObjectModel: public IWithProperties
  36. {
  37. public:
  38. CRWObjectModel(CRWDecoder* decoder);
  39. virtual ~CRWObjectModel();
  40. inline const IList<CRWDescriptor*>* GetRoot()
  41. {
  42. if (mRoot.IsNull())
  43. mRoot = LoadChildren(NULL);
  44. return mRoot.GetPointer();
  45. }
  46. Str GetCRWLibraryPath();
  47. virtual Generic GetPropertyValue(const Str& name) const;
  48. virtual void SetPropertyValue(const Str& name, const Generic& value);
  49. virtual Str ToStr() const
  50. {
  51. return "CRWObjectModel";
  52. }
  53. private:
  54. CRWDecoder* mDecoder;
  55. Shared<IList<CRWDescriptor*> > mRoot;
  56. List<CRWDescriptor*>* LoadChildren(CRWDescriptor* descriptor);
  57. friend class CRWDescriptor;
  58. };
  59. inline const List<CRWDescriptor*>& CRWDescriptor::GetChildren()
  60. {
  61. if (!mChildren)
  62. mChildren = mCRWObjectModel->LoadChildren(this);
  63. return *mChildren;
  64. }
  65. #endif /* __CRWOBJECTMODEL_H__ */