dll - working

fix in unique pointer and array - missing copy constructor
This commit is contained in:
Linda Andersson 2013-11-26 09:16:51 +01:00
parent 0db45bd63f
commit f78027a1cf
5 changed files with 43 additions and 11 deletions

View File

View File

@ -66,24 +66,28 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)..\External\Bin\DLL\$(ProjectName)\</OutDir>
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<LibraryPath>$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\External\Bin\DLL\$(ProjectName)\</OutDir>
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<LibraryPath>$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)..\External\Bin\DLL\$(ProjectName)\</OutDir>
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<LibraryPath>$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\External\Bin\DLL\$(ProjectName)\</OutDir>
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<LibraryPath>$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -95,6 +99,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>GamePhysics_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -107,6 +112,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>GamePhysics_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -123,6 +129,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>GamePhysics_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -139,6 +146,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>GamePhysics_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -47,7 +47,7 @@ Player::Player(void)
life = 10;
UniquePointer<ICustomBody> rigidBody = API::Instance().CreateSimpleRigidBody();
//ref = API::Instance().AddObject(rigidBody);
API::Instance().AddObject(rigidBody);
////ref = API::Instance().AddObject(API::Instance().CreateSimpleRigidBody());
//const ICustomBody* rB;

View File

@ -37,6 +37,14 @@ namespace Utility
this->ownedInstance = assignedInstance;
}
template<typename Type>
UniquePointer<Type>::UniquePointer( const UniquePointer<Type> &donor )
{
this->ownedInstance = donor.ownedInstance;
donor.ownedInstance = NULL;
}
template<typename Type>
UniquePointer<Type>::~UniquePointer()
{
@ -110,6 +118,14 @@ namespace Utility
this->ownedArray = assignedArray;
}
template<typename Type>
UniqueArray<Type>::UniqueArray( const UniqueArray<Type> &donor )
{
this->ownedArray = donor.ownedArray;
donor.ownedArray = NULL;
}
template<typename Type>
UniqueArray<Type>::~UniqueArray()
{

View File

@ -27,18 +27,22 @@ namespace Utility
{
public:
//! Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniquePointer.
//! If NULL is assigned is equivalent with clearing all responsibilities from this UniquePointer.
UniquePointer( Type *assignedInstance = NULL );
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned instance will be deleted.
//! If donor had nothing, is equivalent with clearing all responsibilities from this UniquePointer.
UniquePointer( const UniquePointer<Type> &donor );
//! Will auto delete assigned dynamic instance.
~UniquePointer();
//! Assigns assignedInstance ownership to this UniquePonter, old owned instance will be deleted.
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniquePointer.
//! If NULL is assigned is equivalent with clearing all responsibilities from this UniquePointer.
UniquePointer<Type> & operator = ( Type *assignedInstance );
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned instance will be deleted.
//! If donor had nothing, is equavalent with clearing all responsibilities from this UniquePointer.
//! If donor had nothing, is equivalent with clearing all responsibilities from this UniquePointer.
UniquePointer<Type> & operator = ( const UniquePointer<Type> &donor );
//! Access the assigned dynamic instance. Will crash if nothing there
@ -71,18 +75,22 @@ namespace Utility
{ //! Wrapper to safely transfer dynamic ownership/responsibility
public:
//! Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniqueArray.
//! If NULL is assigned is equivalent with clearing all responsibilities from this UniqueArray.
UniqueArray( Type assignedArray[] = NULL );
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned array will be deleted.
//! If donor had nothing, is equivalent with clearing all responsibilities from this UniqueArray.
UniqueArray( const UniqueArray<Type> &donor );
//! Will auto delete assigned dynamic array.
~UniqueArray();
//! Assigns assignedInstance ownership to this UniquePonter, old owned array will be deleted.
//! If NULL is assigned is equavalent with clearing all responsibilities from this UniqueArray.
//! If NULL is assigned is equivalent with clearing all responsibilities from this UniqueArray.
UniqueArray<Type> & operator = ( Type assignedArray[] );
//! Transfers assignedInstance ownership from donor to this UniquePonter, old owned array will be deleted.
//! If donor had nothing, is equavalent with clearing all responsibilities from this UniqueArray.
//! If donor had nothing, is equivalent with clearing all responsibilities from this UniqueArray.
UniqueArray<Type> & operator = ( const UniqueArray<Type> &donor );
//! Accesses the instance at index i of this UniqeArray's owned dynamic array.