2002-05-31 14:43:23 +00:00
|
|
|
#ifndef CCONFIG_H
|
|
|
|
#define CCONFIG_H
|
2001-10-06 14:13:28 +00:00
|
|
|
|
|
|
|
#include "BasicTypes.h"
|
|
|
|
#include "CString.h"
|
|
|
|
#include <map>
|
|
|
|
|
2002-05-31 14:43:23 +00:00
|
|
|
class CConfig {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2001-10-06 14:13:28 +00:00
|
|
|
enum EDirection { kLeft, kRight, kTop, kBottom,
|
|
|
|
kFirstDirection = kLeft, kLastDirection = kBottom };
|
2001-11-19 00:33:36 +00:00
|
|
|
enum EDirectionMask { kLeftMask = 1, kRightMask = 2,
|
|
|
|
kTopMask = 4, kBottomMask = 8 };
|
2002-05-30 16:13:16 +00:00
|
|
|
private:
|
|
|
|
class CCell {
|
|
|
|
public:
|
|
|
|
CString m_neighbor[kLastDirection - kFirstDirection + 1];
|
|
|
|
};
|
|
|
|
typedef std::map<CString, CCell> CCellMap;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef CCellMap::const_iterator internal_const_iterator;
|
|
|
|
class const_iterator : public std::iterator<
|
|
|
|
std::bidirectional_iterator_tag,
|
|
|
|
CString, ptrdiff_t, CString*, CString&> {
|
|
|
|
public:
|
|
|
|
explicit const_iterator() : m_i() { }
|
|
|
|
explicit const_iterator(const internal_const_iterator& i) : m_i(i) { }
|
|
|
|
|
|
|
|
const_iterator& operator=(const const_iterator& i) {
|
|
|
|
m_i = i.m_i;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
CString operator*() { return m_i->first; }
|
|
|
|
const CString* operator->() { return &(m_i->first); }
|
|
|
|
const_iterator& operator++() { ++m_i; return *this; }
|
|
|
|
const_iterator operator++(int) { return const_iterator(m_i++); }
|
|
|
|
const_iterator& operator--() { --m_i; return *this; }
|
|
|
|
const_iterator operator--(int) { return const_iterator(m_i--); }
|
|
|
|
bool operator==(const const_iterator& i) const {
|
|
|
|
return (m_i == i.m_i);
|
|
|
|
}
|
|
|
|
bool operator!=(const const_iterator& i) const {
|
|
|
|
return (m_i != i.m_i);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2002-05-31 14:43:23 +00:00
|
|
|
CConfig::internal_const_iterator m_i;
|
2002-05-30 16:13:16 +00:00
|
|
|
};
|
2001-10-06 14:13:28 +00:00
|
|
|
|
2002-05-31 14:43:23 +00:00
|
|
|
CConfig();
|
|
|
|
virtual ~CConfig();
|
2001-10-06 14:13:28 +00:00
|
|
|
|
|
|
|
// manipulators
|
|
|
|
|
|
|
|
// add/remove screens
|
|
|
|
void addScreen(const CString& name);
|
|
|
|
void removeScreen(const CString& name);
|
|
|
|
void removeAllScreens();
|
|
|
|
|
|
|
|
// connect edges
|
|
|
|
void connect(const CString& srcName,
|
|
|
|
EDirection srcSide,
|
|
|
|
const CString& dstName);
|
|
|
|
void disconnect(const CString& srcName,
|
|
|
|
EDirection srcSide);
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
2002-05-30 16:13:16 +00:00
|
|
|
// iterators over screen names
|
|
|
|
const_iterator begin() const;
|
|
|
|
const_iterator end() const;
|
|
|
|
|
2001-10-06 14:13:28 +00:00
|
|
|
// get the neighbor in the given direction. returns the empty string
|
|
|
|
// if there is no neighbor in that direction.
|
2001-10-14 16:58:01 +00:00
|
|
|
CString getNeighbor(const CString&, EDirection) const;
|
2001-10-06 14:13:28 +00:00
|
|
|
|
2001-10-14 14:37:41 +00:00
|
|
|
// get the name of a direction (for debugging)
|
|
|
|
static const char* dirName(EDirection);
|
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2001-10-06 14:13:28 +00:00
|
|
|
CCellMap m_map;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|