Using AcArray

Using AcArray

Anonymous
Not applicable
717 Views
3 Replies
Message 1 of 4

Using AcArray

Anonymous
Not applicable
Hi everybody,

Has anyone successfuly used an AcArray of the form

typedef AcArray MyClassArray

and got around the problems with defining the new[] operator?
0 Likes
718 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Please publish your code and somebody can help you.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Try something like

class DLLIMPEXP MyClass : public AcDbObject
{
public:

ACRX_DECLARE_MEMBERS(MyClass);

// Constructor / Destructor
MyClass();
virtual ~MyClass();

//{{AFX_ARX_METHODS(MyClass)
virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler) const;
virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler);
virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
//}}AFX_ARX_METHODS


//{{AFX_ARX_DATA_ACCESS(MyClass)
Acad::ErrorStatus setStartVertex(const Adesk::Int16 StartVertex);
Adesk::Int16 startVertex();
//}}AFX_ARX_DATA_ACCESS


private:
//{{AFX_ARX_DATA(MyClass)
Adesk::Int16 m_StartVertex;
//}}AFX_ARX_DATA


private:

void *operator new[](unsigned nSize) { return 0; }
void operator delete[](void *p) {};
void *operator new[](unsigned nSize, const char *file, int line) { return
0; }

};

typedef AcArray MyClassArray;


If you attempt to include a data member of type MyClassArray in another
class, the compiler will complain about not being able to access the new[]
and delete[] operators, because they are defined as private (by the Wizard).
There is a note in the header for AcDbObject that this is because of a
Microsoft compiler problem with deleting destructors. It also says you can
get around it by using your own new[] and delete[] operators, but that you
should not use them. Unfortunately, the AcArray template class will try to
use them, so what should you do?

Thanks

James.


>"dgoceva" wrote in message
news:[email protected]...
>Please publish your code and somebody can help you.
0 Likes
Message 4 of 4

Anonymous
Not applicable
try this
typedef AcArray MyClassArray;

the form of AcArray is
AcArray

were T is the type and R is the Reallocator the default type for R is
AcArrayMemCopyReallocator that is way you had problems with the array. You
can't do a strait mem copy of an object.

"James" wrote in message
news:[email protected]...
> Try something like
>
> class DLLIMPEXP MyClass : public AcDbObject
> {
> public:
>
> ACRX_DECLARE_MEMBERS(MyClass);
>
> // Constructor / Destructor
> MyClass();
> virtual ~MyClass();
>
> //{{AFX_ARX_METHODS(MyClass)
> virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler) const;
> virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler);
> virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
> virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
> //}}AFX_ARX_METHODS
>
>
> //{{AFX_ARX_DATA_ACCESS(MyClass)
> Acad::ErrorStatus setStartVertex(const Adesk::Int16 StartVertex);
> Adesk::Int16 startVertex();
> //}}AFX_ARX_DATA_ACCESS
>
>
> private:
> //{{AFX_ARX_DATA(MyClass)
> Adesk::Int16 m_StartVertex;
> //}}AFX_ARX_DATA
>
>
> private:
>
> void *operator new[](unsigned nSize) { return 0; }
> void operator delete[](void *p) {};
> void *operator new[](unsigned nSize, const char *file, int line) { return
> 0; }
>
> };
>
> typedef AcArray MyClassArray;
>
>
> If you attempt to include a data member of type MyClassArray in another
> class, the compiler will complain about not being able to access the new[]
> and delete[] operators, because they are defined as private (by the
Wizard).
> There is a note in the header for AcDbObject that this is because of a
> Microsoft compiler problem with deleting destructors. It also says you can
> get around it by using your own new[] and delete[] operators, but that you
> should not use them. Unfortunately, the AcArray template class will try to
> use them, so what should you do?
>
> Thanks
>
> James.
>
>
> >"dgoceva" wrote in message
> news:[email protected]...
> >Please publish your code and somebody can help you.
>
>
0 Likes