Archive

Archive for September, 2011

Working with traits…

September 22, 2011 3 comments

URGH!

I’m trying to write something along the lines of:


template<typename _ItrType>
static size_t countThings(_ItrType begin, _ItrType end)
{
  size_t numThings = 0 ;
  for ( _ItrType it = begin ; it != end ; ++it )
  {
    Entity& entity = getEntityFromIterator(it) ;
    numThings += entity.numThings ;
  }
}

// Handle associative iterators.
template<typename _KeyType>
Entity& getEntityFromIterator(std::pair<_KeyType, Entity&>& it)
{
  return it.second ;
}

template<typename _KeyType>
Entity& getEntityFromIterator(std::pair<_KeyType, Entity*>& it)
{
  return *(it.second) ;
}

template<typename _KeyType>
Entity& getEntityFromIterator(std::pair<_KeyType, Entity>& it)
{
  return it.second ;
}

// Handle sequence iterators.
template<typename _ItrType>
Entity& getEntityFromIterator(_ItrType& it)
{
  return *it ;
}

I.e. something that will allow me to write a function that will take an iterator range and worry about whether the iterators are sequence or container for me at compile time.

But it always falls thru to my last case. The error from GCC indicates that I need to specifically look  std::_RB_tree_iterator<std::pair<_KeyType, Entity>> etc, but I’d rather not. I’m wanting to do something to peel back until we get to an Entity, e.g.

template<typename _Outer, typename _Inner>get(_Outer<_Inner>& container) { return *container ; }
template<typename _Key, typename _Value> get(_Key, _Value entity) { return get(entity) ; }
get(Entity& entity) { return entity ; }
get(Entity* entity) { Return *entity ; }

Cannot seem to find a way to get this to work, and I’m starting to think I probably need to do some traits jiggery-pokery. Grr.

Categories: Coding Tags: ,

QuickPath owns

September 20, 2011 4 comments

When Gophur was building my desktop workstation about a year ago, there were various considerations. While it was fun having multiple PCs, it gets old when it comes to moving stuff around between them. I could also better justify a heavier-hitting machine by having one PC to run not only my desktop but also my other machines virtually.

Somehow, though, I let Goph talk me down to an i3 or i5 – I don’t even remember. What I do know is that it is not an i7.

The i-core CPUs feature Intel’s new QuickPath technology. Short version? Replace the single-lane, cobblestone paved connection between processor and memory, disk, etc with a 2 or 4 lane highway.

If you remember AGP, QuickPath is kinda AGP for everyone and AGP on steroids.

Before QuickPath your processor had a single pipeline (“bus“) for talking to memory, disks, etc.

QuickPath provides a way for the CPU to have multiple conversations going on with different hardware devices (sound chips, graphics card, disks, memory, etc) etc. It also allows the chip to have an onboard memory controller so that the CPU can talk to multiple sticks or banks of memory at the same time.

Which is handy for the CPU if it plans on, say, multi-tasking.

Read more…

Categories: Rants & Opinions

W8DP (Windows 8 Dev Preview) Continued…

September 18, 2011 2 comments

This has to be really early days for the UI; the phone UI heritage screams at you. For example: There’s no clear and evident “shutdown” or “reboot” interface.

If you click on your “User tile” on the start screen/menu/page you get an option to log off.

Sometimes, right-clicking screens works and you get an app-wide context menu. But it doesn’t seem consistent.

The lack of a close-app button is bothering me greatly, hehe.

 

Categories: Rants & Opinions Tags:

Windows 8 (Dev Preview)

September 16, 2011 3 comments

I’m in the middle of moving house, we just finally got into our apartment properly last night. For my test of Internet connectivity, I decided to download the Windows 8 Developer Preview. This morning, while waiting for the carpet guy to come collect his ozone machine (they cleaned the carpets but that didn’t remove the dog-pee stains or the smells of smoke, weed or dog), I gave it a very quick spin.

Read more…

Socket buffers

September 6, 2011 1 comment

If you want to experiment with code for my earlier question about setsockopt and send buffer truncation, I’ve written a small test program (Linux based, might work on Mac too tho, shouldn’t be too hard to port to Winsock)

http://www.kfs.org/oliver/socket.cpp

I haven’t had to look at sockets this way for a very long time, but now that I am, I’m remembering how bloody annoying the supposedly ultra-clean and simple BSD socket API is…

Read more…

Categories: Coding Tags: ,

Sockets: data black holes.

September 6, 2011 5 comments

Sometimes, the opacity of the BSD socket interface is a real pain in the backside.

For example, what happens if you do the following:

/* Set a 4k outgoing buffer size */
int bufSize = 8*1024 ;
setsockopt(socket, SOL_SOCKET, SO_SNDBUF,  &bufSize, sizeof(int)) ;
/* Send 8k of data to a host we know will only receive 2k for a while */
retval = send(socket, buffer, bufSize) ;
/* Data is now in the send buffer, but the remote host
only has buffers for 2k, so 6k of our buffer is "hot" */
int shortSize = 2*1024 ;
int retval = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, &shortSize, sizeof(int)) ;
/* Did we just truncate the outgoing send buffer? Or will this generate an error */
Categories: Coding Tags: ,

Replacing playgate…

September 3, 2011 4 comments

Of course, there’s way more important things to do but replacing PlayGate is still on the todo list after my .NET rewrite got scratched due to a failure to understand what “this is a development version so it may require you to install various libraries and stuff” mean’t, and I had to keep the old Win32 C code alive, again.

The thing keeping me from resurrecting my .NET version is that either I’m missing something or .NET localization is a total pain in the backside – even with XAML?

 

Categories: Coding Tags: ,

I filed an FTC complaint…

September 2, 2011 2 comments

Lil ‘ole me.

I got a call the other day, from a friendly guy, an auditor. He’d seen an upcoming claim for nearly $300 and he wanted to save me some money and hassle by offering me the opportunity to pay it now and keep it from going on my record and stuff.

Chuckle.

Read more…

Categories: Rants & Opinions
Follow

Get every new post delivered to your Inbox.

Join 216 other followers