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

Diff of /linuxsampler/trunk/src/common/ResourceManager.h

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

revision 957 by schoenebeck, Mon Nov 27 21:34:55 2006 UTC revision 958 by schoenebeck, Wed Nov 29 19:48:38 2006 UTC
# Line 93  class ResourceConsumer { Line 93  class ResourceConsumer {
93   *   *
94   * Descendants of this base class have to implement the (protected)   * Descendants of this base class have to implement the (protected)
95   * Create() and Destroy() methods to create and destroy a resource.   * Create() and Destroy() methods to create and destroy a resource.
96     *
97     * Note: this template class is not thread safe, so if thread safety is
98     * needed the descendant has to add synchronization methods on its own.
99   */   */
100  template<class T_key, class T_res>  template<class T_key, class T_res>
101  class ResourceManager {  class ResourceManager {
# Line 330  class ResourceManager { Line 333  class ResourceManager {
333          }          }
334    
335          /**          /**
336             * Returns true in case the resource associated with \a Key is
337             * currently created / "alive".
338             *
339             * @param Key - ID of resource
340             */
341            bool IsCreated(T_key Key) {
342                return Resource(Key) != NULL;
343            }
344    
345            /**
346           * Returns custom data sticked to the given resource previously by           * Returns custom data sticked to the given resource previously by
347           * a SetCustomData() call.           * a SetCustomData() call.
348           *           *
# Line 442  class ResourceManager { Line 455  class ResourceManager {
455                  }                  }
456              }              }
457          }          }
458    
459            /**
460             * Returns pointer to the resource associated with \a Key if
461             * currently created / "alive", NULL otherwise. This method
462             * should be taken with great care in multi-threaded scenarios,
463             * since the returned resource might be destroyed by a concurrent
464             * HandBack() call.
465             *
466             * @param Key - ID of resource
467             */
468            T_res* Resource(T_key Key) {
469                typename ResourceMap::iterator iterEntry = ResourceEntries.find(Key);
470                return (iterEntry == ResourceEntries.end()) ? NULL : iterEntry->second.resource;
471            }
472  };  };
473    
474  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.957  
changed lines
  Added in v.958

  ViewVC Help
Powered by ViewVC