in reply to A Not-as-Clumsy OOP Implementation?

I recently have been working on a similar project (it's open in the other window, that's how recent it is...). I tend to rip off other peoples ideas ( I just call it 'taking inspiration') and this model has been solved before, by the ipchains/iptables people.

My OO - fu is a bit weak, the only two objects that need to be objects in the examples below are the packets (which I use to unpack/pack the binary stream) and the packet engines (which maintain state, sockets and other neat stuff). The tally and function objects may as well be straight functions, but if you're going OO, you may as well go the whole hog.

As near as I can tell the goal of OO is to combine data and code, so anytime you see data, you want to attach code to it. Thus the packets should be objects, and so should the engines. Otherwise you just have modular code, i.e. modules, which perl already does fine. This approach also minimises your packet variables, and notice - no true globals.

---Broad outline: Get packets Tally stats Mangle them Tally stats Send 'em out B---road outline, 10x magnification: Get packets from packet engine Run them through the tally object Mangle packets with custom packet mangler (TM) Tally object... Send them out through the packet engine ---Broad outline, 100x mag: foreach $packet_engine ( @all_packet_engines ) { push @incoming_packet_queue, $packet_engine_object->get_packets; } $stats_object->tally(@incoming_packet_queue); @outgoing_packet_queue = $function_object->mangle(@incoming_packet_que +ue); @incoming_packet_queue = (); $stats_object->tally(@outgoing_packet_queue); foreach $packet ( @outgoing_packet_queue ) { #insert clever routing logic for packets e.g. foreach $engine ( @all_packet_engines ) { if ( $packet->{ATTRIB} == $engine->{ATTRIB} ) {$engine->send($packet) +} } }

now all you have to do is fill in the thousands of lines of code for each object. It's 3am, so maybe it's not so clear. Read up on ipchains for the idea I'm working with here.

To make it more like ipchains, you would have multiple function objects (or multiple routines in the function object), and allow the objects(functions) to pass the packet to each other. Each function would mangle the packet until one of them passed it to the output routing object.

____________________
Jeremy
I didn't believe in evil until I dated it.