Skip to content
Snippets Groups Projects
Commit 2e8bc0f8 authored by ilor's avatar ilor
Browse files

-ccessor typo fix

parent 75026b88
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ namespace Wccl {
template<class T>
class VarGetter : public Function<T> {
public:
VarGetter(const VariableAccesor<T>& var_acc)
VarGetter(const VariableAccessor<T>& var_acc)
: var_acc_(var_acc)
{
}
......@@ -49,7 +49,7 @@ protected:
}
private:
const VariableAccesor<T> var_acc_;
const VariableAccessor<T> var_acc_;
};
......
......@@ -15,7 +15,7 @@ class VarSetter : public Function<Bool> {
public:
typedef typename boost::shared_ptr<Function<T> > ArgFunctionPtr;
VarSetter(const VariableAccesor<T>& var_acc, const ArgFunctionPtr& arg_expr)
VarSetter(const VariableAccessor<T>& var_acc, const ArgFunctionPtr& arg_expr)
: var_acc_(var_acc),
arg_expr_(arg_expr)
{
......@@ -65,7 +65,7 @@ protected:
}
private:
const VariableAccesor<T> var_acc_;
const VariableAccessor<T> var_acc_;
const ArgFunctionPtr arg_expr_;
};
......
......@@ -247,8 +247,8 @@ position_variable
: DOLLAR n: SYMBOL {
vars.get_put<Wccl::Position>(token_ref_to_std_string(n));
Wccl::VariableAccesor<Wccl::Position> acc =
vars.create_accesor<Wccl::Position>(token_ref_to_std_string(n));
Wccl::VariableAccessor<Wccl::Position> acc =
vars.create_accessor<Wccl::Position>(token_ref_to_std_string(n));
op.reset(new Wccl::VarGetter<Wccl::Position>(acc));
}
......@@ -273,9 +273,9 @@ str_set_variable
// get/put variable to variables
vars.get_put<Wccl::StrSet>(token_ref_to_std_string(n));
// makes accesor for value
Wccl::VariableAccesor<Wccl::StrSet> acc =
vars.create_accesor<Wccl::StrSet>(token_ref_to_std_string(n));
// makes accessor for value
Wccl::VariableAccessor<Wccl::StrSet> acc =
vars.create_accessor<Wccl::StrSet>(token_ref_to_std_string(n));
op.reset(new Wccl::VarGetter<Wccl::StrSet>(acc));
}
......@@ -288,8 +288,8 @@ sym_set_variable
: DOLLAR TST_PREFIX n: SYMBOL {
vars.get_put<Wccl::TSet>(token_ref_to_std_string(n));
Wccl::VariableAccesor<Wccl::TSet> acc =
vars.create_accesor<Wccl::TSet>(token_ref_to_std_string(n));
Wccl::VariableAccessor<Wccl::TSet> acc =
vars.create_accessor<Wccl::TSet>(token_ref_to_std_string(n));
op.reset(new Wccl::VarGetter<Wccl::TSet>(acc));
}
......@@ -302,8 +302,8 @@ boolean_variable
: DOLLAR BOOL_PREFIX n: SYMBOL {
vars.get_put<Wccl::Bool>(token_ref_to_std_string(n));
Wccl::VariableAccesor<Wccl::Bool> acc =
vars.create_accesor<Wccl::Bool>(token_ref_to_std_string(n));
Wccl::VariableAccessor<Wccl::Bool> acc =
vars.create_accessor<Wccl::Bool>(token_ref_to_std_string(n));
op.reset(new Wccl::VarGetter<Wccl::Bool>(acc));
}
......@@ -341,8 +341,8 @@ setvar_pos
ret_op = op_position [vars] RPAREN {
/*
Wccl::VariableAccesor<Wccl::Position> acc =
vars.create_accesor<Wccl::Position>(ret_var->acc_name());
Wccl::VariableAccessor<Wccl::Position> acc =
vars.create_accessor<Wccl::Position>(ret_var->acc_name());
op.reset(new Wccl::VarSetter<Wccl::Position>(acc, ret_op));
*/
......@@ -361,8 +361,8 @@ setvar_bool
ret_op = logical_predicates [vars] RPAREN {
/*
Wccl::VariableAccesor<Wccl::Bool> acc =
vars.create_accesor<Wccl::Bool>(ret_var->acc_name());
Wccl::VariableAccessor<Wccl::Bool> acc =
vars.create_accessor<Wccl::Bool>(ret_var->acc_name());
op.reset(new Wccl::VarSetter<Wccl::Bool>(acc, ret_op));
*/
......@@ -379,8 +379,8 @@ setvar_sset
: "setvar" LPAREN ret_var = str_set_variable [vars] COMMA
ret_op = string_operators [vars] RPAREN {
/*
Wccl::VariableAccesor<Wccl::StrSet> acc =
vars.create_accesor<Wccl::StrSet>(ret_var->acc_name());
Wccl::VariableAccessor<Wccl::StrSet> acc =
vars.create_accessor<Wccl::StrSet>(ret_var->acc_name());
op.reset(new Wccl::VarSetter<Wccl::StrSet>(acc, ret_op));
*/
......@@ -397,8 +397,8 @@ setvar_tset
: "setvar" LPAREN ret_var = sym_set_variable [vars] COMMA
ret_op = sym_set_operators [vars] RPAREN {
/*
Wccl::VariableAccesor<Wccl::TSet> acc =
vars.create_accesor<Wccl::TSet>(ret_var->acc_name());
Wccl::VariableAccessor<Wccl::TSet> acc =
vars.create_accessor<Wccl::TSet>(ret_var->acc_name());
op.reset(new Wccl::VarSetter<Wccl::TSet>(acc, ret_op));
*/
......
......@@ -27,12 +27,12 @@ public:
/// Cloning -- clones the underlying sentence as well
SentenceContext* clone() const;
/// Underlying sentence accesor
/// Underlying sentence accessor
Corpus2::Sentence& get_sentence() {
return *sentence_;
}
/// Underlying sentence accesor, const
/// Underlying sentence accessor, const
const Corpus2::Sentence& get_sentence() const {
return *sentence_;
}
......@@ -42,7 +42,7 @@ public:
return sentence_->size();
}
/// Position accesor
/// Position accessor
int get_position() const {
return position_;
}
......
......@@ -80,9 +80,9 @@ public:
};
/**
* Base class for the "fast" variable accesors.
* Base class for the "fast" variable accessors.
*/
class BaseAccesor
class BaseAccessor
{
public:
/// Variable name getter
......@@ -91,7 +91,7 @@ public:
}
protected:
/// Protected ctor, only constructed by derived classes
BaseAccesor(const std::string& varname)
BaseAccessor(const std::string& varname)
: varname_(varname)
{
}
......@@ -100,28 +100,28 @@ protected:
};
/**
* A "fast" accesor class for getting a variable off a Variables object.
* A "fast" accessor class for getting a variable off a Variables object.
*
* It should be faster to create an accesor object from the variables name and
* It should be faster to create an accessor object from the variables name and
* then use it multiple times than to use the name itself often.
*
* @todo the above is not the case yet.
*
* Objects of the accesor class can only be created by the Variables object,
* Objects of the accessor class can only be created by the Variables object,
* are valid only for that Variables object and its copies, and might stop
* working if the Variables object is touched in the wrong way in between the
* creation and use of a VariableAccesor. UB is meant by "stop working".
* creation and use of a VariableAccessor. UB is meant by "stop working".
* Bad touch is not yet fully defined, removing a variable certainly is one.
*/
template<typename T>
class VariableAccesor : public BaseAccesor
class VariableAccessor : public BaseAccessor
{
public:
protected:
/// Protected ctor, only created by Variables::create_accesor
VariableAccesor(const std::string& varname)
: BaseAccesor(varname)
/// Protected ctor, only created by Variables::create_accessor
VariableAccessor(const std::string& varname)
: BaseAccessor(varname)
{
}
......@@ -188,7 +188,7 @@ public:
return detail::Vmap<T>::get(s);
}
/** Create a "fast" accesor for a variable by name.
/** Create a "fast" accessor for a variable by name.
*
* Returns a special object which is valid for use in get_fast, which when
* used should be faster than calling get<T>(s) repeatedly.
......@@ -197,7 +197,7 @@ public:
* will be thrown, either VariableTypeMismatch or InvalidVariableName.
*/
template<typename T>
VariableAccesor<T> create_accesor(const std::string& s) {
VariableAccessor<T> create_accessor(const std::string& s) {
BOOST_MPL_ASSERT(( boost::mpl::count<types, T> ));
if (!get<T>(s)) {
if (get<Value>(s)) {
......@@ -206,22 +206,22 @@ public:
throw InvalidVariableName(s);
}
}
return VariableAccesor<T>(s);
return VariableAccessor<T>(s);
}
/** Get a variable using a "fast" accesor.
/** Get a variable using a "fast" accessor.
*
* The accesor is required to have been created by this particular object,
* The accessor is required to have been created by this particular object,
* or a copy (either way), and the Variables object must have not had
* variables removed (adding new variables should not invalidate accesors).
* variables removed (adding new variables should not invalidate accessors).
*
* If the VariableAccesor comes form a different Variables object or there
* If the VariableAccessor comes form a different Variables object or there
* have been invalidating changes to this Variables object, behavior is not
* well defined. You might get a NULL, a different variable than you
* expected, or a segfault.
*/
template<typename T>
boost::shared_ptr<T> get_fast(const VariableAccesor<T>& a) const {
boost::shared_ptr<T> get_fast(const VariableAccessor<T>& a) const {
BOOST_MPL_ASSERT(( boost::mpl::count<types, T> ));
return get<T>(a.get_name());
}
......
......@@ -34,7 +34,7 @@ BOOST_FIXTURE_TEST_CASE(access, VAfx)
vnames.push_back("c");
vnames.push_back("bb");
foreach (const std::string vn, vnames) {
VariableAccesor<Bool> a1 = v.create_accesor<Bool>(vn);
VariableAccessor<Bool> a1 = v.create_accessor<Bool>(vn);
BOOST_CHECK(v.get_fast(a1) == v.get<Bool>(vn));
v.set("a", Bool(false));
BOOST_CHECK(v.get_fast(a1) == v.get<Bool>(vn));
......@@ -45,8 +45,8 @@ BOOST_FIXTURE_TEST_CASE(access, VAfx)
BOOST_FIXTURE_TEST_CASE(badaccess, VAfx)
{
BOOST_CHECK_THROW(v.create_accesor<Bool>("asd"), InvalidVariableName);
BOOST_CHECK_THROW(v.create_accesor<Bool>("aaa"), VariableTypeMismatch);
BOOST_CHECK_THROW(v.create_accessor<Bool>("asd"), InvalidVariableName);
BOOST_CHECK_THROW(v.create_accessor<Bool>("aaa"), VariableTypeMismatch);
}
......
......@@ -37,10 +37,10 @@ struct VarGetFix
BOOST_FIXTURE_TEST_CASE(bool_apply, VarGetFix)
{
VariableAccesor<Bool> acc_t = cx.variables()->create_accesor<Bool>("True_bool");
VariableAccessor<Bool> acc_t = cx.variables()->create_accessor<Bool>("True_bool");
VarGetter<Bool> var_getter_t(acc_t);
BOOST_CHECK_EQUAL(true, var_getter_t.apply(cx)->get_value());
VariableAccesor<Bool> acc_f = cx.variables()->create_accesor<Bool>("False_bool");
VariableAccessor<Bool> acc_f = cx.variables()->create_accessor<Bool>("False_bool");
VarGetter<Bool> var_getter_f(acc_f);
BOOST_CHECK_EQUAL(false, var_getter_f.apply(cx)->get_value());
}
......@@ -49,7 +49,7 @@ BOOST_FIXTURE_TEST_CASE(bool_apply_acc_destruct, VarGetFix)
{
boost::shared_ptr<VarGetter<Bool> > var_getter;
{
VariableAccesor<Bool> acc_t = cx.variables()->create_accesor<Bool>("True_bool");
VariableAccessor<Bool> acc_t = cx.variables()->create_accessor<Bool>("True_bool");
var_getter.reset(new VarGetter<Bool>(acc_t));
}
BOOST_CHECK_EQUAL(true, var_getter->apply(cx)->get_value());
......@@ -57,7 +57,7 @@ BOOST_FIXTURE_TEST_CASE(bool_apply_acc_destruct, VarGetFix)
BOOST_FIXTURE_TEST_CASE(bool_mod, VarGetFix)
{
VariableAccesor<Bool> acc_t = cx.variables()->create_accesor<Bool>("True_bool");
VariableAccessor<Bool> acc_t = cx.variables()->create_accessor<Bool>("True_bool");
VarGetter<Bool> var_getter_t(acc_t);
BOOST_CHECK_EQUAL(true, var_getter_t.apply(cx)->get_value());
cx.variables()->get<Bool>("True_bool")->set_value(false);
......@@ -74,14 +74,14 @@ BOOST_FIXTURE_TEST_CASE(bool_mod, VarGetFix)
BOOST_FIXTURE_TEST_CASE(bool_varget_to_string, VarGetFix)
{
VariableAccesor<Bool> acc_t = cx.variables()->create_accesor<Bool>("True_bool");
VariableAccessor<Bool> acc_t = cx.variables()->create_accessor<Bool>("True_bool");
VarGetter<Bool> var_getter_t(acc_t);
BOOST_CHECK_EQUAL(Bool::var_repr("True_bool"), var_getter_t.to_string(tagset));
}
BOOST_FIXTURE_TEST_CASE(bool_varget_to_raw_string, VarGetFix)
{
VariableAccesor<Bool> acc_t = cx.variables()->create_accesor<Bool>("True_bool");
VariableAccessor<Bool> acc_t = cx.variables()->create_accessor<Bool>("True_bool");
VarGetter<Bool> var_getter_t(acc_t);
BOOST_CHECK_EQUAL(Bool::var_repr("True_bool"), var_getter_t.to_raw_string());
}
......
......@@ -46,7 +46,7 @@ struct VarSetBoolFix : public VarSetFix
BOOST_FIXTURE_TEST_CASE(bool_apply, VarSetBoolFix)
{
VariableAccesor<Bool> acc_t = cx.variables()->create_accesor<Bool>("True_bool");
VariableAccessor<Bool> acc_t = cx.variables()->create_accessor<Bool>("True_bool");
VarSetter<Bool> var_setter(acc_t, false_constant);
BOOST_CHECK(cx.variables()->get<Bool>("True_bool")->get_value());
BOOST_CHECK(var_setter.apply(cx)->get_value());
......@@ -61,7 +61,7 @@ BOOST_FIXTURE_TEST_CASE(bool_apply_acc_destruct, VarSetBoolFix)
{
boost::shared_ptr<VarSetter<Bool> > var_setter;
{
VariableAccesor<Bool> acc_f = cx.variables()->create_accesor<Bool>("False_bool");
VariableAccessor<Bool> acc_f = cx.variables()->create_accessor<Bool>("False_bool");
var_setter.reset(new VarSetter<Bool>(acc_f, true_constant));
}
BOOST_CHECK(var_setter->apply(cx)->get_value());
......@@ -90,7 +90,7 @@ struct VarSetPositionFix : public VarSetFix
BOOST_FIXTURE_TEST_CASE(set_position, VarSetPositionFix)
{
VariableAccesor<Position> acc = cx.variables()->create_accesor<Position>("Nowhere");
VariableAccessor<Position> acc = cx.variables()->create_accessor<Position>("Nowhere");
VarSetter<Position> var_setter(acc, pos_69_constant);
BOOST_CHECK(cx.variables()->get<Position>("Nowhere")->equals(nowhere));
BOOST_CHECK(var_setter.apply(cx)->get_value());
......@@ -101,7 +101,7 @@ BOOST_FIXTURE_TEST_CASE(set_position_destruct, VarSetPositionFix)
{
boost::shared_ptr<VarSetter<Position> > var_setter;
{
VariableAccesor<Position> acc = cx.variables()->create_accesor<Position>("Pos_69");
VariableAccessor<Position> acc = cx.variables()->create_accessor<Position>("Pos_69");
var_setter.reset(new VarSetter<Position>(acc, nowhere_constant));
}
BOOST_CHECK(cx.variables()->get<Position>("Pos_69")->equals(pos_69));
......@@ -132,7 +132,7 @@ struct VarSetStrSetFix : public VarSetFix
BOOST_FIXTURE_TEST_CASE(set_strset, VarSetStrSetFix)
{
VariableAccesor<StrSet> acc = cx.variables()->create_accesor<StrSet>("EmptySet");
VariableAccessor<StrSet> acc = cx.variables()->create_accessor<StrSet>("EmptySet");
VarSetter<StrSet> var_setter(acc, one_elem_set_constant);
BOOST_CHECK(cx.variables()->get<StrSet>("EmptySet")->equals(empty_set));
BOOST_CHECK(var_setter.apply(cx)->get_value());
......@@ -143,7 +143,7 @@ BOOST_FIXTURE_TEST_CASE(set_strset_destruct, VarSetStrSetFix)
{
boost::shared_ptr<VarSetter<StrSet> > var_setter;
{
VariableAccesor<StrSet> acc = cx.variables()->create_accesor<StrSet>("OneElemSet");
VariableAccessor<StrSet> acc = cx.variables()->create_accessor<StrSet>("OneElemSet");
var_setter.reset(new VarSetter<StrSet>(acc, empty_set_constant));
}
BOOST_CHECK(cx.variables()->get<StrSet>("OneElemSet")->equals(one_elem_set));
......@@ -175,7 +175,7 @@ struct VarSetTSetFix : public VarSetFix
BOOST_FIXTURE_TEST_CASE(set_tset, VarSetTSetFix)
{
VariableAccesor<TSet> acc = cx.variables()->create_accesor<TSet>("EmptyTag");
VariableAccessor<TSet> acc = cx.variables()->create_accessor<TSet>("EmptyTag");
VarSetter<TSet> var_setter(acc, subst_pl_tag_constant);
BOOST_CHECK(cx.variables()->get<TSet>("EmptyTag")->equals(empty_tset));
BOOST_CHECK(var_setter.apply(cx)->get_value());
......@@ -186,7 +186,7 @@ BOOST_FIXTURE_TEST_CASE(set_TSet_destruct, VarSetTSetFix)
{
boost::shared_ptr<VarSetter<TSet> > var_setter;
{
VariableAccesor<TSet> acc = cx.variables()->create_accesor<TSet>("SubstPl");
VariableAccessor<TSet> acc = cx.variables()->create_accessor<TSet>("SubstPl");
var_setter.reset(new VarSetter<TSet>(acc, empty_tset_constant));
}
BOOST_CHECK(cx.variables()->get<TSet>("SubstPl")->equals(subst_pl_tag));
......@@ -198,7 +198,7 @@ BOOST_FIXTURE_TEST_CASE(set_TSet_destruct, VarSetTSetFix)
BOOST_FIXTURE_TEST_CASE(bool_varset_to_string, VarSetBoolFix)
{
VariableAccesor<Bool> acc_t = cx.variables()->create_accesor<Bool>("True_bool");
VariableAccessor<Bool> acc_t = cx.variables()->create_accessor<Bool>("True_bool");
VarSetter<Bool> var_setter_t(acc_t, false_constant);
std::string expected =
"setvar(" + Bool::var_repr("True_bool") + ", False)";
......@@ -207,7 +207,7 @@ BOOST_FIXTURE_TEST_CASE(bool_varset_to_string, VarSetBoolFix)
BOOST_FIXTURE_TEST_CASE(bool_varset_to_raw_string, VarSetBoolFix)
{
VariableAccesor<Bool> acc_t = cx.variables()->create_accesor<Bool>("True_bool");
VariableAccessor<Bool> acc_t = cx.variables()->create_accessor<Bool>("True_bool");
VarSetter<Bool> var_setter_t(acc_t, false_constant);
std::string expected =
"setvar(" + Bool::var_repr("True_bool") + ", False)";
......@@ -216,7 +216,7 @@ BOOST_FIXTURE_TEST_CASE(bool_varset_to_raw_string, VarSetBoolFix)
BOOST_FIXTURE_TEST_CASE(position_varset_to_string, VarSetPositionFix)
{
VariableAccesor<Position> acc_t = cx.variables()->create_accesor<Position>("Nowhere");
VariableAccessor<Position> acc_t = cx.variables()->create_accessor<Position>("Nowhere");
VarSetter<Position> var_setter_t(acc_t, pos_69_constant);
std::string expected =
"setvar(" + Position::var_repr("Nowhere") + ", 69)";
......@@ -225,7 +225,7 @@ BOOST_FIXTURE_TEST_CASE(position_varset_to_string, VarSetPositionFix)
BOOST_FIXTURE_TEST_CASE(position_varset_to_raw_string, VarSetPositionFix)
{
VariableAccesor<Position> acc_t = cx.variables()->create_accesor<Position>("End");
VariableAccessor<Position> acc_t = cx.variables()->create_accessor<Position>("End");
VarSetter<Position> var_setter_t(acc_t, nowhere_constant);
std::string expected =
"setvar(" + Position::var_repr("End") + ", nowhere)";
......@@ -234,7 +234,7 @@ BOOST_FIXTURE_TEST_CASE(position_varset_to_raw_string, VarSetPositionFix)
BOOST_FIXTURE_TEST_CASE(StrSet_varset_to_string, VarSetStrSetFix)
{
VariableAccesor<StrSet> acc = cx.variables()->create_accesor<StrSet>("EmptySet");
VariableAccessor<StrSet> acc = cx.variables()->create_accessor<StrSet>("EmptySet");
VarSetter<StrSet> var_setter_t(acc, one_elem_set_constant);
std::string expected =
"setvar(" + StrSet::var_repr("EmptySet") + ", [\"ThereCanBeOnly1\"])";
......@@ -243,7 +243,7 @@ BOOST_FIXTURE_TEST_CASE(StrSet_varset_to_string, VarSetStrSetFix)
BOOST_FIXTURE_TEST_CASE(StrSet_varset_to_raw_string, VarSetStrSetFix)
{
VariableAccesor<StrSet> acc = cx.variables()->create_accesor<StrSet>("EmptySet");
VariableAccessor<StrSet> acc = cx.variables()->create_accessor<StrSet>("EmptySet");
VarSetter<StrSet> var_setter(acc, one_elem_set_constant);
std::string expected =
"setvar(" + StrSet::var_repr("EmptySet") + ", [\"ThereCanBeOnly1\"])";
......@@ -252,7 +252,7 @@ BOOST_FIXTURE_TEST_CASE(StrSet_varset_to_raw_string, VarSetStrSetFix)
BOOST_FIXTURE_TEST_CASE(tset_varset_to_string, VarSetTSetFix)
{
VariableAccesor<TSet> acc = cx.variables()->create_accesor<TSet>("SubstPl");
VariableAccessor<TSet> acc = cx.variables()->create_accessor<TSet>("SubstPl");
VarSetter<TSet> var_setter(acc, subst_pl_tag_constant);
std::string expected =
"setvar(" + TSet::var_repr("SubstPl") + ", " + subst_pl_tag_constant->to_string(tagset) + ")";
......@@ -261,7 +261,7 @@ BOOST_FIXTURE_TEST_CASE(tset_varset_to_string, VarSetTSetFix)
BOOST_FIXTURE_TEST_CASE(tset_varset_to_raw_string, VarSetTSetFix)
{
VariableAccesor<TSet> acc = cx.variables()->create_accesor<TSet>("SubstPl");
VariableAccessor<TSet> acc = cx.variables()->create_accessor<TSet>("SubstPl");
VarSetter<TSet> var_setter(acc, subst_pl_tag_constant);
std::string expected =
"setvar(" + TSet::var_repr("SubstPl") + ", " + subst_pl_tag_constant->to_raw_string() + ")";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment