Skip to content

Commit

Permalink
优化-规范化命名
Browse files Browse the repository at this point in the history
优化-规范化命名
  • Loading branch information
NingLeixueR committed Jul 15, 2024
1 parent 2eb5293 commit 8bcada0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 42 deletions.
2 changes: 1 addition & 1 deletion public/cpp/actor/actor_base/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ namespace ngl
ninst<TDerived, TYPE>().
template rfun_forward<IsForward>(
(type_np_actor_forward)&TDerived::handle
, type_enum<TDerived, ENUM_ACTOR>::type()
, nactor_type<TDerived>::type()
, false
);
}
Expand Down
4 changes: 2 additions & 2 deletions public/cpp/actor/actor_base/actor_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ namespace ngl
{
.m_parm
{
.m_type = type_enum<tactor_db, ENUM_ACTOR>::type(),
.m_type = nactor_type<tactor_db>::type(),
.m_area = ttab_servers::tab()->m_area,
},
.m_weight = 0x7fffffff,
Expand Down Expand Up @@ -382,7 +382,7 @@ namespace ngl
pro->m_type = atype;
pro->m_ls.swap(aset);

ENUM_ACTOR ltype = type_enum<actor_db<TDBTAB_TYPE, TDBTAB>, ENUM_ACTOR>::type();
ENUM_ACTOR ltype = nactor_type<actor_db<TDBTAB_TYPE, TDBTAB>>::type();
i64_actorid lactorid = nguid::make(ltype, tab_self_area, nguid::none_actordataid());
actor::static_send_actor(lactorid, nguid::make(), pro);
}
Expand Down
38 changes: 5 additions & 33 deletions public/cpp/actor/actor_base/nactortype.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ namespace ngl
template <typename T,typename ENUMT>
class type_enum
{
type_enum() = delete;
type_enum(const type_enum&) = delete;
type_enum& operator=(const type_enum&) = delete;

static ENUMT m_type;
public:
static void inits(ENUMT atype)
Expand Down Expand Up @@ -102,40 +106,8 @@ namespace ngl
template <typename T, typename ENUMT>
ENUMT type_enum<T, ENUMT>::m_type = type_enum<T, ENUMT>::enum_null();

// # 根据actor类型获取其对应的枚举值
/*template <typename TACTOR>
class nactor_type
{
nactor_type() = delete;
nactor_type(const nactor_type&) = delete;
nactor_type& operator=(const nactor_type&) = delete;
static ENUM_ACTOR m_type;
public:
static void inits(ENUM_ACTOR atype)
{
m_type = atype;
}
static ENUM_ACTOR type()
{
if (m_type == ACTOR_NONE)
{
log_error()->print(
"nactor_type<{}>::type() == ACTOR_NONE",
tools::type_name<TACTOR>()
);
Throw(
"nactor_type<{}>::type() == ACTOR_NONE",
tools::type_name<TACTOR>()
);
}
return m_type;
}
};
template <typename TACTOR>
ENUM_ACTOR nactor_type<TACTOR>::m_type = ACTOR_NONE;*/
using nactor_type = type_enum<TACTOR, ENUM_ACTOR>;

// # 根据pbdb::ENUM_DB获取ENUM_ACTOR
ENUM_ACTOR db_enum(pbdb::ENUM_DB TDBTAB_TYPE);
Expand Down
2 changes: 1 addition & 1 deletion public/cpp/actor/actor_base/ndbclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace ngl
// # 获取db actor的guid
inline i64_actorid dbguid()
{
ENUM_ACTOR ltype = type_enum<actor_db<DBTYPE, TDBTAB>, ENUM_ACTOR>::type();
ENUM_ACTOR ltype = nactor_type<actor_db<DBTYPE, TDBTAB>>::type();
return nguid::make(ltype, tab_self_area, nguid::none_actordataid());
}

Expand Down
6 changes: 3 additions & 3 deletions public/cpp/actor/actor_base/nregister.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace ngl
}
};
protocol::registry_actor<T, TYPE>(
type_enum<TDerived, ENUM_ACTOR>::type(),
nactor_type<TDerived>::type(),
tprotocol::protocol_name<T>().c_str()
);
return *this;
Expand Down Expand Up @@ -59,7 +59,7 @@ namespace ngl
bool aisload/* = false*/
)
{
rfun<TTTDerived, T>(afun, type_enum<TDerived, ENUM_ACTOR>::type(), aisload);
rfun<TTTDerived, T>(afun, nactor_type<TDerived>::type(), aisload);
return *this;
}

Expand Down Expand Up @@ -124,7 +124,7 @@ namespace ngl
}
};
protocol::registry_actor_recvforward<T, type_forward::isusing, TYPE>(
type_enum<TDerived, ENUM_ACTOR>::type(),
nactor_type<TDerived>::type(),
tprotocol::protocol<type_forward>(),
tprotocol::protocol_name<type_forward>().c_str()
);
Expand Down
4 changes: 2 additions & 2 deletions public/cpp/actor/nactor_auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace ngl
{
using type_actor_db = ngl::actor_db<TDBTAB_TYPE, TDBTAB>;
ENUM_ACTOR lenum = db_enum(TDBTAB_TYPE);
type_enum<type_actor_db, ENUM_ACTOR>::inits(lenum);
nactor_type<type_actor_db>::inits(lenum);
std::string ldbname("actor_");
std::string ltemp = tools::type_name<TDBTAB>();
auto pos = ltemp.rfind(":");
Expand All @@ -87,7 +87,7 @@ namespace ngl
void auto_actor(const TACTOR* aactor, ENUM_ACTOR aenum, const char* aname)
{
em<ENUM_ACTOR>::set(aenum, aname);
type_enum<TACTOR, ENUM_ACTOR>::inits(aenum);
nactor_type<TACTOR>::inits(aenum);
}

template <typename TACTOR, typename ...ARG>
Expand Down

0 comments on commit 8bcada0

Please sign in to comment.