SQL refactoring.

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
mor
Posts: 45
Joined: Sat Apr 26, 2008 1:41 am

SQL refactoring.

Post 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
mor
Posts: 45
Joined: Sat Apr 26, 2008 1:41 am

Post by mor »

PS: Forgot to say, this is not seriously tested yet. I'm posting for comments on usefulness and style. thanks :)
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post 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:
mor
Posts: 45
Joined: Sat Apr 26, 2008 1:41 am

Post 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?
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

You can email the patch's directly to Philip. 8)
mor
Posts: 45
Joined: Sat Apr 26, 2008 1:41 am

Post 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.
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post 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.
Phil
Post Reply