Commit c04b7838 authored by Alexey.Musinov's avatar Alexey.Musinov Committed by Alexander Trofimov

refactoring

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@59881 954022d7-b5bf-4e40-9824-e11837661b57
parent db1692b5
...@@ -7,6 +7,119 @@ ...@@ -7,6 +7,119 @@
#include "string.h" #include "string.h"
#endif #endif
#if 1 //__APPLE__
#include <vector>
template <class T>
class CArray
{
public:
// Construction/destruction
CArray()
{ }
~CArray()
{ }
CArray(const CArray<T>& src)
{
int nSrcSize = src.GetCount();
if (0 != nSrcSize)
{
for (int i = 0; i < nSrcSize; i++)
Add(src[i]);
}
}
CArray<T>& operator=(const CArray<T>& src)
{
int nSrcSize = src.GetCount();
RemoveAll();
for (int i = 0; i < nSrcSize; i++)
Add(src[i]);
return *this;
}
// Operations
int GetSize() const
{
return (int)m_aT.size();
}
int GetCount() const
{
return (int)m_aT.size();
}
INT SetCount(int nAllocSize)
{
RemoveAll();
for (int i = 0; i < nAllocSize; i++)
Add();
return TRUE;
}
INT Add()
{
T element;
m_aT.push_back(element);
return TRUE;
}
INT Add(const T& t)
{
m_aT.push_back(t);
return TRUE;
}
INT RemoveAt(int nIndex)
{
m_aT.erase(m_aT.begin() + nIndex);
return TRUE;
}
INT RemoveAt(int nIndex, int nCount)
{
m_aT.erase(m_aT.begin() + nIndex, m_aT.begin() + nIndex + nCount);
return TRUE;
}
void RemoveAll()
{
m_aT.clear();
}
const T& operator[] (int nIndex) const
{
if (nIndex < 0 || nIndex >= (int)m_aT.size())
{
return m_aT[0]; // exeption
}
return m_aT[nIndex];
}
T& operator[] (int nIndex)
{
if (nIndex < 0 || nIndex >= (int)m_aT.size())
{
return m_aT[0]; // exeption
}
return m_aT[nIndex];
}
private:
std::vector<T> m_aT;
};
#else
// NOTE: при определенных условиях ловим исключения в деструкторе класса (T)CArray()::~CArray()
template <class T> template <class T>
class CArray class CArray
{ {
...@@ -211,5 +324,7 @@ private: ...@@ -211,5 +324,7 @@ private:
int m_nAllocSize; int m_nAllocSize;
}; };
#endif
#endif // !defined(_GRAPHICS_ARRAY_H) #endif // !defined(_GRAPHICS_ARRAY_H)
#ifndef _BUILD_IRENDERER_H_ #ifndef _BUILD_IRENDERER_H_
#define _BUILD_IRENDERER_H_ #define _BUILD_IRENDERER_H_
#pragma once #pragma once
...@@ -7,10 +7,17 @@ ...@@ -7,10 +7,17 @@
#include "Matrix.h" #include "Matrix.h"
#include <string> #include <string>
#include <libkern/OSAtomic.h>
class IGrObject class IGrObject
{ {
protected: protected:
#ifdef __APPLE__
volatile int32_t m_lRef;
#else
ULONG m_lRef; ULONG m_lRef;
#endif
public: public:
IGrObject() IGrObject()
...@@ -22,11 +29,27 @@ public: ...@@ -22,11 +29,27 @@ public:
{ {
} }
#ifdef __APPLE__
virtual ULONG AddRef()
{
OSAtomicIncrement32(&m_lRef);
return (ULONG)m_lRef;
}
virtual ULONG Release()
{
int32_t ret = OSAtomicDecrement32(&m_lRef);
if (0 == m_lRef)
delete this;
return (ULONG)ret;
}
#else
virtual ULONG AddRef() virtual ULONG AddRef()
{ {
++m_lRef; ++m_lRef;
return m_lRef; return m_lRef;
} }
virtual ULONG Release() virtual ULONG Release()
{ {
ULONG ret = --m_lRef; ULONG ret = --m_lRef;
...@@ -34,6 +57,7 @@ public: ...@@ -34,6 +57,7 @@ public:
delete this; delete this;
return ret; return ret;
} }
#endif
}; };
// тип в DrawPath // тип в DrawPath
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment