Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Manager.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Execution_Resources_Manager_h_
5#define _Stroika_Foundation_Execution_Resources_Manager_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Common/Common.h"
10
11#include "Accessor.h"
12#include "Name.h"
13
14namespace Stroika::Foundation::Execution::Resources {
15
16 /**
17 * A resource Manager is a abstract class (effectively smart pointer) to a source of resources. You instantiate
18 * an appropriate resource manager subclass, and call ReadResource() as needed. ReadResource() returns a proxy
19 * which points to the resource data.
20 */
21 class Manager {
22 protected:
23 class _IRep {
24 public:
25 virtual ~_IRep () = default;
26 virtual Accessor ReadResource (const Name& name) const = 0;
27 };
28
29 protected:
30 static Accessor _mkAccessor (span<const byte> s);
31
32 protected:
33 explicit Manager (const shared_ptr<_IRep>& rep);
34
35 private:
36 shared_ptr<_IRep> fRep_;
37
38 public:
39 // throws if not found
40 nonvirtual Accessor ReadResource (const Name& name) const;
41
42 public:
43 // Like ReadResource () - but asserts instead of throwing if resource not found
44 nonvirtual Accessor CheckedReadResource (const Name& name) const noexcept;
45 };
46
47}
48
49/*
50 ********************************************************************************
51 ***************************** Implementation Details ***************************
52 ********************************************************************************
53 */
54#include "Manager.inl"
55
56#endif /*_Stroika_Foundation_Execution_Resources_Manager_h_*/