Isomet Modular Synthesiser (iMS) API  v1.4.2
iMS API
FileSystem.h
Go to the documentation of this file.
1 /*-----------------------------------------------------------------------------
2 / Title : Synthesiser File System Header
3 / Project : Isomet Modular Synthesiser System
4 /------------------------------------------------------------------------------
5 / File : $URL: http://nutmeg.qytek.lan/svn/sw/trunk/09-Isomet/iMS_SDK/API/FileSystem/h/FileSystem.h $
6 / Author : $Author: dave $
7 / Company : Isomet (UK) Ltd
8 / Created : 2015-04-09
9 / Last update: $Date: 2017-09-11 23:55:34 +0100 (Mon, 11 Sep 2017) $
10 / Platform :
11 / Standard : C++11
12 / Revision : $Rev: 300 $
13 /------------------------------------------------------------------------------
14 / Description:
15 /------------------------------------------------------------------------------
16 / Copyright (c) 2015 Isomet (UK) Ltd. All Rights Reserved.
17 /------------------------------------------------------------------------------
18 / Revisions :
19 / Date Version Author Description
20 / 2015-04-09 1.0 dc Created
21 /
22 /----------------------------------------------------------------------------*/
23 
72 
73 #ifndef IMS_FILESYSTEM_H__
74 #define IMS_FILESYSTEM_H__
75 
76 #include "IMSSystem.h"
77 #include "IEventHandler.h"
78 
79 #include <memory>
80 #include <array>
81 
83 #if defined _WIN32 || defined __CYGWIN__
84  #ifdef __GNUC__
85  #define DLL_EXPORT __attribute__ ((dllexport))
86  #define DLL_IMPORT __attribute__ ((dllimport))
87  #else
88  #define DLL_EXPORT __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
89  #define DLL_IMPORT __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
90  #endif
91  #define DLL_LOCAL
92 #else
93  #if __GNUC__ >= 4
94  #define DLL_EXPORT __attribute__ ((visibility ("default")))
95  #define DLL_IMPORT __attribute__ ((visibility ("default")))
96  #define DLL_LOCAL __attribute__ ((visibility ("hidden")))
97  #else
98  #define DLL_EXPORT
99  #define DLL_IMPORT
100  #define DLL_LOCAL
101  #endif
102 #endif
103 
104 #if defined(_EXPORTING_IMS)
105  #define LIBSPEC DLL_EXPORT
106  #define LIBLOCAL DLL_LOCAL
107  #define EXPIMP_TEMPLATE
108 #elif defined(_STATIC_IMS)
109  #define LIBSPEC
110  #define LIBLOCAL
111  #define EXPIMP_TEMPLATE
112 #else
113  #define LIBSPEC DLL_IMPORT
114  #define LIBLOCAL DLL_LOCAL
115  #define EXPIMP_TEMPLATE extern
116 #endif
117 
119 namespace iMS
120 {
124  enum class FileSystemTypes : std::uint8_t
125  {
127  NO_FILE = 0,
129  COMPENSATION_TABLE = 1,
131  TONE_BUFFER = 2,
133  DDS_SCRIPT = 3,
135  USER_DATA = 15
136  };
137 
141  enum class FileDefault : bool
142  {
144  DEFAULT = true,
146  NON_DEFAULT = false
147  };
148 
150  using FileSystemIndex = int;
151 
165  struct LIBSPEC FileSystemTableEntry
166  {
169 
180  FileSystemTableEntry(FileSystemTypes type, std::uint32_t addr, std::uint32_t length, FileDefault def);
188  FileSystemTableEntry(FileSystemTypes type, std::uint32_t addr, std::uint32_t length, FileDefault def, std::string name);
190  ~FileSystemTableEntry();
192  FileSystemTableEntry(const FileSystemTableEntry &);
194  FileSystemTableEntry &operator =(const FileSystemTableEntry &);
196 
198 
199  const FileSystemTypes Type() const;
202  const std::uint32_t Address() const;
204  const std::uint32_t Length() const;
206  const bool IsDefault() const;
208  const std::string Name() const;
210 
211  private:
212  // Declare Implementation
213  class Impl;
214  Impl * p_Impl;
215  };
216 
218  const unsigned int MAX_FST_ENTRIES = 33;
219 
226  class LIBSPEC FileSystemTableViewer
227  {
228  public:
231 
232  FileSystemTableViewer(const IMSSystem& ims) : myiMS(ims) {};
246 
248 
249  const bool IsValid() const;
261  const int Entries() const;
263 
265  const FileSystemTableEntry operator[](const std::size_t idx) const;
282 
308  friend LIBSPEC std::ostream& operator<< (std::ostream& stream, const FileSystemTableViewer&);
309  private:
310  // Make this object non-copyable
312  FileSystemTableViewer& operator= (const FileSystemTableViewer& other);
313 
314  const IMSSystem& myiMS;
315  };
316 
323  class LIBSPEC FileSystemManager
324  {
325  public:
328 
345 
347 
348  bool Delete(FileSystemIndex index);
365  bool Delete(const std::string& FileName);
377  bool SetDefault(FileSystemIndex index);
383  bool SetDefault(const std::string& FileName);
389  bool ClearDefault(FileSystemIndex index);
395  bool ClearDefault(const std::string& FileName);
405  bool Sanitize();
407 
409 
410  bool FindSpace(std::uint32_t& addr, const std::vector<std::uint8_t>& data) const;
421 
432  bool Execute(FileSystemIndex index);
436  bool Execute(const std::string& FileName);
438  private:
439  // Make this object non-copyable
441  const FileSystemManager &operator =(const FileSystemManager &);
442 
443  // Declare Implementation
444  class Impl;
445  Impl * p_Impl;
446  };
447 
454  class LIBSPEC UserFileReader
455  {
456  public:
459 
460  UserFileReader(const IMSSystem& ims, const FileSystemIndex index);
481  UserFileReader(const IMSSystem& ims, const std::string& FileName);
483  ~UserFileReader();
485 
487 
488  bool Readback(std::vector<std::uint8_t>& data);
497  private:
498  // Make this object non-copyable
500  const UserFileReader &operator =(const UserFileReader &);
501  // Declare Implementation
502  class Impl;
503  Impl * p_Impl;
504  };
505 
512  class LIBSPEC UserFileWriter
513  {
514  public:
517 
518  UserFileWriter(IMSSystem& ims, const std::vector<std::uint8_t>& file_data, const std::string file_name);
541  ~UserFileWriter();
543 
545 
546  FileSystemIndex Program();
559  private:
560  // Make this object non-copyable
562  const UserFileWriter &operator =(const UserFileWriter &);
563 
564  // Declare Implementation
565  class Impl;
566  Impl * p_Impl;
567  };
568 
569 }
570 
571 #undef EXPIMP_TEMPLATE
572 #undef LIBSPEC
573 #endif
Provides a mechanism for viewing the FileSystemTable associated with an iMS System.
Definition: FileSystem.h:226
File contains ToneBuffer data.
FileSystemTypes
All of the different (up to 15) types of file available to the filesystem.
Definition: FileSystem.h:124
FileDefault
Default flag tags a file entry for execution at startup (only one per filetype)
Definition: FileSystem.h:141
Non-default is the normal state for most files.
Contains all the parameters that uniquely locate a File within the Synthesiser FileSystem.
Definition: FileSystem.h:165
Interface Class for User Application code to receive and process events from the iMS library...
Provides user management operations for working with Synthesiser FileSystems.
Definition: FileSystem.h:323
An object representing the overall configuration of an attached iMS System and permits applications t...
Definition: IMSSystem.h:361
Default indicates the Synthesiser should attempt to execute that file during its startup procedure...
int FileSystemIndex
FileSystemIndex represents the entry number for a particular file in the FileSystemTable.
Definition: FileSystem.h:150
File contains user data for application use.
The entire API is encapsulated by the iMS namespace.
Definition: Auxiliary.h:95
Classes within this group are used to store information about an iMS System and to Connect / Disconne...
Provides a mechanism for retrieving User File data from the Synthesiser FileSystem.
Definition: FileSystem.h:454
const unsigned int MAX_FST_ENTRIES
Maximum number of entries that may be stored in the FileSystem.
Definition: FileSystem.h:218
File contains a DDS Script for manual programming of the DDS.
File contains Compensation table data.
Provides a mechanism for committing User File data to the Synthesiser FileSystem. ...
Definition: FileSystem.h:512
No file stored at this FileSystemTable entry.