ModDocTemplate.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * ModDocTemplate.h
  3. * ----------------
  4. * Purpose: CDocTemplate and CModDocManager specializations for CModDoc.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #include <unordered_set>
  12. OPENMPT_NAMESPACE_BEGIN
  13. class CModDoc;
  14. namespace mpt { class PathString; }
  15. class CModDocTemplate: public CMultiDocTemplate
  16. {
  17. std::unordered_set<CModDoc *> m_documents; // Allow faster lookup of open documents than MFC's linear search allows for
  18. public:
  19. CModDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass):
  20. CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass) {}
  21. CDocument* OpenTemplateFile(const mpt::PathString &filename, bool isExampleTune = false);
  22. CDocument* OpenDocumentFile(LPCTSTR lpszPathName, BOOL addToMru = TRUE, BOOL makeVisible = TRUE) override;
  23. void AddDocument(CDocument *doc) override;
  24. void RemoveDocument(CDocument *doc) override;
  25. bool DocumentExists(const CModDoc *doc) const;
  26. size_t size() const { return m_documents.size(); }
  27. bool empty() const { return m_documents.empty(); }
  28. auto begin() { return m_documents.begin(); }
  29. auto begin() const { return m_documents.begin(); }
  30. auto cbegin() const { return m_documents.cbegin(); }
  31. auto end() { return m_documents.end(); }
  32. auto end() const { return m_documents.end(); }
  33. auto cend() const { return m_documents.cend(); }
  34. };
  35. class CModDocManager : public CDocManager
  36. {
  37. public:
  38. CDocument *OpenDocumentFile(LPCTSTR lpszFileName, BOOL bAddToMRU = TRUE) override;
  39. BOOL OnDDECommand(LPTSTR lpszCommand) override;
  40. };
  41. OPENMPT_NAMESPACE_END