2009-11-13 16:45:49 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2011-01-30 18:05:38 +03:00
|
|
|
#ifndef _PACKAGE__HPKG__PRIVATE__STACKER_H_
|
|
|
|
#define _PACKAGE__HPKG__PRIVATE__STACKER_H_
|
2009-11-13 16:45:49 +03:00
|
|
|
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
namespace BPackageKit {
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
namespace BHPKG {
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
|
2009-11-13 16:45:49 +03:00
|
|
|
template<typename Type>
|
|
|
|
class Stacker {
|
|
|
|
public:
|
|
|
|
Stacker(Type*& location, Type* element)
|
|
|
|
:
|
|
|
|
fLocation(&location),
|
|
|
|
fPreviousElement(location)
|
|
|
|
{
|
|
|
|
*fLocation = element;
|
|
|
|
}
|
|
|
|
|
|
|
|
Stacker(Type** location, Type* element)
|
|
|
|
:
|
|
|
|
fLocation(location),
|
|
|
|
fPreviousElement(*location)
|
|
|
|
{
|
|
|
|
*fLocation = element;
|
|
|
|
}
|
|
|
|
|
|
|
|
~Stacker()
|
|
|
|
{
|
|
|
|
if (fLocation != NULL)
|
|
|
|
*fLocation = fPreviousElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Type** fLocation;
|
|
|
|
Type* fPreviousElement;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
} // namespace BHPKG
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
2011-01-30 18:05:38 +03:00
|
|
|
#endif // _PACKAGE__HPKG__PRIVATE__STACKER_H_
|