Make VariableData uncopyable but moveable

This commit is contained in:
Thomas Goyne 2012-12-09 08:06:10 -08:00
parent 482d31299b
commit 851f7f40e6
4 changed files with 17 additions and 13 deletions

View File

@ -56,18 +56,13 @@ AssOverrideParameter::AssOverrideParameter()
{
}
AssOverrideParameter::AssOverrideParameter(const AssOverrideParameter &param)
: VariableData(param)
, classification(param.classification)
, omitted(param.omitted)
AssOverrideParameter::AssOverrideParameter(AssOverrideParameter&& o)
: VariableData(std::move(o))
, classification(o.classification)
, omitted(o.omitted)
{
}
void AssOverrideParameter::operator=(const AssOverrideParameter &param) {
DeleteValue();
new(this) AssOverrideParameter(param);
}
// From ass_dialogue.h
AssDialogueBlockOverride::~AssDialogueBlockOverride() {
delete_clear(Tags);
@ -117,7 +112,7 @@ void AssDialogueBlockOverride::ProcessParameters(ProcessParametersCallback callb
}
}
AssOverrideParamProto::AssOverrideParamProto(VariableDataType type,int opt,AssParameterClass classi)
AssOverrideParamProto::AssOverrideParamProto(VariableDataType type, int opt, AssParameterClass classi)
: optional(opt)
, type(type)
, classification(classi)

View File

@ -68,6 +68,8 @@ enum AssParameterOptional {
/// A single parameter to an override tag
class AssOverrideParameter : public VariableData {
public:
AssOverrideParameter(AssOverrideParameter&&);
/// Type of parameter
AssParameterClass classification;
@ -75,8 +77,6 @@ public:
bool omitted;
AssOverrideParameter();
AssOverrideParameter(const AssOverrideParameter&);
void operator=(const AssOverrideParameter &param);
};
/// Prototype of a single override parameter

View File

@ -47,6 +47,12 @@ VariableData::VariableData() {
value = nullptr;
}
VariableData::VariableData(VariableData&& o)
: type(o.type)
, value(o.value)
{
}
VariableData::~VariableData() {
DeleteValue();
}

View File

@ -34,6 +34,8 @@
#pragma once
#include <boost/noncopyable.hpp>
namespace agi { struct Color; }
class wxString;
@ -49,7 +51,7 @@ enum VariableDataType {
class AssDialogueBlockOverride;
class VariableData {
class VariableData : private boost::noncopyable {
private:
union {
void *value;
@ -68,6 +70,7 @@ protected:
public:
VariableData();
VariableData(VariableData&& o);
virtual ~VariableData();
VariableDataType GetType() const { return type; }