08.30.2006 19:41

NOAA Charts funding issue?

http://www.boatus.com/gov/noaachart.htm
Of most concern was a budget approved by the House of Representatives
in July (HR 5672) that cut by 10% the President's request for Mapping
& Charting and virtually zeroed out any funding for converting
existing paper charts into electronic files. Currently only about half
of the full suite of 1,000 NOS charts are converted to Electronic
Navigation Charts, or ENCs.


The most recent Senate version of the NOAA 07 budget (Senate Report 109.280) retained $6 million for continuing the ENC conversion; the president's budget request for this line item was $6.1 million. The Senate budget for NOS also met the President's request for Mapping & Charting of $43.7 million.

Posted by Kurt | Permalink

08.29.2006 21:21

raytracing

I have been talking up raytracing/radiosity methods as having strong potential for visualizing marine datasets. Then today I ran into these two articles. And where? slashdot...

Add Another Core for Faster Graphics

Parallel Worlds on bit-tech...
As some of you already know, the idea of real-time raytracing has
always been one of my pet-peeves for the industry. The concept is easy
- rather than trying to approximate every single pixel's light value
through myriad pipelines and shaders, you trace rays of light from eye
to source using one physics calculation. This calculation takes lots
into account based on what the light hits, but it is just one
calculation that is repeated millions and millions of times per frame.


Rather than using uni-directional meshes for models, where only the outside counts as visible space (this is where clipping errors derive from), raytracing deals in volumes. Each time a ray of light hits a new volume, a new segment is created (dubbed a rayseg) for how light would react within (or on) that particular material. Since light is now allowed to pass through transparent objects, or is properly reflected off a solid surface, all light in a room traces back to its sources. It sounds easy enough! If only the implementation were as simple...

But rather than working on that advancement, most of the commercial graphics industry has been intent on pushing raster-based graphics as far as they could go. Research has been slow in raytracing, whereas raster graphic research has continued to be milked for every approximate drop it closely resembles being worth. Of course, it is to be expected that current technology be pushed, and it was a bit of a pipe dream to think that the whole industry should redesign itself over raytracing.


Compute-Intensive, Highly Parallel Applications and Uses - Ray Tracing Goes Mainstream
ABSTRACT


We present an introduction to the rendering technique known as "ray tracing." We propose that its performance has reached the stage where it is feasible that it will take over from raster graphics in the near future for interactive gaming and other application domains. We investigate various aspects of ray tracing and compare and contrast them with the raster equivalent. Finally, we analyze ray tracing's platform requirements and scalability potential.

Posted by Kurt | Permalink

08.29.2006 10:12

when is a trick too tricky

Just thinking about all this code I have been ingesting. Some tricks are great. I think that using ?: in c++ is really effective. I know, some people really don't like this construct and I understand that they don't want to use it in their code, but check this out:
int main(int argc, char *argv[])
{
    bool ok=true;
    // Lots of processing code that sets ok false if anything had trouble.
    cerr << "Finished.  Write " << (ok?"succeeded":"failed") << endl;
    return (ok?EXIT_SUCCESS:EXIT_FAILURE);
}
What would be the equivalent without "?:" ? Not as much fun IMHO. But about 10 years ago I wrote a compiler for XDR messages that emitted C and python code. I used flex and bison since I thought they are powerful and elegant tools. Problem was, few people who I worked with were comfortable with those two tools and did not have time to learn them. As a result, one person made a modification to add lisp generation, but after that the code just rotted. I was too tricky for my own good. The answer is that there is no clear cut answer. It is all trade offs.

Posted by Kurt | Permalink

08.29.2006 10:01

wired news on ubuntu

Roland has ordered our new server and we are thinking about what OS to put on it. It will not be Windows or Mac... it will be a Linux distro. Would have been fun to do OpenBSD, but we actually need to get work done. We are wondering about ubuntu.

Is Ubuntu Linux for You, Too? [wired.com]

Why would I want to install Ubuntu -- or any form of Linux?


Linux is free -- in many senses of the word. It costs nothing, and it's also free of corporate control and restrictions on how you can use your media. That recently prompted digital-rights advocate Cory Doctorow to switch from Apple Computer software to Ubuntu. He was concerned, for example, about Apple's proprietary software locking up his personal data. "Every day, I add thousands of e-mails to my e-mail repository," he said. "And for so long as Mail.app is using proprietary stores, that's an ever-growing liability."

Compared to Windows, Linux is also relatively free of malware attacks. For example, security company Panda Software records about 300 pieces of malware targeting Linux systems, versus more than 100,000 for Windows machines.

Can I run Ubuntu on my computer?

Most likely. The software is compiled for systems based on x86 processors (new Macs and most PCs with Intel or Advanced Micro Devices chips), 64-bit AMD Athlon PCs, older Macs with PowerPC processors, and Sun computers with the UltraSparc T1 chip. Canonical recommends the operating system for computers with as little as 256 MB of RAM.

Can I try Ubuntu before I get locked in?

The latest version (nicknamed "Dapper Drake") comes on a "live CD" that allows you to run the operating system -- albeit slowly -- without installing anything on the hard drive. The same CD can also be used to install Ubuntu alongside another OS, such as Windows. (At boot up, you can choose which operating system to load.) But be sure to choose the option of resizing your disk partition during the installation. Otherwise, Ubuntu may wipe out the previous operating system, applications and data -- as happened to this author (luckily, on a spare computer). ...

Can Ubuntu completely replace Windows or Mac OS X?

Probably not. It doesn't work perfectly out of the box. And even if you do get it working smoothly, you may miss industry-standard professional programs, such as Photoshop ...
So there you have it. It will solve a lot of problems, but I am not giving up my desktop mac box.

Posted by Kurt | Permalink

08.25.2006 20:28

local headers before or after the stdlib headers?

When writing C++ headers, I have always had the style of headers in this order:
  1. C stdlib headers (e.g. #include <cassert>)
  2. C++ stdlib headers (e.g. #include <iostream>)
  3. External C libs (e.g. tiff)
  4. External C++ libs (e.g. boost or Inventor)
  5. Local headers (e.g. #include "myheader.h")
But after talking to Brian Locke, I am not questioning that policy. The goals of header order are
  1. Make sure that header dependencies are correct (don't hide things that are left out - aka use the compiler)
  2. Be consistant so it is easy to find headers
That makes me think that the local headers are first so that if that header uses, for example, the C++ string lib, then the header has <string>. Also, classes that are referenced but not really used should be defined with just a "class foo;" forward which should definitely increase program performance. After that, what should the order be? I don't know. How about his:
  1. Local headers
  2. C stdlib headers
  3. C++ stdlib headers
  4. External C libs
  5. External C++ libs
I don't have Brian's code in front of me to see what he thought so look at a future blog post for what we finally settle on.

Posted by Kurt | Permalink

08.23.2006 16:44

Open Navigation Surface

Brian C. just pointed me at this website (which is hosted upstairs from my office): http://www.opennavsurf.org/.
 The Navigation Surface paradigm is a design for a databased
 alternative to traditional methods of representing bathymetric
 data. It aims to preserve the highest level of detail in every
 bathymetric dataset and provide methods for their combination and
 manipulation to generate multiple products for both hydrographic and
 non-hydrographic purposes. The advantages of the method over
 traditional schemes are such that a number of commercial vendors have
 adopted the technology. However, this means that there is a strong
 requirement for a method to communicate results in a vendor neutral
 technology. The Open Navigation Surface (ONS) project was designed to
 fill this gap by implementing a freely available source-code library
 to read and write all of the information required for a Navigation
 Surface.
I am going to try to use this on my current project which is now called the "Generalizer".

Posted by Kurt | Permalink

08.23.2006 16:41

Using delete with class pointers

Brian L and I were talking about pointers within C++ class and Brian told me something I didn't realize (because of my C background): calling delete on pointers that are 0 is ok! Nice. Here is a demostration program that builds itself 4 ways. It shows that if you initialize all your pointers in the constructor, then life is good.
./test-del.C


Building test-del-dbg

test-del-dbg(26565) malloc: *** Deallocation of a pointer not malloced test-del-dbg(26565) malloc: *** Deallocation of a pointer not malloced

Building test-del-opt

test-del.C: In function 'int main(int, char**)': test-del.C:53: warning: 'td_stack$foo' is used uninitialized in this function test-del.C:55: warning: 'td_stack$foobar' is used uninitialized in this function

test-del-opt(26573) malloc: *** Deallocation of a pointer not malloced test-del-opt(26573) malloc: *** Deallocation of a pointer not malloced test-del-opt(26573) malloc: *** Deallocation of a pointer not malloced

=========

Building test-del-dbg-init

Building test-del-opt-init
The results above come from this code:

#if 0
#!/usr/bin/env bash


echo echo Building test-del-dbg g++ -g -O0 -Wall -o test-del-dbg test-del.C ./test-del-dbg echo echo Building test-del-opt g++ -O3 -fexpensive-optimizations -DNDEBUG -Wall -o test-del-opt test-del.C ./test-del-opt

echo echo "=========" echo echo Building test-del-dbg-init g++ -g -O0 -Wall -o test-del-dbg-init test-del.C -DINITIALIZE ./test-del-dbg-init echo echo Building test-del-opt-init g++ -O3 -fexpensive-optimizations -DNDEBUG -Wall -o test-del-opt-init test-del.C -DINITIALIZE ./test-del-opt-init

exit #endif

// What does C++ do with pointers within a class? // Can the compiler do the right thing with pointers that have not been newed?

#include <iostream>

class TestDel { public: TestDel(); ~TestDel(); void print() {std::cout << *bar << "\n";} bool check(); private: int *foo; int *bar; double *foobar; };

TestDel::TestDel() { bar = new int(123); #ifdef INITIALIZE foo=0; foobar=0; #endif }

TestDel::~TestDel() { delete foo; delete bar; delete foobar; }

int main (int argc, char *argv[]) {

{ TestDel td_stack; }

TestDel *td_heap = new TestDel; delete td_heap;

return EXIT_SUCCESS; }

Posted by Kurt | Permalink

08.21.2006 12:09

NASA Software of the Year - air traffic management

From: owner-insider@LISTSERV.ABPI.NET
[mailto:owner-insider@LISTSERV.ABPI.NET] On Behalf Of
nasatechbriefs@LISTSERV.ABPI.NET
Sent: Monday, August 21, 2006 6:46 AM
To: INSIDER@LISTSERV.ABPI.NET
Subject: NASA Tech Briefs INSIDER 08/21/06


* Air Traffic Analysis Program Named NASA Software of the Year ...

NASA SOFTWARE OF THE YEAR A software-based analysis environment for exploring, developing, and evaluating advanced air traffic management (ATM) concepts has been named NASA's 2006 Software of the Year. FACET (Future ATM Concepts Evaluation Tool) was developed by a team at NASA's Ames Research Center in California led by Dr. Banavar Sridhar, and has been implemented by the Federal Aviation Administration (FAA), as well as commercial and general aviation. FACET-developed techniques are enabling traffic flow management and dynamic airspace configuration to reduce airport delays and increase overall efficiency of our nation's airspace system. Engine noise data, exhaust dispersion data, and existing trajectory information are modeled in FACET for the design of environmentally friendly airports and approach paths.The program's ability to simulate large-scale, complex systems can be applied horizontally to planning other large networks, including the Internet and data communications, ground transportation, and power distribution grids. Visit http://link.abpi.net/l.php?20060821A2 for more information on FACET, as well as the other nominated software.

Posted by Kurt | Permalink

08.21.2006 09:50

Apple X11 menu

Just recreated my nanoblogger add entry menu option. From X11, go to the Applications menu and select customize. Add a new entry with this command:
xterm -bg black -fg white -r -sb -sl 1000 -e "nb -a"
That's it!

Posted by Kurt | Permalink

08.21.2006 09:47

NASA-Pixar visualization

Forwarded by Larry. From the Washington Post...
Telling NASA's Tales With Hollywood's Tools*


Space Center Uses Pixar's Palette To Artfully Explain Scientific Data

/By Michael S. Rosenwald

Washington Post Staff Writer Monday, August 21, 2006; Page D01

Every once in a while when a new movie with mind-blowing special effects or /oh-my-gosh-it-looked-so-real/ animation opens, a nondescript office at NASA Goddard Space Center in Greenbelt will mysteriously empty of employees during matinee hours.

Before an investigation is launched into the whereabouts of these workers -- particularly, say, around last year's opening of "Star Wars: Episode III -- Revenge of the Sith" -- understand that they are not blowing off work. The absentee employees are animators, NASA staffers and contractors who use the same software Pixar Animation Studios uses to tell stories about talking cars to instead tell stories about the Earth. They just want to see what their counterparts in Hollywood have been up to. ...

Posted by Kurt | Permalink

08.21.2006 09:40

unittest++

The first draft of some unittest++ docs are available here: http://www.winwonk.com/temp/unittest++.html. So that they don't dissappear, here the are:




UnitTest++ in brief

UnitTest++ in brief

Introduction

This little document serves as bare-bones documentation for UnitTest++.



For background, goals and license details, see:





The documentation, while sparse, aims to be practical, so it should give you enough info to get started using UnitTest++ as fast as possible.



Building UnitTest++

Building UnitTest++ will be specific to each platform and build environment, but it should be straightforward.



Building with Visual Studio

If you are using Visual Studio, go for either of the provided .sln files, depending on version. There are no prefabricated solutions for versions earlier than VS.NET 2003, but we have had reports of people building UnitTest++ with at least VS.NET 2002.



Building with Make

The bundled makefile is written to build with g++. It also needs sed installed in the path, and to be able to use the mv and rm shell commands. The makefile should be usable on most Posix-like platforms.



Do "make all" to generate a library and test executable. A final build step runs all unit tests to make sure that the result works as expected.



Packaging

You'll probably want to keep the generated library in a shared space in source control, so you can reuse it for multiple test projects. A redistributable package of UnitTest++ would consist of the generated library file, and all of the header files in UnitTest++/src/ and its per-platform subfolders. The tests directory only contains the unit tests for the library, and need not be included.



Using UnitTest++

The source code for UnitTest++ comes with a full test suite written using UnitTest++. This is a great place to learn techniques for testing. There is one sample .cpp file: UnitTest++/src/tests/TestUnitTest++.cpp. It covers most of UnitTest++'s features in an easy-to-grasp context, so start there if you want a quick overview of typical usage.



Getting started

Listed below is a minimal C++ program to run a failing test through UnitTest++.



  // test.cpp
  #include <UnitTest++.h>


TEST(FailSpectacularly) { CHECK(false); }

int main() { return UnitTest::RunAllTests(); }


UnitTest++.h is a facade header for UnitTest++, so including that should get you all features of the library. Note that all classes and free functions are placed in namespace UnitTest, so you need to either qualify their full names (as with RunAllTests() in the example) or add a using namespace UnitTest; statement in your .cpp files.



This needs to be linked with UnitTest++'s static library, whose name varies with platform. Making and running this program will produce the following output (details may vary):



  .\test.cpp(5): error: Failure in FailSpectacularly: false
  FAILED: 1 out of 1 tests failed (1 failures).
  Test time: 0.00 seconds.


UnitTest++ attempts to report every failure in an IDE-friendly format, depending on platform (e.g. you can double-click it in Visual Studio's error list.) The exit code will be the number of failed tests, so that a failed test run always returns a non-zero exit code.



Test macros

To add a test, simply put the following code in a .cpp file of your choice:



  TEST(YourTestName)
  {
  }


The TEST macro contains enough machinery to turn this slightly odd-looking syntax into legal C++, and automatically register the test in a global list. This test list forms the basis of what is executed by RunAllTests().



If you want to re-use a set of test data for more than one test or provide setup/teardown for tests, you can use the TEST_FIXTURE macro instead. The macro requires that you pass it a class name that it will instantiate, so any setup and teardown code should be in its constructor and destructor.



  struct SomeFixture
  {
    SomeFixture() { /* some setup */ }
    ~SomeFixture() { /* some teardown */ }


int testData; }; TEST_FIXTURE(SomeFixture, YourTestName) { int temp = testData; }


Note how members of the fixture are used as if they are a part of the test, since the macro-generated test class derives from the provided fixture class.



Suite macros

Tests can be grouped into suites, using the SUITE macro. A suite serves as a namespace for test names, so that the same test name can be used in two difference contexts.



  SUITE(YourSuiteName)
  {
    TEST(YourTestName)
    {
    }


TEST(YourOtherTestName) { } }


This will place the tests into a C++ namespace called YourSuiteName, and make the suite name available to UnitTest++. RunAllTests() can be called for a specific suite name, so you can use this to build named groups of tests to be run together.



Simple check macros

In test cases, we want to check the results of our system under test. UnitTest++ provides a number of check macros that handle comparison and proper failure reporting.



The most basic variety is the boolean CHECK macro:



  CHECK(false); // fails


It will fail if the boolean expression evaluates to false.



For equality checks, it's generally better to use CHECK_EQUAL:



  CHECK_EQUAL(10, 20); // fails
  CHECK_EQUAL("foo", "bar"); // fails


Note how CHECK_EQUAL is overloaded for C strings, so you don't have to resort to strcmp or similar. There is no facility for case-insensitive comparison or string searches, so you may have to drop down to a plain boolean CHECK with help from the CRT:



  CHECK(std::strstr("zaza", "az") != 0); // succeeds


For floating-point comparison, equality isn't necessarily well-defined, so you should prefer the CHECK_CLOSE macro:



  CHECK_CLOSE(3.14, 3.1415, 0.01); // succeeds


All of the macros are tailored to avoid unintended side-effects, for example:



  int i = 4;
  CHECK_EQUAL(5, ++i); // succeeds
  CHECK_EQUAL(5, i); // succeeds


The check macros guarantee that the ++i expression isn't repeated internally, as demonstrated above.



Array check macros

There is a set of check macros for array comparison as well:



  const float oned[2] = { 10, 20 };
  CHECK_ARRAY_EQUAL(oned, oned, 2); // succeeds
  CHECK_ARRAY_CLOSE(oned, oned, 2, 0.00); // succeeds


const float twod[2][3] = { {0, 1, 2}, {2, 3, 4} }; CHECK_ARRAY2D_CLOSE(twod, twod, 2, 3, 0.00); // succeeds


The array equal macro compares elements using operator==, so CHECK_ARRAY_EQUAL won't work for an array of C strings, for example.



The array close macros are similar to the regular CHECK_CLOSE macro, and are really only useful for scalar types, that can be compared in terms of a difference between two array elements.



Note that the one-dimensional array macros work for std::vector as well, as it can be indexed just as a C array.



Exception check macros

Finally, there's a CHECK_THROW macro, which asserts that its enclosed expression throws the specified type:



  struct TestException {};
  CHECK_THROW(throw TestException(), TestException); // succeeds


UnitTest++ natively catches exceptions if your test code doesn't. So if your code under test throws any exception UnitTest++ will fail the test and report either using the what() method for std::exception derivatives or just a plain message for unknown exception types.



Should your test or code raise an irrecoverable error (an Access Violation on Win32, for example, or a signal on Linux), UnitTest++ will attempt to map them to an exception and fail the test, just as for other unhandled exceptions.



Time constraints

UnitTest++ can fail a test if it takes too long to complete, using so-called time constraints.



They come in two flavors; local and global time constraints.



Local time constraints are limited to the current scope, like so:



  TEST(YourTimedTest)
  {
     // Lengthy setup...
     {
        UNITTEST_TIME_CONSTRAINT(50);
        // Do time-critical stuff
     }
     // Lengthy teardown...
  }


The test will fail if the "Do time-critical stuff" block takes longer than 50 ms to complete. The time-consuming setup and teardown are not measured, since the time constraint is scope-bound. It's perfectly valid to have multiple local time constraints in the same test, as long as there is only one per block.



A global time constraint, on the other hand, requires that all of the tests in a test run are faster than a specified amount of time. This allows you, when you run a suite of tests, to ask UnitTest++ to fail it entirely if any test exceeds the global constraint. The max time is passed as a parameter to an overload of RunAllTests().



If you want to use a global time constraint, but have one test that is notoriously slow, you can exempt it from inspection by using the UNITTEST_TIME_CONSTRAINT_EXEMPT macro anywhere inside the test body.



  TEST(NotoriouslySlowTest)
  {
     UNITTEST_TIME_CONSTRAINT_EXEMPT();


// Oh boy, this is going to take a while ... }


Test runners

The RunAllTests() function has an overload that lets you customize the behavior of the runner, such as global time constraints, custom reporters, which suite to run, etc.



  int RunAllTests(TestReporter& reporter, TestList const& list, char const* suiteName, int const maxTestTimeInMs);


If you attempt to pass custom parameters to RunAllTests(), note that the list parameter should have the value Test::GetTestList().



The parameterless RunAllTests() is a simple wrapper for this one, with sensible defaults.



Typical setup

How to create a new test project varies depending on your environment, but here are some directions on file structure and common usage.



The general idea is that you keep one Main.cpp file with the entry-point which calls RunAllTests().



Then you can simply compile and link new .cpp files at will, typically one per test suite.



   + ShaverTests/
   |
   +- Main.cpp
   |
   +- TestRazor.cpp
   +- TestEngine.cpp
   +- TestBrush.cpp


Each of the Test*.cpp files will contain one or more TEST macro incantations with the associated test code. There are no source-level dependencies between Main.cpp and Test*.cpp, as the TEST macro handles the registration and setup necessary for RunAllTests() to find all tests compiled into the same final executable.



It's common to make the generated executable start as a post-build step, so that merely building your test project will run the tests as well. Since the exit code is the count of failures, a failed test will generally break the build, as most build engines will fail a build if any step returns a non-zero exit code.


Posted by Kurt | Permalink

08.17.2006 08:15

ints as booleans and return codes

I used to be very comfortable with ints used as booleans, but as I program more with languages that have bools (even C99 has bools), I get very uncomfortable with numbers representing true state. It is much more natural to check a return code as being true for success or false for failure. In C, sometime 0 means everything is great and other times it means that something bad happens. Yesterday while looking at some inherited code, I had to refresh my brain and started overhauling the code to use bool return codes. First, I had to get rid of strcmp to see if two strings are equal. That just causes bugs... did they mean to use !=0 or ==0? It is easy to get them backwards. We all can guess what strequ means, right?
inline bool strequ(const char *s1, const char *s2) {
    return strcmp(s1,s2)==0;
}
Then I had to write a program to double check what C thinks of integers when treating them as booleans.
#include <iostream>
int main(int argc,char *argv[]) {
    std::cout << "-1 evaluates to " << (-1?"true":"false") << std::endl;
    std::cout << " 0 evaluates to " << ( 0?"true":"false") << std::endl;
    std::cout << " 1 evaluates to " << ( 1?"true":"false") << std::endl;
    return 0;
}
Which tells me what I need to know (and should have remembered!)
./bool
-1 evaluates to true
 0 evaluates to false
 1 evaluates to true

Posted by Kurt | Permalink

08.15.2006 13:29

Google marine data

http://www.justmagic.com/GM-GE.html was posted on the rvtec mailing list.


Posted by Kurt | Permalink

08.15.2006 10:22

slogcxx 0.5

I just put slogcxx-0.5 on the ccom ftp site. This adds support for size_t which I seem to end up using all the time with the C++ STL containers.

http://freshmeat.net/projects/slogcxx/

The source can be had as a tarball here: http://freshmeat.net/redir/slogcxx/65728/url_bz2/slogcxx-0.4.tar.bz2

Or if you are a part of ccom, you can check out the svn tree:

Posted by Kurt | Permalink

08.15.2006 09:23

STL map of vectors example

Arg. Figuring this out took way to long. I know I had this worked out a couple years ago, but I never took good notes (it was before I talked to Anne Wright about notes files and way before I started blog entries). But now, I have a simple example that at least I can understand. I just want a lookup table based on ship MMSI that will have lists for time stamped position records. Then I can somehow make an Inventor visualization system for AIS. Not sure what to do about the Coin/Inventor arch yet, but here is my sample code.
#include <map>
#include <string>
#include <iostream>
#include <slogcxx.h>


using namespace std; #ifdef __GNUC__ #define UNUSED __attribute((__unused__)) #else #define UNUSED #endif typedef vector<int> VecInt; typedef map<int, VecInt> VecIntMap;

int main (UNUSED int argc, char *argv[]) { bool ok=true; Slog slog((string(argv[0])+string(".log")));

VecInt vi;

for (int i=20; i<100; i+= 11) { vi.push_back(i); }

VecIntMap vim; vim[1] = vi; vi.push_back(-1); vim[2] = vi;

slog << "Adding a -2 to both lists" << endl; for (VecIntMap::iterator it = vim.begin(); it != vim.end(); ++it) { slog << int(it->second.size()) << endl; it->second.push_back(-2); }

for (VecIntMap::iterator it = vim.begin(); it != vim.end(); ++it) { slog << "size of " << it->first << ": " <<int(it->second.size()) << endl; for (VecInt::iterator p = it->second.begin(); p != it->second.end(); ++p) { slog << *p << " "; } slog << endl; }

slog << " " << argv[0] << " test: " << (ok?"ok":"failed")<<endl; return (ok?EXIT_SUCCESS:EXIT_FAILURE); }
That is not the simplest example possible. You can ignore the "ok" stuff. I just pulled this main from a file with my funky test code. I use the slogcxx library, but you can replace slog with cout and it should work just fine. To build it on my Mac, here is the command:
g++ map.C -o map -Wall -Wimplicit -pedantic -W \
  -Wredundant-decls -I/sw/include -L/sw/lib  \
  -g3 -O0 -D_GLIBCXX_DEBUG -lslogcxx
Running the program looks like this:
./map
Opening log file: './map.log'
 0: started logging
 0: Adding a -2 to both lists
 0: 8
 0: 9
 0: size of 1: 9
 0: 20 31 42 53 64 75 86 97 -2 
 0: size of 2: 10
 0: 20 31 42 53 64 75 86 97 -1 -2 
 0:   ./map test:  ok
 0: stopped logging
Looking at the map.log file, you can see that I still have the time formatting bug (grr)...
<slogcxx>
<entry time="1.15565e+09">started logging</entry>
<entry time="1.15565e+09">Adding a -2 to both lists</entry>
<entry time="1.15565e+09">8</entry>
<entry time="1.15565e+09">9</entry>
<entry time="1.15565e+09">size of 1: 9</entry>
<entry time="1.15565e+09">20 31 42 53 64 75 86 97 -2 </entry>
<entry time="1.15565e+09">size of 2: 10</entry>
<entry time="1.15565e+09">20 31 42 53 64 75 86 97 -1 -2 </entry>
<entry time="1.15565e+09">  ./map test:  ok</entry>
<entry time="1.15565e+09">stopped logging</entry>
</slogcxx>

Posted by Kurt | Permalink

08.14.2006 11:36

Passwd troubles

Starting Friday afternoon, my passwd stopped working for imap and webmail. I had no idea what was wrong. This morning, Will explained to me what happened. My Active Directory passwd had expired. Since I never use windows, nothing told me that I needed to change to a new passwd. Loging into a windows box at work popped up a change passwd dialog and life is back to normal.

Posted by Kurt | Permalink

08.11.2006 08:29

SDL_net client tutorial

Here is about the simplest example of using SDL_net. I am just reading from a port. The key is to make sure that the process does a non blocking read and then tells the OS to reschedule. The usleep(1) allows other stuff to get a chance. This is basically poll mode.

The idea is that a process will fetch all of the available data in a timer callback from an OpenInventor program.

The first couple lines are a cleaver hack to make the source an executable script that compiles the program.
#if 0
#!/bin/sh
g++ -Wall `sdl-config --cflags` sdl.c -o sdl `sdl-config --libs` -lSDL_net
 
exit
#endif
// Try out SDL_net
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> // usleep


#include <iostream> using namespace std;

#include <SDL_net.h> int main(int argc, char **argv) { IPaddress ip; /* Server address */ TCPsocket sd; /* Socket descriptor */ char buffer[512]; /* Simple parameter checking */ if (argc < 3) { fprintf(stderr, "Usage: %s host port\n", argv[0]); exit(EXIT_FAILURE); } if (SDLNet_Init() < 0) { fprintf(stderr, "SDLNet_Init: %s\n", SDLNet_GetError()); exit(EXIT_FAILURE); } /* Resolve the host we are connecting to */ if (SDLNet_ResolveHost(&ip, argv[1], atoi(argv[2]))) { fprintf(stderr, "SDLNet_ResolveHost: %s\n", SDLNet_GetError()); exit(EXIT_FAILURE); } /* Open a connection with the IP provided (listen on the host's port) */ if (!(sd = SDLNet_TCP_Open(&ip))) { fprintf(stderr, "SDLNet_TCP_Open: %s\n", SDLNet_GetError()); exit(EXIT_FAILURE); }

SDLNet_SocketSet set = SDLNet_AllocSocketSet(1); // Set of only one socket SDLNet_TCP_AddSocket(set,sd); // CheckSockets only takes a set int len; //while (true) { for (size_t i=0; i < 10000; i++) { if(SDLNet_CheckSockets(set,0)) { // Have data so it should not block, right? len=SDLNet_TCP_Recv(sd, buffer, 512); if (len>0) { cout << "ais: [" << len << "]" << buffer << "\n"; //cout << " " << len; } else { cout << "nop\n"; exit(EXIT_SUCCESS); } } else { // Check //cout << "Nothing in check\n"; } usleep(1); }

SDLNet_TCP_Close(sd); SDLNet_Quit(); return EXIT_SUCCESS; }

Posted by Kurt | Permalink

08.11.2006 07:53

Why nb is so slow

Ah... I know why nb is taking forever! I killed the cache and it has to reprocess every single entry. It will take a while with 1265 entries!

Posted by Kurt | Permalink

08.11.2006 07:51

Blog in svn

I am currently trying to figure out what to do with my blog and how to keep myself writing. I have only done a couple entries in the last month or two since schwehr.org went down. Now with the blog in svn, I can make entries, I just don't know what to do with them and I am quickly outgrowing nanoblogger. I need to find something else and create a way to migrate my entries to said new blog tool.

Even on a 4x2.5GHz mac the blog takes a long time to process a new entry. After a couple minutes, it is still going. That is not good! Maybe the newer versions of nanoblogger are faster, but I really need to get to a real database!

For now, I will probably throw the pages up on an machine that is only viewable internally from work.

Posted by Kurt | Permalink

08.11.2006 07:46

m4

I've looked at m4 data before, but haven't looked at anything in ages. When I saw m4 pop up in the list of packages to update in fink, I figured that I'd kick the tires. Gotta keep playing with those obscure languages to keep the brain sharp.
#!/usr/bin/env m4


eval(1+1) format(`Result is %d', eval(2**15))
Which gives this:
./foo.m4 


#!/usr/bin/env m4 2 Result is 32768

Posted by Kurt | Permalink

08.05.2006 10:07

slogcxx

Yesterday, I submitted slogcxx to freshmeat. It is not yet showing up in the project search, but the URL's are: The ftp server is pretty cranky, so you may have to go in by hand and be sure to put in the user as 'anonymous' as the server can't handle the ftp alias and it will complain about multiple connections.

Posted by Kurt | Permalink