DeclPDA.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __DECLPDA_H__
  21. #define __DECLPDA_H__
  22. /*
  23. ===============================================================================
  24. idDeclPDA
  25. ===============================================================================
  26. */
  27. class idDeclEmail : public idDecl {
  28. public:
  29. idDeclEmail() {}
  30. virtual size_t Size() const;
  31. virtual const char * DefaultDefinition() const;
  32. virtual bool Parse( const char *text, const int textLength, bool allowBinaryVersion );
  33. virtual void FreeData();
  34. virtual void Print() const;
  35. virtual void List() const;
  36. const char * GetFrom() const { return from; }
  37. const char * GetBody() const { return text; }
  38. const char * GetSubject() const { return subject; }
  39. const char * GetDate() const { return date; }
  40. const char * GetTo() const { return to; }
  41. private:
  42. idStr text;
  43. idStr subject;
  44. idStr date;
  45. idStr to;
  46. idStr from;
  47. };
  48. class idDeclVideo : public idDecl {
  49. public:
  50. idDeclVideo() : preview( NULL ), video( NULL ), audio( NULL ) {};
  51. virtual size_t Size() const;
  52. virtual const char * DefaultDefinition() const;
  53. virtual bool Parse( const char *text, const int textLength, bool allowBinaryVersion );
  54. virtual void FreeData();
  55. virtual void Print() const;
  56. virtual void List() const;
  57. const idMaterial * GetRoq() const { return video; }
  58. const idSoundShader * GetWave() const { return audio; }
  59. const char * GetVideoName() const { return videoName; }
  60. const char * GetInfo() const { return info; }
  61. const idMaterial * GetPreview() const { return preview; }
  62. private:
  63. const idMaterial * preview;
  64. const idMaterial * video;
  65. idStr videoName;
  66. idStr info;
  67. const idSoundShader * audio;
  68. };
  69. class idDeclAudio : public idDecl {
  70. public:
  71. idDeclAudio() : audio( NULL ) {};
  72. virtual size_t Size() const;
  73. virtual const char * DefaultDefinition() const;
  74. virtual bool Parse( const char *text, const int textLength, bool allowBinaryVersion );
  75. virtual void FreeData();
  76. virtual void Print() const;
  77. virtual void List() const;
  78. const char * GetAudioName() const { return audioName; }
  79. const idSoundShader * GetWave() const { return audio; }
  80. const char * GetInfo() const { return info; }
  81. private:
  82. const idSoundShader * audio;
  83. idStr audioName;
  84. idStr info;
  85. };
  86. class idDeclPDA : public idDecl {
  87. public:
  88. idDeclPDA() { originalEmails = originalVideos = 0; };
  89. virtual size_t Size() const;
  90. virtual const char * DefaultDefinition() const;
  91. virtual bool Parse( const char *text, const int textLength, bool allowBinaryVersion );
  92. virtual void FreeData();
  93. virtual void Print() const;
  94. virtual void List() const;
  95. virtual void AddVideo( const idDeclVideo * video, bool unique = true ) const { if ( unique ) { videos.AddUnique( video ); } else { videos.Append( video ); } }
  96. virtual void AddAudio( const idDeclAudio * audio, bool unique = true ) const { if ( unique ) { audios.AddUnique( audio ); } else { audios.Append( audio ); } }
  97. virtual void AddEmail( const idDeclEmail * email, bool unique = true ) const { if ( unique ) { emails.AddUnique( email ); } else { emails.Append( email ); } }
  98. virtual void RemoveAddedEmailsAndVideos() const;
  99. virtual const int GetNumVideos() const { return videos.Num(); }
  100. virtual const int GetNumAudios() const { return audios.Num(); }
  101. virtual const int GetNumEmails() const { return emails.Num(); }
  102. virtual const idDeclVideo *GetVideoByIndex( int index ) const { return ( index < 0 || index > videos.Num() ? NULL : videos[index] ); }
  103. virtual const idDeclAudio *GetAudioByIndex( int index ) const { return ( index < 0 || index > audios.Num() ? NULL : audios[index] ); }
  104. virtual const idDeclEmail *GetEmailByIndex( int index ) const { return ( index < 0 || index > emails.Num() ? NULL : emails[index] ); }
  105. virtual void SetSecurity( const char *sec ) const;
  106. const char * GetPdaName() const { return pdaName; }
  107. const char * GetSecurity() const {return security; }
  108. const char * GetFullName() const { return fullName; }
  109. const char * GetIcon() const { return icon; }
  110. const char * GetPost() const { return post; }
  111. const char * GetID() const { return id; }
  112. const char * GetTitle() const { return title; }
  113. private:
  114. mutable idList<const idDeclVideo *> videos;
  115. mutable idList<const idDeclAudio *> audios;
  116. mutable idList<const idDeclEmail *> emails;
  117. idStr pdaName;
  118. idStr fullName;
  119. idStr icon;
  120. idStr id;
  121. idStr post;
  122. idStr title;
  123. mutable idStr security;
  124. mutable int originalEmails;
  125. mutable int originalVideos;
  126. };
  127. #endif /* !__DECLPDA_H__ */