Enum "Inheritance"?

%u wfunction at hotmail.com
Fri Feb 25 01:27:11 PST 2011


> What exactly is it that you're trying to do?


>> (1) I'm not going to create a new instance of an entire class
every single time I need to check an access mask, that's wasteful.
> I meant, you write File.open or File.isReadable which do the job
for you and don't expose OS cruft.


That's what I'm doing! I'm precisely trying to wrap the Windows NT
API, and so I'm making classes like NtObject, NtFile, NtToken, etc.,
to wrap functions like NtOpenFile, NtQueryObject, etc. (I'm aware
that some of them are undocumented, but I live with that.)

So I have different kinds of access masks:
1. Generic access masks that can be passed to _any_ procedure and
combined with any other access masks, like GENERIC_READ,
MAXIMUM_ALLOWED, etc.
2. Object-specific access masks that can be only used for specific
objects and that can be combined with each other and with generic
access masks, like FILE_READ_DATA, TOKEN_ALL_ACCESS, etc.

So I'm trying to avoid redundant code here, because any member of an
AccessMask enumeration would also be inside the FileAccess enum, the
TokenAccess enum, the ThreadAccess enum, etc. But at the same time,
I need to be able to pass both specific and generic access masks to
functions that take in specific access masks.

So the question is, what's the best way to do it?


More information about the Digitalmars-d mailing list