namespace.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef _namespace_h_
  2. #define _namespace_h_
  3. //////////////////////////////////////////////////////////////////////////////
  4. //
  5. // NameSpace
  6. //
  7. //////////////////////////////////////////////////////////////////////////////
  8. class IEngineFont;
  9. class Image;
  10. class Geo;
  11. class MDLType;
  12. class INameSpace : public IObject {
  13. public:
  14. virtual const ZString& GetName() = 0;
  15. virtual void AddMember(const ZString& strName, IObject* pobject) = 0;
  16. virtual IObject* FindMember(const ZString& strName) = 0;
  17. virtual IObject* FindMemberLocal(const ZString& strName) = 0;
  18. virtual IObject* FindMemberAndNameSpace(const ZString& str, INameSpace*& pns) = 0;
  19. virtual void AddType(const ZString& strName, MDLType* ptype) = 0;
  20. virtual MDLType* FindType(const ZString& strName) = 0;
  21. virtual MDLType* FindTypeLocal(const ZString& strName) = 0;
  22. virtual void WriteTypeHeader(ZFile* pfile) = 0;
  23. virtual void WriteToTextFile(int indent, ZFile* pfile) = 0;
  24. virtual void WriteToBinaryFile(ZFile* pfile) = 0;
  25. #ifndef DREAMCAST // these mothods break VC5
  26. float FindNumber(const ZString& strName, float valueDefault = 0)
  27. {
  28. TRef<Number> pnumber; CastTo(pnumber, FindMember(strName));
  29. return pnumber->GetValue();
  30. //return pnumber ? pnumber->GetValue() : valueDefault;
  31. }
  32. bool FindBoolean(const ZString& strName, bool valueDefault = false)
  33. {
  34. TRef<Boolean> pvalue; CastTo(pvalue, FindMember(strName));
  35. return pvalue->GetValue();
  36. //return pvalue ? pvalue->GetValue() : valueDefault;
  37. }
  38. IEngineFont* FindFont(const ZString& strName, IEngineFont* valueDefault = NULL)
  39. {
  40. TRef<FontValue> pvalue; CastTo(pvalue, FindMember(strName));
  41. return pvalue->GetValue();
  42. //return pvalue ? pvalue->GetValue() : valueDefault;
  43. }
  44. IObjectList* FindList(const ZString& strName)
  45. {
  46. TRef<IObjectList> pvalue; CastTo(pvalue, FindMember(strName));
  47. return pvalue;
  48. }
  49. const ZString& FindString(const ZString& strName, const ZString& valueDefault = ZString())
  50. {
  51. TRef<StringValue> pvalue; CastTo(pvalue, FindMember(strName));
  52. return pvalue->GetValue();
  53. //return pvalue ? pvalue->GetValue() : valueDefault;
  54. }
  55. const Color& FindColor(const ZString& strName, const Color& valueDefault = Color::White())
  56. {
  57. TRef<ColorValue> pvalue; CastTo(pvalue, FindMember(strName));
  58. return pvalue->GetValue();
  59. //return pvalue ? pvalue->GetValue() : valueDefault;
  60. }
  61. const Point& FindPoint(const ZString& strName, const Point& valueDefault = Point(0, 0))
  62. {
  63. TRef<PointValue> pvalue; CastTo(pvalue, FindMember(strName));
  64. return pvalue->GetValue();
  65. //return pvalue ? pvalue->GetValue() : valueDefault;
  66. }
  67. WinPoint FindWinPoint(const ZString& strName, const WinPoint& valueDefault = WinPoint(0, 0))
  68. {
  69. TRef<PointValue> pvalue; CastTo(pvalue, FindMember(strName));
  70. return WinPoint::Cast(pvalue->GetValue());
  71. //return pvalue ? WinPoint::Cast(pvalue->GetValue()) : valueDefault;
  72. }
  73. const Vector& FindVector(const ZString& strName, const Vector& valueDefault = Vector(0, 0, 0))
  74. {
  75. TRef<VectorValue> pvalue; CastTo(pvalue, FindMember(strName));
  76. return pvalue->GetValue();
  77. //return pvalue ? pvalue->GetValue() : valueDefault;
  78. }
  79. TRef<Image> FindImage(const ZString& strName)
  80. {
  81. TRef<Image> pvalue; CastTo(pvalue, (Value*)FindMember(strName));
  82. return pvalue;
  83. }
  84. TRef<Geo> FindGeo(const ZString& strName)
  85. {
  86. TRef<Geo> pvalue; CastTo(pvalue, (Value*)FindMember(strName));
  87. return pvalue;
  88. }
  89. #endif
  90. };
  91. typedef TList<TRef<INameSpace> > INameSpaceList;
  92. #endif