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

View File

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

View File

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

View File

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