VPTissue Reference Manual
cpp_simshell/workspace/Workspace.h
Go to the documentation of this file.
1 #ifndef WS_WORKSPACE_H_INCLUDED
2 #define WS_WORKSPACE_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "IWorkspace.h"
23 #include "Preferences.h"
24 #include "util/FileSystemWatcher.h"
25 
26 #include <functional>
27 
28 namespace SimShell {
29 namespace Ws {
30 
45 template <class ProjectType, const std::string& index_file>
46 class Workspace : public IWorkspace, public Preferences
47 {
48 public:
52  Workspace(const std::string& path,
53  const std::string& prefs_file);
54 
57 
59  virtual ~Workspace() {}
60 
62  virtual ProjectIterator begin();
63 
65  virtual ConstProjectIterator begin() const;
66 
68  virtual ProjectIterator end();
69 
71  virtual ConstProjectIterator end() const;
72 
74  virtual ProjectIterator Add(const std::string& type, const std::string& name);
75 
77  virtual std::shared_ptr<IProject> Back();
78 
80  virtual std::shared_ptr<const IProject> Back() const;
81 
83  virtual ProjectIterator Find(const std::string& name);
84 
86  virtual ConstProjectIterator Find(const std::string& name) const;
87 
89  virtual bool IsProject(const std::string& name) const;
90 
92  virtual std::shared_ptr<IProject> Front();
93 
95  virtual std::shared_ptr<const IProject> Front() const;
96 
98  virtual std::shared_ptr<IProject> Get(const std::string& name);
99 
101  virtual std::shared_ptr<const IProject> Get(const std::string& name) const;
102 
104  virtual const std::string& GetIndexFile() const;
105 
107  virtual const std::string& GetPath() const;
108 
110  virtual const boost::property_tree::ptree& GetUserData(const std::string& user) const;
111 
113  virtual ProjectIterator New(const std::string& type, const std::string& name);
114 
116  virtual void Refresh();
117 
119  virtual ProjectIterator Rename(ProjectIterator, const std::string& new_name);
120 
122  virtual ProjectIterator Rename(const std::string& old_name, const std::string& new_name);
123 
125  virtual void Remove(ProjectIterator);
126 
128  virtual void Remove(const std::string& name);
129 
131  virtual void SetUserData(const std::string& user, const boost::property_tree::ptree&);
132 
133 private:
136 
139 
142  void Store() const;
143 
144 protected:
145  std::string m_path;
146  std::string m_prefs_file;
147  ProjectMap m_projects;
148  mutable boost::property_tree::ptree m_user_data;
150 };
151 
152 } // namespace
153 } // namespace
154 
155 #endif // end_of_inclde_guard
virtual ProjectIterator begin()
Utility class for being informed about changes to a file/directory on the filesystem.
Implementation of IPreferences.
Definition: Preferences.h:35
virtual bool IsProject(const std::string &name) const
ProjectMap m_projects
Mapping from project name to project.
Interface for Preferences.
virtual std::shared_ptr< IProject > Get(const std::string &name)
Workspace(const std::string &path, const std::string &prefs_file)
Constructor.
Definition: Workspace_def.h:40
std::string m_path
Path workspace was initialized with.
virtual ProjectIterator Rename(ProjectIterator, const std::string &new_name)
Util::FileSystemWatcher m_filesystem_watcher
Watch workspace index file for changes.
boost::property_tree::ptree m_user_data
GetUserData() with non-existing argument creates an empty user data.
Interface for workspace-like behavior.
Definition: IWorkspace.h:48
std::string m_prefs_file
Name of preferences file.
virtual std::shared_ptr< IProject > Back()
virtual const boost::property_tree::ptree & GetUserData(const std::string &user) const
Interface for IWorkspace.
virtual void Remove(ProjectIterator)
virtual void SetUserData(const std::string &user, const boost::property_tree::ptree &)
virtual ProjectIterator Add(const std::string &type, const std::string &name)
virtual void Refresh()
Abstraction of workspace on file system.
virtual const std::string & GetPath() const
virtual std::shared_ptr< IProject > Front()
virtual ProjectIterator end()
virtual const std::string & GetIndexFile() const
Definition: Workspace_def.h:94
virtual ~Workspace()
Virtual destructor.
virtual ProjectIterator Find(const std::string &name)
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
Definition for FileSystemWatcher.
virtual ProjectIterator New(const std::string &type, const std::string &name)