-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIFooBar.h
More file actions
48 lines (42 loc) · 1.43 KB
/
Copy pathIFooBar.h
File metadata and controls
48 lines (42 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <Meta.hpp>
namespace Meta::FooBar
{
struct MCBarFooVirtualMethod;
struct MCFooBarVirtualMethod;
struct MCBarFooAbstractMethod;
struct MCFooBarAbstractMethod;
}
// Interface for CFooBar and CBarFoo
class IFooBar
{
protected:
int fooBarNum = 0; // CMeta::TFooBarNum
public:
struct CMeta
{
using TMode = Meta::EResourceAccessMode;
// Resource definitions
template <TMode Mode>
using TFooBarNum = Meta::CResourceAccess<^^IFooBar::fooBarNum, Mode>;
// Method definitions
// Since we don't know which derived class is going to be used at runtime,
// we include the resource definitions from all derived classes at compile-time
// and from IFooBar itself.
// The type list filters will deal with duplicates and read-write pairs.
using TAbstractMethod = Meta::CMethodResources<Meta::FooBar::MCFooBarAbstractMethod,
Meta::FooBar::MCBarFooAbstractMethod,
TFooBarNum<TMode::WRITE>>;
using TVirtualMethod = Meta::CMethodResources<Meta::FooBar::MCFooBarVirtualMethod,
Meta::FooBar::MCBarFooVirtualMethod>;
};
virtual ~IFooBar() = default;
[[=CMeta::TAbstractMethod{}]]
virtual int AbstractMethod() // abstract
{
fooBarNum = 1; // write access IFooBar::fooBarNum
return fooBarNum;
}
[[=CMeta::TVirtualMethod{}]]
virtual int VirtualMethod() = 0; // pure virtual
};