2010-08-09 13:28:56 +00:00
|
|
|
#ifndef NALL_PROPERTY_HPP
|
|
|
|
#define NALL_PROPERTY_HPP
|
|
|
|
|
|
|
|
//nall::property implements ownership semantics into container classes
|
|
|
|
//example: property<owner>::readonly<type> implies that only owner has full
|
|
|
|
//access to type; and all other code has readonly access.
|
|
|
|
//
|
|
|
|
//this code relies on extended friend semantics from C++0x to work, as it
|
|
|
|
//declares a friend class via a template paramter. it also exploits a bug in
|
|
|
|
//G++ 4.x to work even in C++98 mode.
|
|
|
|
//
|
|
|
|
//if compiling elsewhere, simply remove the friend class and private semantics
|
|
|
|
|
|
|
|
//property can be used either of two ways:
|
|
|
|
//struct foo {
|
|
|
|
// property<foo>::readonly<bool> x;
|
|
|
|
// property<foo>::readwrite<int> y;
|
|
|
|
//};
|
|
|
|
//-or-
|
|
|
|
//struct foo : property<foo> {
|
|
|
|
// readonly<bool> x;
|
|
|
|
// readwrite<int> y;
|
|
|
|
//};
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
//return types are const T& (byref) instead of T (byval) to avoid major speed
|
2010-08-09 13:28:56 +00:00
|
|
|
//penalties for objects with expensive copy constructors
|
|
|
|
|
|
|
|
//operator-> provides access to underlying object type:
|
|
|
|
//readonly<Object> foo;
|
|
|
|
//foo->bar();
|
|
|
|
//... will call Object::bar();
|
|
|
|
|
|
|
|
//operator='s reference is constant so as to avoid leaking a reference handle
|
|
|
|
//that could bypass access restrictions
|
|
|
|
|
|
|
|
//both constant and non-constant operators are provided, though it may be
|
|
|
|
//necessary to cast first, for instance:
|
|
|
|
//struct foo : property<foo> { readonly<int> bar; } object;
|
|
|
|
//int main() { int value = const_cast<const foo&>(object); }
|
|
|
|
|
|
|
|
//writeonly is useful for objects that have non-const reads, but const writes.
|
|
|
|
//however, to avoid leaking handles, the interface is very restricted. the only
|
|
|
|
//way to write is via operator=, which requires conversion via eg copy
|
|
|
|
//constructor. example:
|
|
|
|
//struct foo {
|
|
|
|
// foo(bool value) { ... }
|
|
|
|
//};
|
|
|
|
//writeonly<foo> bar;
|
|
|
|
//bar = true;
|
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
template<typename C> struct property {
|
|
|
|
template<typename T> struct traits { typedef T type; };
|
|
|
|
|
|
|
|
template<typename T> struct readonly {
|
|
|
|
const T* operator->() const { return &value; }
|
|
|
|
const T& operator()() const { return value; }
|
|
|
|
operator const T&() const { return value; }
|
|
|
|
private:
|
|
|
|
T* operator->() { return &value; }
|
|
|
|
operator T&() { return value; }
|
|
|
|
const T& operator=(const T& value_) { return value = value_; }
|
|
|
|
T value;
|
|
|
|
friend class traits<C>::type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T> struct writeonly {
|
|
|
|
void operator=(const T& value_) { value = value_; }
|
|
|
|
private:
|
|
|
|
const T* operator->() const { return &value; }
|
|
|
|
const T& operator()() const { return value; }
|
|
|
|
operator const T&() const { return value; }
|
|
|
|
T* operator->() { return &value; }
|
|
|
|
operator T&() { return value; }
|
|
|
|
T value;
|
|
|
|
friend class traits<C>::type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T> struct readwrite {
|
|
|
|
const T* operator->() const { return &value; }
|
|
|
|
const T& operator()() const { return value; }
|
|
|
|
operator const T&() const { return value; }
|
|
|
|
T* operator->() { return &value; }
|
|
|
|
operator T&() { return value; }
|
|
|
|
const T& operator=(const T& value_) { return value = value_; }
|
|
|
|
T value;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|