Jump to content
  • Advertisement

SlimTimmy

Member
  • Content Count

    135
  • Joined

  • Last visited

Community Reputation

138 Neutral

About SlimTimmy

  • Rank
    Member
  1. In one of my sources I define a new type "real" that resolves either to float or double (depending on some compiler flag) typedef double real; // respectively: typedef float real; One problem I'm facing now is how I should treat floating point literals. Somewhere in the code I may have the following: real c = 1.234567891011 When I'm compiling with real as double everything is fine, switching to float however produces a warning about a truncation (as it's a double literal). Then I began adding casts everywhere I'm using literals: real c = static_cast<real>(1.234567891011) However this tends to be hard to read, especially if there are many floating point literals in a single expression. Can you think of a way to handle this in a better and less verbose way?
  2. SlimTimmy

    hidden inter-object communication

    Quote:Original post by SiCrane Abstract the client and the server network layer so that instead of sending and receiving data directly from the network they send and receive from a proxy class. Implement the proxy classes with both a networking implementation and an in-memory queue implementation. Instantiate the correct proxies for which communication mode is being used. So you would have two proxy classes? (one with networking, the other with an in-memory implementation) This might pose a problem for the server as it has to be able to communicate via network and via memory at the same time. Therefore you would have to instantiate both proxies and everytime you do something with a client figure out whether the client is remote or local in order to choose the proper proxy object.
  3. SlimTimmy

    hidden inter-object communication

    I'm designing a client-server application: Normally client and server communicate via network. However if the client and server run on the same machine (as different threads in the same process) the walk through the network stack should be removed. For example, if the client sends a packet to the server (in the configuration that both run on the same machine), internally the client would call server->addPacket(). Making the addPacket method publicly available would seem rather awkward to the user of the library.
  4. I have two objects of different classes A and B that should pass data between them. However I do not want to extend the public interface of both classes as those additional methods should not be accessible by the user of the classes. I thought about two solutions: 1) Introduce a special naming scheme to denote those methods that are not supposed to be called by the user. (the OGRE engine does something like that, prefixing those methods with an underscore) 2) Use a friend relationship. I would prefer using friend, although I think its suboptimal. How can I keep the public interfaces of both classes clean while enabling communication between them?
  5. I'm developing a raytracer (non realtime) which currently solely works on the CPU. One task that is repeated several million times is the evaluation of a composite 3D perlin noise function, which takes a considerable time. I thought about moving this task to the GPU (just one 3D vector is necessary as an input argument to evaluate the function), but have no information about the common techniques used. Could you point out some articles that deal with this topic? (I would strongly prefer working with DirectX) btw: I tried googling but couldn't make up a concise keyword. Is there any special term for "misusing" the GPU as I intend?
  6. SlimTimmy

    Managing unit tests

    I've chosen the UnitTest++ framework (http://unittest-cpp.sourceforge.net/) for my first unit-tested application (it's a console application). The structure: Test code and application code are compiled into a single executable. By specifying "--test" as an argument you start the execution of the test code. There are three different configurations: 1) DebugTest 2) ReleaseTest 3) Release The first two configurations contain the test code, the last is used for shipping. I'm using a global define to conditionally insert the test-specific code. In the end it looks like this: Main.cpp #ifdef UNIT_TEST #include <UnitTest++.h> #endif #include <iostream> int main(int argc, char *argv[]) { #ifdef UNIT_TEST if( argc > 1 ) { string argument(argv[1]); if( argument == "--test" ) return UnitTest::RunAllTests(); } #endif cout << "Application"; } Test.cpp #ifdef UNIT_TEST #include <UnitTest++.h> using namespace UnitTest; TEST(XYZTest) { CHECK(...); } #endif [Edited by - SlimTimmy on January 11, 2007 8:41:35 AM]
  7. SlimTimmy

    Managing unit tests

    Quote:Original post by psykr Just for comparison, here is my setup: I am running CxxTest, and all my unit tests are in separate header files (they don't have to be). Because of this, I put all my files together into one VS project. Because it's a small project, I can run the tests manually. I have one configuration that compiles and runs the unit tests (with a separate executable), and then my normal debug/profile builds. How do you make the C++ files (which contain the classes to be tested) available to the unit test project? Do you add them manually to the project? Quote: I don't think there's any need to have both the unit tests and the actual application code in the same executable. The only time you'll run the unit tests is during development (and should stay there), and actual application code is what you will be giving to the end user. You could control this by using some global defines (like the _DEBUG define). During development you would for example define "UNIT_TEST" and the unit test code gest compiled into the executable.
  8. SlimTimmy

    Managing unit tests

    Quote:Original post by ToohrVyk I have two program entry points. When in NDEBUG mode, the release entry point is the normal one. When in _DEBUG mode, the debug entry point checks if "test" is passed as the first command line argument, and performs the tests (otherwise, it behaves normally). Then, as a post-build step, I call the executable with "test" as the first command line argument. When I have control over my own makefile, I usually create a test executable from the test files (which are adequately named) and run it as part of the build process — it is then removed unless it failed. Which unit testing framework do you use? (something written by yourself?) I would also prefer having both the application code and the unit testing code in one single executable. The problem is that the frameworks I've seen define a main() function themselves, which only executes the test code. How can I use the test code and the application code side by side? (I'm using Boost.Test)
  9. SlimTimmy

    Managing unit tests

    Quote:Original post by Soth I think you can add .cpp files to your second project by using Project->Add Existing Item->your cpp`s. Or you can build your main program as .dll and link to it from your second application. Both solutions are certainly possible, although there are some drawbacks: Adding the files manually to the test project involves some extra work. You have to keep both projects in sync (It would be perfect if you could specify some kind of reference folder, but I don't know whether this is possible in Visual Studio). When the project increases in size there is another problem: compilation time. Having two separate projects (with more or less identical source code files) the code has to be compiled twice. A .DLL might incur substantial work (i.e. exporting classes etc.), but I tried a different approach using static libraries (.lib): In the solution you create 3 different projects: 1) Code 2) Application 3) Tester The Code project contains the classes you want to use in your application and which should also be tested. The project compiles into a lib, that is linked to by the other two projects. I guess that the optimal way would look like this: There are two projects (the application with the code to be tested and the test project). Instead of sharing common code files the projects should share the compiled code files (.obj). The application is responsible for generating these files, whereas the linker of the test project just includes the obj files. But I couldn't find a way to set this up in the Visual Studio IDE. Any further ideas? How do you set up your projects when you do unit testing?
  10. I want to start using unit tests now (I picked the Boost.Test library as a start), but still have some basic questions. 1) Do you create a second project specifically for the tests? 2) If you do so: How do you set up the projects? I'm using the Visual Studio 2005 IDE and created 2 projects (located in the same solution). How can I make the cpp files from the main program available to the test program? Is there any option to specify some kind of reference?
  11. SlimTimmy

    encryption: protecting the key

    Thanks for your advice, I already feared that it would maybe require a different approach. Currently I've a pretty similar problem: I want to publish a small utility which makes it possible for users to upload some data to a predefined FTP server. Of course, the access data (host, username, password) has to be stored somewhere on the client machine (either in the exe, a separate file or the registry for example). Determined users will certainly get access to this data (encrypted or not, the FTP connection uses plain text transmission anyway), so I think about alternatives: Is another protocol more suitable? Is it possible to prevent users from gaining access to the server? As I doubt that this is realistic I thought about a different approach, limiting the damage someone could make: 1) Access for the FTP user is restricted to a certain temporary directory on the server 2) Data which gets uploaded onto the server gets processed by a program running on the server. This application could move fully uploaded files to certain protected directories, so most of the time an attacker would just see an empty temporary directory. Nevertheless he could delete newly uploaded files and cause damage. What other ideas do you have?
  12. In one of my programs I want to store some encrypted data on the hard drive. Using a symmetric cryptographic algorithm like AES, I would have to store the key somewhere in the program. But I think that it should be relatively easy to decompile the executable and find the employed key, and this would be even worse if I used .NET for example. How should I protect this key? Is it worth the effort?
  13. SlimTimmy

    search algorithms

    The structure is very simple: I have a simple array of bytes which has an arbitrary length (the user specifies the data), normally up to hundreds of mega bytes. The task of the program is to localize a sequence of bytes (4 bytes long => an integer) in that block of data and to return the addresses of the found locations. It should also be possible to search for a range of integers, e.g. 1000 to 2000. The problem in my opinion is that you can hardly preprocess the data thoroughly (that would be required for a binary search for example), as you have large amounts of data. But maybe I am wrong and the cost of preprocessing pays off at the search stage.
  14. I need to perform a search on a block of memory which currently takes a bit too long as I am just using a linear search. To be more precisely I want to search several integers in a block of bytes. I thought of ordering all bytes in the block and then start a binary search, but the problem is that the integers can start anywhere in the block. So I could just find the occurences which match the first byte of the integer. Here's an example: E3 A0 FF C8 FF 64 12 1F FE FF FA AA B9 33 21 So if I want to find the integer FA AA B9 33 I would have to find the bytes containg "FF" via a binary search (this gives me 3 results) and then look at the subsequent bytes to identify the real integer. Does anybody know which algorithms are more suitable?
  15. I guess you just overlooked the other overloads of the Texture constructor. You can easily load textures: texture = new Texture(device, filePath); It seems they have removed all Loaders and replaced it either with an appropriate overload of the constructor or a static method (like Effect.FromFile). Nevertheless I can't find some saving methods (maybe they forgot it: http://exdream.dyn.ee/blog/CommentView.aspx?guid=2811ff76-f35a-4a8c-add1-9a7adff54180) [Edited by - SlimTimmy on December 31, 2005 10:11:03 AM]
  • 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!