VPTissue Reference Manual
cpp_simshell/workspace/Project.h
Go to the documentation of this file.
1 #ifndef WS_PROJECT_H_INCLUDED
2 #define WS_PROJECT_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 "IProject.h"
23 #include "Preferences.h"
24 #include "session/ISession.h"
25 #include "util/FileSystemWatcher.h"
26 
27 namespace SimShell {
28 namespace Ws {
29 
44 template <class FileType, const std::string& index_file>
45 class Project : public IProject,
46  public Preferences
47 {
48 public:
51  Project(const std::string& path,
52  const std::string& prefs_file,
53  const std::shared_ptr<IWorkspace>& w);
54 
57 
59  virtual ~Project() {}
60 
62  virtual FileIterator Add(const std::string& name);
63 
65  virtual std::shared_ptr<IFile> Back();
66 
68  virtual std::shared_ptr<const IFile> Back() const;
69 
71  virtual FileIterator begin();
72 
74  virtual ConstFileIterator begin() const;
75 
77  virtual FileIterator end();
78 
80  virtual ConstFileIterator end() const;
81 
83  virtual void Close();
84 
86  virtual FileIterator Find(const std::string& name);
87 
89  virtual ConstFileIterator Find(const std::string& name) const;
90 
92  virtual std::shared_ptr<IFile> Front();
93 
95  virtual std::shared_ptr<const IFile> Front() const;
96 
98  virtual std::shared_ptr<IFile> Get(const std::string& name);
99 
101  virtual std::shared_ptr<const IFile> 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 std::shared_ptr<Session::ISession> GetSession() const;
111 
113  virtual std::string GetSessionFileName() const;
114 
116  virtual const boost::property_tree::ptree& GetUserData(const std::string& user) const;
117 
119  virtual bool IsLeaf(const std::string& name) const;
120 
122  virtual bool IsOpened() const;
123 
125  virtual bool IsWatchingDirectory() const;
126 
128  virtual void Open();
129 
131  virtual void Open(const std::string& name);
132 
134  virtual void Open(FileIterator);
135 
137  virtual void Refresh();
138 
140  virtual void Remove(const std::string& name);
141 
143  virtual void Remove(FileIterator);
144 
146  virtual Session::ISession& Session() const;
147 
149  virtual void SetWatchingDirectory(bool);
150 
152  virtual void SetUserData(const std::string& user, const boost::property_tree::ptree&);
153 
154 private:
157 
160 
162  void Store();
163 
164 protected:
165  std::string m_path;
166  std::shared_ptr<IWorkspace> m_workspace;
167  std::shared_ptr<Session::ISession> m_session;
168  std::string m_session_name;
169  FileMap m_files;
170  mutable boost::property_tree::ptree m_user_data;
172 };
173 
174 } // namespace
175 } // namespace
176 
177 #endif // end_of_inclde_guard
Utility class for being informed about changes to a file/directory on the filesystem.
Implementation of IPreferences.
Definition: Preferences.h:35
Util::FileSystemWatcher m_filesystem_watcher
Watches project directory for changes.
virtual FileIterator Add(const std::string &name)
Definition: Project_def.h:82
Interface for project-like behavior.
Definition: IProject.h:59
virtual bool IsWatchingDirectory() const
Definition: Project_def.h:252
Interface for Preferences.
virtual Session::ISession & Session() const
Definition: Project_def.h:346
virtual void Remove(const std::string &name)
Definition: Project_def.h:323
virtual void SetWatchingDirectory(bool)
Definition: Project_def.h:355
virtual std::shared_ptr< IFile > Get(const std::string &name)
Definition: Project_def.h:178
Abstraction of project in workspace on file system.
boost::property_tree::ptree m_user_data
User data. Mutable because a GetUserData() with non-existing argument will create an empty user data ...
virtual std::string GetSessionFileName() const
Definition: Project_def.h:222
std::string m_session_name
Name of opened file.
Interface for IProject.
virtual bool IsLeaf(const std::string &name) const
Definition: Project_def.h:240
Project(const std::string &path, const std::string &prefs_file, const std::shared_ptr< IWorkspace > &w)
Constructor.
virtual FileIterator begin()
Definition: Project_def.h:110
virtual bool IsOpened() const
Definition: Project_def.h:246
virtual std::shared_ptr< Session::ISession > GetSession() const
Definition: Project_def.h:214
Interface for ISession.
virtual ~Project()
Virtual destructor.
std::shared_ptr< Session::ISession > m_session
Opened state.
virtual std::shared_ptr< IFile > Back()
Definition: Project_def.h:97
virtual FileIterator end()
Definition: Project_def.h:134
std::shared_ptr< IWorkspace > m_workspace
Workspace to which project belongs.
std::string m_path
Path of project directory.
virtual void SetUserData(const std::string &user, const boost::property_tree::ptree &)
Definition: Project_def.h:361
FileMap m_files
Mapping from file name to file objects.
virtual std::shared_ptr< IFile > Front()
Definition: Project_def.h:166
virtual const std::string & GetPath() const
Definition: Project_def.h:208
virtual void Close()
Definition: Project_def.h:124
virtual void Open()
Definition: Project_def.h:258
virtual const std::string & GetIndexFile() const
Definition: Project_def.h:202
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32
virtual void Refresh()
Definition: Project_def.h:279
Definition for FileSystemWatcher.
virtual const boost::property_tree::ptree & GetUserData(const std::string &user) const
Definition: Project_def.h:228
Generic session interface.
Definition: ISession.h:53
virtual FileIterator Find(const std::string &name)
Definition: Project_def.h:148