-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCFoo.h
More file actions
70 lines (61 loc) · 2.3 KB
/
Copy pathCFoo.h
File metadata and controls
70 lines (61 loc) · 2.3 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <iostream>
#include <Meta.hpp>
#include "CBar.h"
class CFoo
{
bool bPrint = true;
int number = 0; // CMeta::TNumber
public:
struct CMeta
{
using TMode = Meta::EResourceAccessMode;
// Resource definitions
template <TMode Mode>
using TNumber = Meta::CResourceAccess<^^CFoo::number, Mode>;
// Method definitions
using TMethodA = Meta::CMethodResources<TNumber<TMode::WRITE>,
CBar::CMeta::TPublicWriteSomeNumber,
CBar::CMeta::TPublicReadSomeString>;
using TMethodB = Meta::CMethodResources<CBar::CMeta::TMethod,
CBar::CMeta::TPublicReadSomeString>;
using TMethodC = Meta::CMethodResources<TMethodB,
CBar::CMeta::TPublicReadSomeString,
CBar::CMeta::TSetAnotherString>;
using TReadSomeString = Meta::CMethodResources<TNumber<TMode::WRITE>,
CBar::CMeta::TPublicReadSomeString>;
};
explicit CFoo(const bool bPrint = true)
: bPrint(bPrint)
{}
[[=CMeta::TMethodA{}]]
void MethodA(CBar& bar)
{
number = 1; // write access Foo::number
bar.someNumber = 0; // write access Bar::someNumber
if (bPrint)
std::cout << "Bar string: " + bar.someString + '\n'; // read access Bar::someString
}
[[=CMeta::TMethodB{}]]
void MethodB(CBar& bar)
{
bar.Method(); // inherit everything from Meta::Bar::Method
if (bPrint)
std::cout << "Bar string: " + bar.someString + '\n'; // read access Bar::someString
}
[[=CMeta::TMethodC{}]]
void MethodC(CBar& bar)
{
MethodB(bar); // inherit everything from MethodB
if (bPrint)
std::cout << "Bar string: " + bar.someString + '\n'; // read access Bar::someString
bar.SetAnotherString("Test"); // write access Bar::anotherString
}
[[=CMeta::TReadSomeString{}]]
void ReadSomeString(const CBar& bar)
{
if (bPrint)
std::cout << "Bar string: " + bar.someString + '\n'; // read access Bar::someString
number = 2; // write access Foo::number
}
};