Page 1 of 1

SQL refactoring.

Posted: Wed Apr 30, 2008 7:59 am
by mor
While I was distracted, I refactored the SQL handling. I turned zm_db.cpp into a class, changed everything else to use that class, and changed all the field accesses to reference by name.

I also extracted all the common code out of the LoadMonitor functions.

The combined result of these changes is to make the code about 300 lines shorter.

Patch is versus 1.23.3

Code: Select all

 src/zm_config.cpp  |   21 +--
 src/zm_db.cpp      |  175 +++++++++++--
 src/zm_db.h        |   56 ++++-
 src/zm_event.cpp   |  167 ++++--------
 src/zm_monitor.cpp |  756 ++++++++++++---------------------------------------
 src/zm_monitor.h   |    2 +
 src/zm_user.cpp    |   78 ++----
 src/zm_user.h      |    2 +-
 src/zm_zone.cpp    |   88 +++----
 src/zmfix.cpp      |   50 +---
 src/zmu.cpp        |   25 +--
 11 files changed, 535 insertions(+), 885 deletions(-)
Ok, I had posted the patch here, but it was turned into junk by the forum software. Seriously, you must have a better way for people to submit patches than cutting and posting them into forums!?!?

Actual patch is at http://www.dgmo.org/diffs/zm-1.diff

Posted: Wed Apr 30, 2008 8:34 pm
by mor
PS: Forgot to say, this is not seriously tested yet. I'm posting for comments on usefulness and style. thanks :)

Posted: Thu May 01, 2008 1:47 am
by cordel
So long as you follow Phil's original style, anything that helps speed up/optimize the binaries is always welcome :D

Well so long as it don't break anything of coarse :wink:

Posted: Thu May 01, 2008 4:13 am
by mor
cordel wrote:So long as you follow Phil's original style, anything that helps speed up/optimize the binaries is always welcome :D

Well so long as it don't break anything of coarse :wink:
Ok. I'll actually test this a bit and then repost it.

Is there a source code control system in use anywhere?
Is there a better way to submit patches than cutting and pasting into the forum?

Posted: Thu May 01, 2008 9:30 am
by cordel
You can email the patch's directly to Philip. 8)

Posted: Sat May 03, 2008 3:22 am
by mor
mor wrote: Ok. I'll actually test this a bit and then repost it.
Ok, tested version is here.

http://www.dgmo.org/diffs/zm-2.diff

This doesn't (shouldn't! :) ) change any functionality, it just makes all the SQL handler significantly shorter and easier to follow.

Posted: Mon May 05, 2008 7:26 pm
by zoneminder
Thanks. I will take a look at this when I get time. I have done the same with the php code already but not got around tothe c++ stuff yet.