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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3732 by schoenebeck, Tue May 3 14:00:16 2016 UTC revision 3733 by schoenebeck, Sat Feb 1 18:11:20 2020 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014-2016 Christian Schoenebeck   * Copyright (c) 2014-2020 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 19  namespace LinuxSampler { Line 19  namespace LinuxSampler {
19    
20      typedef ResourceConsumer<VMParserContext> InstrumentScriptConsumer;      typedef ResourceConsumer<VMParserContext> InstrumentScriptConsumer;
21    
22        /// 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      class AbstractInstrumentManager : public InstrumentManager {      class AbstractInstrumentManager : public InstrumentManager {
55      public:      public:
56          AbstractInstrumentManager() { }          AbstractInstrumentManager() { }
# Line 29  namespace LinuxSampler { Line 61  namespace LinuxSampler {
61           * presentation of real-time instrument scripts. The key used here, and           * presentation of real-time instrument scripts. The key used here, and
62           * associated with each script resource, is not as one might expect the           * associated with each script resource, is not as one might expect the
63           * script name or something equivalent, instead the key used is           * script name or something equivalent, instead the key used is
64           * actually the entire script's source code text. The value (the actual           * actually the entire script's source code text (and additionally
65           * resource) is of type @c VMParserContext, which is the parsed           * potentially patched variables). The value (the actual resource) is of
66           * (executable) VM representation of the respective script.           * type @c VMParserContext, which is the parsed (executable) VM
67             * representation of the respective script.
68           */           */
69          class ScriptResourceManager : public ResourceManager<String, VMParserContext> {          class ScriptResourceManager : public ResourceManager<ScriptKey, VMParserContext> {
70          public:          public:
71              ScriptResourceManager() {}              ScriptResourceManager() {}
72              virtual ~ScriptResourceManager() {}              virtual ~ScriptResourceManager() {}
73          protected:          protected:
74              // implementation of derived abstract methods from 'ResourceManager'              // implementation of derived abstract methods from 'ResourceManager'
75              virtual VMParserContext* Create(String Key, InstrumentScriptConsumer* pConsumer, void*& pArg);              virtual VMParserContext* Create(ScriptKey key, InstrumentScriptConsumer* pConsumer, void*& pArg);
76              virtual void Destroy(VMParserContext* pResource, void* pArg);              virtual void Destroy(VMParserContext* pResource, void* pArg);
77              virtual void OnBorrow(VMParserContext* pResource, InstrumentScriptConsumer* pConsumer, void*& pArg) {} // ignore              virtual void OnBorrow(VMParserContext* pResource, InstrumentScriptConsumer* pConsumer, void*& pArg) {} // ignore
78          } scripts;          } scripts;

Legend:
Removed from v.3732  
changed lines
  Added in v.3733

  ViewVC Help
Powered by ViewVC