#ifndef CBWORKSPACE_H #define CBWORKSPACE_H #include #ifdef __BORLANDC__ #pragma hdrstop #endif #include #include #include "settings.h" #include "sanitycheck.h" /** * @brief A workspace class. * * Workspaces are just collections of projects. By loading a workspace, * all the projects it contains are loaded.\n * There is always a workspace open. The default one does not contain any projects.\n * Currently, no inter-project dependencies are supported but at some point * they will be ;) * * @note The way WorkspaceLoader works now, requires that you save and delete the * loaded workspace *before* creating a new one... */ class cbWorkspace { public: /** @brief Constructor * * @param filename The file from which to load the workspace. If this * parameter is empty, the default workspace is loaded. */ cbWorkspace(const wxString& filename = DEFAULT_WORKSPACE); /** @brief Destructor */ virtual ~cbWorkspace(); /** @brief Save the workspace * * @param force If false (the default), the workspace will not be written to disk, * if it is not marked as modified. * @return True if saving succeeded, false if not. */ virtual bool Save(bool force = false); /** @brief Save the workspace under a different filename * * @param filename The name of the file to save. * @return True if saving succeeded, false if not. * @note If the filename parameter is empty, a file dialog to choose * the filename to save will be displayed. */ virtual bool SaveAs(const wxString& filename); /** @brief Get the workspace file's name * * @return The name of the file this workspace was loaded from. */ virtual wxString GetFilename() { SANITY_CHECK(_T("")); return m_Filename.GetFullPath(); } /** @brief Get the workspace's title * * @return The title of the workspace. */ virtual wxString GetTitle() { SANITY_CHECK(_T("")); return m_Title; } /** @brief Set the workspace's title * * @param title The new title. */ virtual void SetTitle(const wxString& title); /** @brief Was this workspace loaded succesfully? * * @return True if the workspace was loaded succesfully, false if not. * @note Because the only way to load a workspace is through its * constructor, and because we don't use exceptions, this is the only * way to know if loading succeeded. */ virtual bool IsOK(){ SANITY_CHECK(false);return m_IsOK; } /** @brief Is this workspace the Code::Blocks default? * * @return True if the workspace is the default, false if not. */ virtual bool IsDefault(){ SANITY_CHECK(false);return m_IsDefault; } /** @brief Is this workspace modified? * * @return True if the workspace is modified, false if not. * @note A workspace is considered modified when projects * are added-to/removed-from it, when the project's order * is changed or when the active project is changed. */ virtual bool GetModified(){ SANITY_CHECK(false);return m_Modified; } /** @brief Mark the workspace as modified or not * * @param modified If true, the workspace will be marked as modified. If * false, the workspace will be marked as unmodified. */ virtual void SetModified(bool modified); protected: bool m_IsOK; // succeeded loading? bool m_IsDefault; // is this the Code::Blocks default workspace? bool m_Modified; // is it modified? wxFileName m_Filename; // filename wxString m_Title; // title private: void Load(); // utility function DECLARE_SANITY_CHECK }; #endif // CBWORKSPACE_H