summaryrefslogtreecommitdiff
path: root/src/lockedarray.h
diff options
context:
space:
mode:
authorRogier Polak <rogier.l.a.polak@gmail.com>2007-02-23 19:18:28 +0000
committerRogier Polak <rogier.l.a.polak@gmail.com>2007-02-23 19:18:28 +0000
commit775404c84c3250225d43f10c4a5363e997618cb2 (patch)
tree38393287d1554d8e19471f24bc65525c79efeccb /src/lockedarray.h
parentfee8461a594770f8ef2bd826868a4ae81270a666 (diff)
downloadMana-775404c84c3250225d43f10c4a5363e997618cb2.tar.gz
Mana-775404c84c3250225d43f10c4a5363e997618cb2.tar.bz2
Mana-775404c84c3250225d43f10c4a5363e997618cb2.tar.xz
Mana-775404c84c3250225d43f10c4a5363e997618cb2.zip
Added unregistering, logout_then_exit, switch_character and switch_accountserver.
Diffstat (limited to 'src/lockedarray.h')
-rw-r--r--src/lockedarray.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/lockedarray.h b/src/lockedarray.h
index 7ec2f9da..f31292d7 100644
--- a/src/lockedarray.h
+++ b/src/lockedarray.h
@@ -46,7 +46,7 @@ class LockedArray
bool isLocked() const { return mLocked; };
T getEntry() const { return mData[mCurEntry]; };
- void setEntry(T entry) { mData[mCurEntry] = entry; };
+ void setEntry(T entry) { mData[mCurEntry] = entry; mFilled = true; };
void next();
void prev();
@@ -55,6 +55,11 @@ class LockedArray
unsigned int getSize() const { return mSize; };
+ /**
+ * Clears the array without changing size or data type
+ */
+ void clear();
+
protected:
unsigned int mSize;
@@ -62,11 +67,14 @@ class LockedArray
unsigned int mCurEntry;
bool mLocked;
+
+ bool mFilled;
};
template<class T>
LockedArray<T>::LockedArray(unsigned int size):
- mSize(size), mData(new T[size]), mCurEntry(0), mLocked(false)
+ mSize(size), mData(new T[size]), mCurEntry(0), mLocked(false),
+ mFilled(false)
{
std::fill_n(mData, mSize, (T)0);
}
@@ -107,4 +115,19 @@ void LockedArray<T>::select(unsigned int pos)
mCurEntry = 0;
}
+template<class T>
+void LockedArray<T>::clear()
+{
+ if (!mFilled) return;
+
+ delete [] mData;
+
+ mData = new T[mSize];
+
+ std::fill_n(mData, mSize, (T)0);
+
+ mCurEntry = 0;
+
+ mLocked = false;
+}
#endif