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 { |
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 |
* |
* |
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 |