Skip to content

Instantly share code, notes, and snippets.

@DavidLudwig
Last active August 16, 2018 16:37
Show Gist options
  • Save DavidLudwig/561a7d698b89d1a2715b71677366c094 to your computer and use it in GitHub Desktop.
Save DavidLudwig/561a7d698b89d1a2715b71677366c094 to your computer and use it in GitHub Desktop.
/*
A proposal to reduce io2d's namespace, by combining 'basic_FOO' and 'FOO' typenames, to 'FOO'
Author: David Ludwig <[email protected]>
Version: 1
Many io2d classes have two typenames, each of which is present on all platforms.
These typenames take two forms, 'basic_FOO' and 'FOO' (for a variety of 'FOO's).
For example, given a FOO of 'path_builder', there are two type names:
1. basic_path_builder
2. path_builder
I propose that we combine as many of these typenames as possible. Following
the above example (with 'path_builder'), this would mean that:
a. the 'basic_path_builder' typename would be removed
b. the 'path_builder' typename would remain, but would (almost certainly) be
modified
c. there would be no loss of functionality, however an API break (in io2d)
would occur
Per-platorm differences, I believe (currently), should be represented via
one or more 'devices' (the name of which seems very negotiable; for the
sake of consistency, for now, 'device' will be used). 'device' may be
subclass-able, however, consideration of upcoming C++ Concepts should,
perhaps, be taken into account.
(Question for future selves: Should 'device' be broken down into smaller chunks?)
*/
namespace io2d {
/////////////////////////////////////////////////////////////////////
// High-level structs:
struct device {
device() = delete; // cannot be instantiated
...;
}
struct generic_device : device { // instantiate-able on any platform, but might not attach to any i/o hardware
...
};
/////////////////////////////////////////////////////////////////////
// Specific i/o platforms:
#if MAC
struct coregraphics_device : device {
...
};
typedef coregraphics_device default_device;
#elif WIN32
struct win32_device : device {
...
};
typedef win32_device default_device;
#else
typedef generic_device default_device;
#endif
/////////////////////////////////////////////////////////////////////
// Example of 'basic_FOO' to just 'FOO', for a FOO of 'path_builder'
template <typename Device=default_device>
struct path_builder {
...
};
// Note the lack of 'basic_path_builder'. I.e., one less bit of
// clutter, in the io2d namespace.
}; // namespace
//////////////////////////////////////////////////////////////////////
// Goal achieved?: Combined 'basic_FOO' and 'FOO', into just 'FOO', //
// via experimentation on 'io2d::path_builder' //
//////////////////////////////////////////////////////////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment