Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

2109 Excellent

About the_edd

  • Rank
  1. the_edd

    Flat hash containers

    In response to your first question, about submission to boost:   The work you will have to do to get your library to the point of submission (assuming there's sufficient interest -- ask on the boost mailing list) includes: provide documentation in a manner consistent with boost's style and infrastructure ditto for tests ditto for build scripts modifying your code to use boost's portability macros/conventions getting it to build and perform well on platforms that you may have little or no experience with. I'm almost certain that you will be required to provide a version that builds cleanly on POSIX systems such as Linux and OS X. Libraries undergoing submission are assigned a review manager. At some point, your library will be reviewed publicly on the boost mailing list. It can take quite a long time, depending on interest, to get your library through the review backlog.   Once the review starts, a lot of people will tear your code apart, often with little or no tact. So make sure you're comfortable with criticism. Revisions will probably have to be made to what you have now until people are satisfied. I haven't looked at your code, it's just what usually happens.   Assuming submission is successful, you will have to maintain your library for the foreseeable future. This will probably mean: familiarizing yourself with boost's release process responding to bug reports, even those where you don't have access to a similar system to that of the reporter. Of course, this is true wherever you 'publish' your code, but the exposure provided by boost will mean more bugs reported (even if they're invalid). there's talk on the mailing list of boost moving to a new version control/modularization/distribution system soon, too. So you will almost certainly have more maintenance work to do in future. More generally, you will have to stay up to date with boost's infrastructure changes, just to keep your library's head above water.    Exposure is nice of course, but submission to boost isn't a one-shot thing.
  2. The best way is to fix the library so that each function takes some kind of 'context' structure, in to which all the global state is moved. Multiple context structures would allow multiple clients in the same process.   Loading a library twice (at distinct locations in virtual memory) may be possible, but it will be highly platform dependent. What platform(s) do you care about?   It's possible to write a non-intrusive wrapper, as long as you have a true static library (not a stub) and are willing to find all global state. In this case you will have to: Create a context structure with one member for each piece of global state.  Create init_context(context *ctx) that initializes a context in the same way that the global state is initialized. Create get_current_context(context *ctx) and set_current_context(const context *ctx) functions that get and set the current global state Add a global mutex if you want to use this in a multithreaded environment. Now wrap each function, f, as follows: return_type wrapped_f(context *ctx, type1 arg1, type2 arg2, type3 arg3, etc) {     g_mutex.lock();     context old_ctx;     get_current_context(&old_ctx);     set_current_context(ctx);       return_type ret = f(arg1, arg2, arg3, etc);       get_current_context(ctx);     set_current_context(&old_ctx);     g_mutex.unlock();       return ret; }   An RAII-style class could automate the locking and context swapping. I admit it's ugly and you'll still have to take care to look for new global state to add to the context structure whenever the underlying library is changed, but it's probably all you can do without modifying the library.
  3. IMHO, tests should really only use the public members of a class. You shouldn't need to add any kind of "hooks" for testing. If you feel the need to add extra functionality purely for testing, it could be a hint that you've violated what's often called the Single Responsibility Principle.   I'm not an advocate of TDD, but when using this methodology, private methods arise naturally as part of the 'refactoring' steps and so will be automatically exercised by the tests.   As for how to structure unit tests, look at the examples of existing libraries/frameworks. googletest and unittest++ are two popular ones, though there are countless others.
  4. MSDN says that lParam is 0 when wParam is DBT_DEVNODES_CHANGED (which IMHO, you should really assert on anyway). So your code behaves as expected -- undefined behaviour.   It appears you have copied the GUID passed to RegisterDeviceNotification from the MSDN example code. I don't know much about Windows' device handling but I have a strong suspicion that this GUID is not the one you should be using.   Have you tried adding DEVICE_NOTIFY_ALL_INTERFACE_CLASSES to the flags in your call to RegisterDeviceNotification()? In this case the GUID is ignored and you get messages for all devices. This may give you a better indication of what's really happening and help you detect your TV.   Just out of curiosity, are you attempting to detect your telly to automatically enable some kind of out-of-band debug console for a game? That would be cool :)
  5. Have you checked wparam? If it's something like DBT_DEVICEREMOVECOMPLETE, you're probably casting lParam to the wrong type in the first place.   In general, it's my understanding that you should always first cast lparam to a DEV_BROADCAST_HDR* and only cast to something further once you have confirmed the value of its dbch_devicetype.
  6. the_edd

    fread question

    That's the kind of thing I was expecting. We'd probably be debating semantics, but I wouldn't say it's 'meaningless' as you can still use ftell() to 'save' a position to which you can return later with fseek().
  7. the_edd

    fread question

    Is this really true?
  8. the_edd

    fread question

    Are you saying it contains the bytes 0x30, 0x0D, 0x0A, 0x31, 0x0D, 0x0A, 0x32, 0x0D, 0x0A, 0x33 (assuming little endian and typical windows text formatting)? Or are you saying it contains something like 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00? The distinction is important. But I'll assume the latter as that's what the rest of your question implies. Reading a file does not change its content. Think of a FILE as containing a pointer or cursor in it somewhere that is moved along every time you read something from the file. The first fread() call will read an int (on success) and advance the cursor sizeof(int) bytes, so that the cursor is now at 0x02,00,00,00 (again assuming 'binary' formatting). The fseek() function allows you to change the position of this cursor. ftell() tells you its position. Not sure if this answers your question directly, but I hope it helps. EDIT: ninja'd :(
  9. the_edd

    C++ encapsulation

    It's actually quite common. It even has a bunch of names: the "pimpl idiom", the "compiler firewall idiom", the "cheshire cat idiom" and the "bridge pattern".
  10. The trick with error messages like this is to resist intimidation and the urge to give up. If we replace "std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> >" with "std::string", this message should become a bit clearer:   error LNK2019: unresolved external symbol "public: __thiscall HashContainer<std::string,int>::~HashContainer<std::string,int>(void)"[/quote]   In other words, the linker can't find a definition for your HashContainer's destructor. Have you provided one?
  11. You don't need any dynamic allocation (beyond what's required for creating a ListNode for the SortedList). Could you explain why you think you need to do any more than that?
  12.   This is the way to go.   So that makes the user responsible for packaging their key and data before calling the table's Insert function. Is this how it is usually done? [/quote] You can do the packaging in the insertion method, on their behalf.
  13. the_edd

    Verlet physics

    Once you have calculated the force due to friction, you divide by the mass to get the acceleration (a deceleration in this case) due to friction. This is then added to the acceleration before you perform an iteration of the verlet solver (or any other solver for the equations of motion). So your Physics::UpdateVerlet() method should not have to change. How you actually model friction is up to you. One simple model is to have the magnitude of friction be proportional to that of the perpendicular component of the contact force of the two bodies (so proportional to the weight -- the effect of mass due to gravity -- of a body if it is sitting on a flat surface). Any introductory book on Newtonian mechanics is likely to explain this model.
  14. I think you're missing a call to keyboard->Poll() somewhere.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!