move registration code to corresponding cpp files.
Merge pull request #1270 from Yangqing/dev

Give back to layer what is layer's, and to factory what is factory's
Revert "OpenCV should be compiled using pkg-config options." -- breaks
compilation on working systems

This reverts commit 4587b2f9043996fed36fc989c00329ec829ecae9.
some namespace cleaning.
Merge pull request #1277 from Yangqing/dev

some more namespace cleaning.
Refactored leveldb and lmdb code.
Some cleanup to make travis happy.
Updated interface to make fewer string copies.
Don't autocommit on close for the databases.  If they were read-only, then they might fail.
data layer test was relying on the autocommit on close db behavior that was recently removed.
Updated cifar10 build script to specify db backend.
Switched create_cifar10.sh output from leveldb to lmdb.
Updated extract_features to take a leveldb/lmdb config option.
Updated Database interface to use custom KV type rather than std::pair.  Removed two buffer copies in dereference operation for DB iterators.
Added a couple of sanity checks to make sure the datum buffer sizes matched what we expected.
Added get interface to Database.  Added test cases for Database.  Fixed a few bugs related to ReadOnly mode in Database in order to pass test cases.
Added some tests for the Database iterator interface.  Updated the post-increment operator so that it forks off a copy of the LevelDB or LMDB iterator/cursor when necessary.  Neither of these APIs allow you to directly copy an iterator or cursor, so I create a new iterator and seek to the key that the previous one was currently on.  This means the pre-increment operator can be much cheaper than the post-increment operator.
Updated Database interface so that rather than CHECKing for certain conditions inside open, put, get, and commit, these functions return a bool indicating whether or not the operation was successful or a failure.  This means the caller is now responsible for error checking.
Updated Database interface to take key and value by const reference for put and key by const reference for put.  Additional copies are made for get and put in the LMDB implementation.
The LevelDB iterator/DB deallocation order bug is pretty much fixed by having each iterator hold a shared pointer to the DB.  I manually specified a deconstructor for the LeveldbState to make it clear what order these two things need to be deallocated in.