Menu

#302 typedef all the ids and similar

Feature_Request
open
nobody
2
2008-03-01
2008-03-01
No

It would be good if you typedef all the various ID types.

This has two advantages, it makes the code more self documenting. It also means that at a later state if the id's change to being a different size, the code doesn't break.

typedef ResourceId uint32_t;

// A map between resource id's and amounts.
std::map<ResourceId, uint32_t> amounts;

// Function which returns a resourceid
ResourceId getId();

// Function which returns a map like the above
std::map<ResourceId, uint32_t> getResourceAmounts();

Discussion

  • Tim 'mithro' Ansell

    • labels: --> tpserver-cpp
    • milestone: --> Feature_Request
    • priority: 5 --> 2
     
  • Lee Begg

    Lee Begg - 2008-03-01

    Logged In: YES
    user_id=82757
    Originator: NO

    I have thought about it a few times, and various people looking at the server code have suggested it.

    I agree that it would make things a little clearer, but there are a lot of times where knowing the size is important. Changing the size of an ID type would break:
    - Persistence
    - protocol & frame packing/unpacking
    - some logging message (maybe)

    I will think about it. I think I will pass on it until after 0.5.0

     

Log in to post a comment.