Skip to content

Commit

Permalink
Removed ID field from subhandler, forcing it to be uint32_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin committed Apr 2, 2014
1 parent cd05eb1 commit 790c598
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
28 changes: 14 additions & 14 deletions src/alice/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,18 @@ namespace dota {
*
* If Obj and Data have the same type, Data will be treated as if it was already parsed.
*/
template <typename Obj, typename Id, typename Data, typename IdSelf>
template <typename Obj, typename Data, typename IdSelf>
class handlersub {
public:
/** Type for parent object each message of this type inherits from */
typedef Obj obj_t;
/** Type of the object id to manage relations */
typedef Id id_t;
typedef uint32_t id_t;

/** Type for the parameter of the callback function */
typedef cbObject<Obj, Id>* callbackObj_t;
typedef cbObject<Obj, uint32_t>* callbackObj_t;
/** Pointer-less type for the callback object */
typedef cbObject<Obj, Id> callbackObjS_t;
typedef cbObject<Obj, uint32_t> callbackObjS_t;
/** Type for the callback signature */
typedef delegate<void, callbackObj_t> delegate_t;

Expand Down Expand Up @@ -243,14 +243,14 @@ namespace dota {
}
private:
/** Type for a list of registered callbacks */
typedef std::vector<std::vector<delegate_t>> cbmap_t;
typedef std::vector<std::vector<delegate_t>> cblist_t;
/** Callback list */
cbmap_t cb;
cblist_t cb;

/** Type for a list of registered objects */
typedef std::vector<obj_t (*)(Data&&)> objmap_t;
typedef std::vector<obj_t (*)(Data&&)> objlist_t;
/** Object list */
objmap_t obj;
objlist_t obj;

/** Called if the message needs to be parsed from the data */
void forward(const id_t& i, Data &&data, uint32_t tick, std::false_type);
Expand Down Expand Up @@ -447,12 +447,12 @@ namespace dota {

/** Type for our default handler */
typedef handler<
handlersub< uint32_t, uint32_t, uint32_t, msgStatus >,
handlersub< ::google::protobuf::Message*, uint32_t, demMessage_t, msgDem >,
handlersub< ::google::protobuf::Message*, uint32_t, demMessage_t, msgUser >,
handlersub< ::google::protobuf::Message*, uint32_t, demMessage_t, msgNet >,
handlersub< entity*, uint32_t, entity*, msgEntity >,
handlersub< entity_delta*, uint32_t, entity_delta*, msgEntityDelta >
handlersub< uint32_t, uint32_t, msgStatus >,
handlersub< ::google::protobuf::Message*, demMessage_t, msgDem >,
handlersub< ::google::protobuf::Message*, demMessage_t, msgUser >,
handlersub< ::google::protobuf::Message*, demMessage_t, msgNet >,
handlersub< entity*, entity*, msgEntity >,
handlersub< entity_delta*, entity_delta*, msgEntityDelta >
> handler_t;

/// @}
Expand Down
24 changes: 12 additions & 12 deletions src/alice/handler_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*
*/

template <typename Obj, typename Id, typename Data, typename IdSelf>
void handlersub<Obj, Id, Data, IdSelf>::
template <typename Obj, typename Data, typename IdSelf>
void handlersub<Obj, Data, IdSelf>::
forward(const id_t& i, Data &&data, uint32_t tick, std::false_type) {
// check for callback handlers
if (cb.size() <= i)
Expand All @@ -37,16 +37,16 @@ forward(const id_t& i, Data &&data, uint32_t tick, std::false_type) {
);

// create object
cbObject<Obj, Id> o(obj[i](std::move(data)), tick, i);
cbObject<Obj, uint32_t> o(obj[i](std::move(data)), tick, i);

// forward to definitive handlers
for (auto &d : cb[i]) {
d(&o);
}
}

template <typename Obj, typename Id, typename Data, typename IdSelf>
void handlersub<Obj, Id, Data, IdSelf>::
template <typename Obj, typename Data, typename IdSelf>
void handlersub<Obj, Data, IdSelf>::
forward(const id_t& i, Data &&data, uint32_t tick, std::true_type) {
// check for callback handlers
if (cb.size() <= i)
Expand All @@ -56,16 +56,16 @@ forward(const id_t& i, Data &&data, uint32_t tick, std::true_type) {
return;

// create object
cbObject<Obj, Id> o(std::move(data), tick, i, false);
cbObject<Obj, uint32_t> o(std::move(data), tick, i, false);

// forward to definitive handlers
for (auto &d : cb[i]) {
d(&o);
}
}

template <typename Obj, typename Id, typename Data, typename IdSelf>
typename handlersub<Obj, Id, Data, IdSelf>::callbackObjS_t handlersub<Obj, Id, Data, IdSelf>::
template <typename Obj, typename Data, typename IdSelf>
typename handlersub<Obj, Data, IdSelf>::callbackObjS_t handlersub<Obj, Data, IdSelf>::
retrieve(const id_t& i, Data &&data, uint32_t tick, std::false_type) {
// get conversion object
if (obj.size() <= i || obj[i] == nullptr)
Expand All @@ -74,13 +74,13 @@ retrieve(const id_t& i, Data &&data, uint32_t tick, std::false_type) {
);

// return object
return cbObject<Obj, Id>(obj[i](std::move(data)), tick, i);
return cbObject<Obj, uint32_t>(obj[i](std::move(data)), tick, i);
}

template <typename Obj, typename Id, typename Data, typename IdSelf>
typename handlersub<Obj, Id, Data, IdSelf>::callbackObjS_t handlersub<Obj, Id, Data, IdSelf>::
template <typename Obj, typename Data, typename IdSelf>
typename handlersub<Obj, Data, IdSelf>::callbackObjS_t handlersub<Obj, Data, IdSelf>::
retrieve(const id_t& i, Data &&data, uint32_t tick, std::true_type) {
return cbObject<Obj, Id>(std::move(data), tick, i);
return cbObject<Obj, uint32_t>(std::move(data), tick, i);
}

template <typename T1, typename... Rest>
Expand Down

0 comments on commit 790c598

Please sign in to comment.