Files
Upsilon/layout_reference.h
Léa Saviot 0af06b5f3a Add Layouts
2018-06-25 13:37:28 +02:00

51 lines
1.3 KiB
C++

#ifndef LAYOUT_REFERENCE_H
#define LAYOUT_REFERENCE_H
#include "tree_reference.h"
//#include "layout_cursor.h"
#include "layout_node.h"
template <typename T>
class LayoutReference : public TreeReference<T> {
friend class LayoutCursor;
public:
using TreeReference<T>::TreeReference;
/* Allow every LayoutReference<T> to be transformed into a
* LayoutReference<LayoutNode>, i.e. Layout */
operator LayoutReference<LayoutNode>() const {
// TODO: make sure this is kosher
return *(reinterpret_cast<const LayoutReference<LayoutNode> *>(this));
}
LayoutReference<LayoutNode> * pointer() {
return (reinterpret_cast<LayoutReference<LayoutNode> *>(this));
}
// LayoutReference<T> cursorReference() const;
void addChild(LayoutReference<LayoutNode> l) {
TreeReference<T>::addChild(l);
}
LayoutReference<LayoutNode> childAtIndex(int i) {
return TreeReference<T>::childAtIndex(i);
}
void replaceChildAtIndex(int oldChildIndex, LayoutReference<LayoutNode> newChild) {
TreeReference<T>::replaceChildAtIndex(oldChildIndex, newChild);
}
int layoutOrigin() {
return this->node()->layoutOrigin();
}
int absoluteOrigin() {
return this->node()->absoluteOrigin();
}
};
typedef LayoutReference<LayoutNode> Layout;
#endif