NCBI C++ ToolKit
project_service.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_CORE___PROJECT_SERVICE__HPP
2 #define GUI_CORE___PROJECT_SERVICE__HPP
3 
4 /* $Id: project_service.hpp 47479 2023-05-02 13:24:02Z ucko $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Mike DiCuccio, Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbimtx.hpp>
36 #include <corelib/ncbistl.hpp>
37 
40 
42 
43 #include <gui/objutils/objects.hpp>
45 
46 #include <gui/utils/mru_list.hpp>
47 
50 
52 
53 #include <set>
54 
55 #include <wx/string.h>
56 
58 
60 class CGBDocument;
61 class CProjectTreePanel;
62 
64  class CGBWorkspace;
65  class CWorkspaceFolder;
66  class CUser_object;
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// CProjectService - a service providing API for operations with Workspaces and
71 /// Projects.
72 /// CProjectService
73 ///
74 /// CProjectService shall not have any dependencies on GUI.
75 
77  public CObjectEx,
78  public IService,
80  public IRegSettings
81 {
82  friend class CWorkspaceAutoSaver;
83 public:
85  using TProjectId = objects::CGBProjectHandle::TId;
86 
87 public:
89  virtual ~CProjectService();
90 
91  /// @name IService interface implementation
92  /// @{
93  virtual void InitService();
94  virtual void ShutDownService();
95  /// @}
96 
97  /// @name IServiceLocatorConsumer interface implementation
98  /// @{
99  virtual void SetServiceLocator(IServiceLocator* locator);
100  /// @}
101 
103 
104  /// @name IRegSettings interface implementation
105  /// @{
106  virtual void SetRegistryPath(const string& path);
107  virtual void SaveSettings() const;
108  virtual void LoadSettings();
109  /// @}
110 
111  /// @name Workspace manipulators
112  /// @{
113  bool HasWorkspace();
114  void CreateNewWorkspace();
115  /// Loads a workspace from a file and optionally set as current
116  bool LoadWorkspace(const wxString& filename);
117  /// release the current workspace and all its contents TODO - review
118  void ResetWorkspace();
119  /// Save a workspace. This will (potentially) ask the user for a
120  /// filename to which to save the workspace
121  bool SaveWorkspace();
122  /// @}
123 
124  /// get MRU Projects and Workspaces
125  const TMRUPathList& GetProjectWorkspaceMRUList() const;
126  void AddToProjectWorkspaceMRUList(const wxString& path);
127  /// @}
128 
129  /// @name Project View Manipulators
130  /// @{
131  /// initialized view, connects it to a projects and adds to View Manager Service
132  CIRef<IProjectView> AddProjectView(const string& view_name, SConstScopedObject& object, const objects::CUser_object* params, bool bFloat = false);
133  CIRef<IProjectView> AddProjectView(const string& view_name, TConstScopedObjects& objects, const objects::CUser_object* params, bool bFloat = false);
134 
135  IProjectView* FindView(const CObject& mainObject, const string& viewType);
136  void FindViews(vector<CIRef<IProjectView> >& projectViews, const CObject& mainObject);
137  void FindViews(vector<CIRef<IProjectView> >& projectViews);
138 
139  CIRef<IProjectView> ShowView(const string& viewName, FWindowFactory widgetFactory, TConstScopedObjects& objects, bool bFloat);
140 
141  void ActivateProjectView(IProjectView* projectView);
142 
143  /// removes the view from View manager Service and disconnects it from the project
144  void RemoveProjectView(IProjectView& view);
145  void RemoveAllProjectViews();
146 
147  /// called by CDocument when IProjectView is attached/detached to it
148  void OnViewAttached(IProjectView* view);
149 
150  void GetObjProjects(TConstScopedObjects& objects, vector<TProjectId>& ids);
151 
152  CRef<objects::CGBWorkspace> GetGBWorkspace();
153 
154  void AddProject(CGBDocument& doc);
155  void RemoveProject(CGBDocument& doc);
156 
157  CProjectTreePanel* GetProjectTreePanel();
158 
159  const objects::CProjectItem* GetProjectItem(const CObject& object, objects::CScope& scope);
160 
161 protected:
162  CRef<objects::CGBWorkspace> x_LoadWorkspace(const wxString& filename);
163  void x_CreateDocuments(objects::CWorkspaceFolder& folder);
164 
165  void x_RemoveView(IViewManagerService& view_srv, IProjectView& view, bool reset_hist_async = true);
166 
167  void x_ReloadProjectTreeView();
168 
169  void x_UpdateWorkspaceLabel();
170 
171 private:
172  /// all constructing / copying of project managers is forbidden
174  CProjectService& operator= (const CProjectService&);
175 
176 protected:
179 
180 protected:
181  /// path in the Registry to our settings
182  string m_RegPath;
183 
185 
186  /// the only Workspace
188 
189  string m_Filename; /// filename for the workspace
190 
192 };
193 
194 
196 
197 #endif /// GUI_CORE___PROJECT_SERVICE__HPP
User-defined methods of the data storage class.
CGBDocument.
Definition: document.hpp:113
CGBWorkspace.
Definition: GBWorkspace.hpp:63
CObjectEx –.
Definition: ncbiobj.hpp:2531
CObject –.
Definition: ncbiobj.hpp:180
CProjectService - a service providing API for operations with Workspaces and Projects.
CRef< objects::CGBWorkspace > m_Workspace
the only Workspace
CProjectService(const CProjectService &)
all constructing / copying of project managers is forbidden
string m_RegPath
path in the Registry to our settings
set< int > TWorkspaceIds
IServiceLocator * GetServiceLocator()
TMRUPathList m_ProjectWorkspaceMRUList
filename for the workspace
CTimeMRUList< wxString > TMRUPathList
bool LoadWorkspace(const wxString &filename)
Loads a workspace from a file and optionally set as current.
objects::CGBProjectHandle::TId TProjectId
set< int > TProjectIds
IServiceLocator * m_ServiceLocator
CProjectTreePanel - a window that represents Project View.
IServiceLocator & m_ServiceLocator
class IProjectView defines the abstract interface for views observing projects.
IRegSettings An interface for objects that save / restore settings using CGuiRegistry.
IServiceLocatorConsumer - classes that need IServiceLocator should implement this interface.
Definition: service.hpp:103
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:71
IService an abstraction that represents an application component providing specific functional capa...
Definition: service.hpp:56
IViewManagerService IViewManagerService manages views in Workbench.
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_GUICORE_EXPORT
Definition: gui_export.h:508
wxWindow *(* FWindowFactory)(wxWindow *)
Definition: gui_widget.hpp:45
Multi-threading – mutexes; rw-locks; semaphore.
The NCBI C++/STL use hints.
Modified on Wed Dec 06 07:16:12 2023 by modify_doxy.py rev. 669887