Hello,
I don't think this is a repeat question, as I'm not getting a physical error, it's just plain not letting me do something. So I have a custom-made data structure that I made a while back, (an AVL Tree as visual studio doesn't have a good one built in), and it was coded in c++ (it's verified to have none or rare memory leaks). I want to use it in unity but when I created a CLR class in visual studio 2008 and connected it with the c++ class, and plugged in the methods and such, when creating the DLL it doesn't seem to want to be referenced in the unity project I'm making.
As in, I'll drag it to the assets folder and unity will do it's thing, then when I go into visual studio it doesn't recognize any new classes like "AVLTreeWrapper" or even a using statement. Dragging it into visual studio itself doesn't do anything either. Any help?
Here is the main blocks of code for the wrapper:
// CppWrapper.h
#ifndef AVLTREE_WRAPPER
#define AVLTREE_WRAPPER
//#pragma once
#define NODE TreeNode*&
using namespace System;
#include "C:\Users\[redacted]\Documents\Visual Studio 2017\Projects\AVLTree\AVLTree\AVLTree.h"
#include "C:\Users\[redacted]\Documents\Visual Studio 2017\Projects\AVLTree\AVLTree\dllqueue.h"
#include "C:\Users\[redacted]\Documents\Visual Studio 2017\Projects\AVLTree\AVLTree\TreeNode.h"
#include "C:\Users\[redacted]\Documents\Visual Studio 2017\Projects\AVLTree\AVLTree\AVLTree.cpp"
namespace CppWrapper {
public ref class AVLTreeWrapper
{
public:
AVLTreeWrapper();
AVLTreeWrapper(int keyToInsert);
~AVLTreeWrapper();
NODE Insert(int data); //for users
NODE Insert(NODE n, int data); //for users
NODE Insert(NODE n, int data, bool& toCheck); //the recursive algorithm
void leftBalance(NODE n, bool& toCheck);
void rightBalance(NODE n, bool& toCheck);
void rotateLeft(NODE n);
void rotateRight(NODE n);
bool AVLDelete(int data); //if they only give the key
void Purge();
void InOrderTraversal(TreeNode& node, void(*visit)(TreeNode& n));
void PreOrderTraversal(TreeNode& node, void(*visit)(TreeNode& n));
void PostOrderTraversal(TreeNode& node, void(*visit)(TreeNode& n));
void BreadthFirstTraversal(TreeNode& node, void(*visit)(TreeNode& n));
NODE retrieve(int data);
NODE retrieve(NODE node, int data);
int height();
private:
AVLTree* treePointer;
int itemCount;
TreeNode* root;
};
}
#endif
// CPPWrapper.cpp
#include "stdafx.h"
#include "CppWrapper.h"
#include "C:\Users\[redacted]\Documents\Visual Studio 2017\Projects\AVLTree\AVLTree\dllqueue.h"
#include "C:\Users\Wyatt\Documents\Visual Studio 2017\Projects\AVLTree\AVLTree\TreeNode.h"
#include "C:\Users\[redacted]\Documents\Visual Studio 2017\Projects\AVLTree\AVLTree\AVLTree.h"
#include "C:\Users\[redacted]\Documents\Visual Studio 2017\Projects\AVLTree\AVLTree\AVLTree.cpp"
CppWrapper::AVLTreeWrapper::AVLTreeWrapper()
{
treePointer = new AVLTree();
}
CppWrapper::AVLTreeWrapper::AVLTreeWrapper(int keyToInsert)
{
treePointer = new AVLTree(keyToInsert);
}
CppWrapper::AVLTreeWrapper::~AVLTreeWrapper()
{
treePointer->Purge();
delete treePointer;
}
NODE CppWrapper::AVLTreeWrapper::Insert(int data)
{
return treePointer->Insert(data);
}
NODE CppWrapper::AVLTreeWrapper::Insert(NODE n, int data)
{
return treePointer->Insert(n, data);
}
NODE CppWrapper::AVLTreeWrapper::Insert(NODE n, int data, bool & toCheck)
{
return treePointer->Insert(n, data, toCheck);
}
void CppWrapper::AVLTreeWrapper::leftBalance(NODE n, bool & toCheck)
{
treePointer->leftBalance(n, toCheck);
}
void CppWrapper::AVLTreeWrapper::rightBalance(NODE n, bool & toCheck)
{
treePointer->rightBalance(n, toCheck);
}
void CppWrapper::AVLTreeWrapper::rotateLeft(NODE n)
{
treePointer->rotateLeft(n);
}
void CppWrapper::AVLTreeWrapper::rotateRight(NODE n)
{
treePointer->rotateRight(n);
}
bool CppWrapper::AVLTreeWrapper::AVLDelete(int data)
{
return treePointer->AVLDelete(data);
}
void CppWrapper::AVLTreeWrapper::Purge()
{
treePointer->Purge();
}
void CppWrapper::AVLTreeWrapper::InOrderTraversal(TreeNode& node, void(*visit)(TreeNode&n))
{
treePointer->InOrderTraversal(node, visit);
}
void CppWrapper::AVLTreeWrapper::PreOrderTraversal(TreeNode& node, void(*visit)(TreeNode&n))
{
treePointer->PreOrderTraversal(node, visit);
}
void CppWrapper::AVLTreeWrapper::PostOrderTraversal(TreeNode& node, void(*visit)(TreeNode&n))
{
treePointer->PostOrderTraversal(node, visit);
}
void CppWrapper::AVLTreeWrapper::BreadthFirstTraversal(TreeNode& node, void(*visit)(TreeNode&n))
{
treePointer->BreadthFirstTraversal(node, visit);
}
NODE CppWrapper::AVLTreeWrapper::retrieve(int data)
{
return treePointer->retrieve(data);
}
NODE CppWrapper::AVLTreeWrapper::retrieve(NODE node, int data)
{
return treePointer->retrieve(node, data);
}
int CppWrapper::AVLTreeWrapper::height()
{
return treePointer->height();
}
↧