/[svn]/linuxsampler/trunk/src/engines/common/AbstractInstrumentManager.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/engines/common/AbstractInstrumentManager.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3733 - (hide annotations) (download) (as text)
Sat Feb 1 18:11:20 2020 UTC (4 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 3201 byte(s)
NKSP: Added support for 'patch' variables.

* NKSP language: Added support for 'patch' variable qualifier
  (as new dedicated keyword 'patch').

* NKSP parser: capture locations of 'patch' variable declarations
  in script's source code.

* ScriptVM: Allow patching 'patch' script variables by replacing
  their default assignment expression with a supplied replacement
  variable initialization expression by optional 2nd argument when
  calling loadScript().

* ScriptVM: Allow retrieval of default initialization expressions
  of all 'patch' variables by optional 3rd argument when calling
  loadScript() (i.e. for instrument editors).

* gig engine: Implemented support for loading real-time instrument
  scripts with 'patch' variables bundled with gig instruments.

* Bumped version (2.1.1.svn46).


1 schoenebeck 2611 /*
2 schoenebeck 3733 * Copyright (c) 2014-2020 Christian Schoenebeck
3 schoenebeck 2611 *
4     * http://www.linuxsampler.org
5     *
6     * This file is part of LinuxSampler and released under the same terms.
7     * See README file for details.
8     */
9    
10     #ifndef LS_ABSTRACTINSTRUMENTMANAGER_H
11     #define LS_ABSTRACTINSTRUMENTMANAGER_H
12    
13     #include "../InstrumentManager.h"
14     #include "../../common/ResourceManager.h"
15     #include "../../common/global_private.h"
16     #include "InstrumentScriptVM.h"
17    
18     namespace LinuxSampler {
19    
20     typedef ResourceConsumer<VMParserContext> InstrumentScriptConsumer;
21    
22 schoenebeck 3733 /// Identifies uniquely a compiled script.
23     struct ScriptKey {
24     String code; ///< Script's source code.
25     std::map<String,String> patchVars; ///< Patch variables being overridden by instrument.
26     bool wildcardPatchVars; ///< Seldom use: Allows lookup for consumers of a specific script by ignoring all (overridden) patch variables.
27    
28     inline bool operator<(const ScriptKey& o) const {
29     if (wildcardPatchVars)
30     return code < o.code;
31     else
32     return code < o.code || (code == o.code && patchVars < o.patchVars);
33     }
34    
35     inline bool operator>(const ScriptKey& o) const {
36     if (wildcardPatchVars)
37     return code > o.code;
38     else
39     return code > o.code || (code == o.code && patchVars > o.patchVars);
40     }
41    
42     inline bool operator==(const ScriptKey& o) const {
43     if (wildcardPatchVars)
44     return code == o.code;
45     else
46     return code == o.code && patchVars == o.patchVars;
47     }
48    
49     inline bool operator!=(const ScriptKey& o) const {
50     return !(operator==(o));
51     }
52     };
53    
54 schoenebeck 2611 class AbstractInstrumentManager : public InstrumentManager {
55     public:
56     AbstractInstrumentManager() { }
57     virtual ~AbstractInstrumentManager() { }
58    
59 schoenebeck 2902 /**
60     * Resource manager for loading and sharing the parsed (executable) VM
61     * presentation of real-time instrument scripts. The key used here, and
62     * associated with each script resource, is not as one might expect the
63     * script name or something equivalent, instead the key used is
64 schoenebeck 3733 * actually the entire script's source code text (and additionally
65     * potentially patched variables). The value (the actual resource) is of
66     * type @c VMParserContext, which is the parsed (executable) VM
67     * representation of the respective script.
68 schoenebeck 2902 */
69 schoenebeck 3733 class ScriptResourceManager : public ResourceManager<ScriptKey, VMParserContext> {
70 schoenebeck 2611 public:
71     ScriptResourceManager() {}
72     virtual ~ScriptResourceManager() {}
73     protected:
74     // implementation of derived abstract methods from 'ResourceManager'
75 schoenebeck 3733 virtual VMParserContext* Create(ScriptKey key, InstrumentScriptConsumer* pConsumer, void*& pArg);
76 schoenebeck 2611 virtual void Destroy(VMParserContext* pResource, void* pArg);
77     virtual void OnBorrow(VMParserContext* pResource, InstrumentScriptConsumer* pConsumer, void*& pArg) {} // ignore
78     } scripts;
79     };
80    
81     } // namespace LinuxSampler
82    
83     #endif // LS_ABSTRACTINSTRUMENTMANAGER_H

  ViewVC Help
Powered by ViewVC