Cleanup pthread code for data layers

Get rid of the ugly "friend" thread function. Simplify the creation of the
thread by inheriting from a base class. Thus, defining the thread is as
simple as overriding a virtual function.
Add NetState message with phase, level, stage; NetStateRule message with
filtering rules for Layers.
Add unit tests and skeleton code for Net/Solver filtering functionality.
Incorporate NetState{,Rule} into Solver/Net.  Net::FilterNet
includes/excludes layers based on whether the NetState meets each
layer's NetStateRule(s).
Use unified train/test nets in examples.
Merge pull request #734 from jeffdonahue/all-in-one-net

All-in-one nets
Merge pull request #710 from geenux/dev

Cleanup pthread code for data layers
fix some namespace with std::signbit
Set correct solver_mode in SolverTest so Travis build doesn't randomly
fail.
Also apply HDF5OutputLayer fix to GPU version.
Merge pull request #823 from jeffdonahue/hdf5output-gpu-fix

Apply HDF5OutputLayer fix to GPU version
Solver switching support & implementation of Nesterov's accelerated gradient and AdaGrad
restored vituals in solver.hpp
converted pointers to shared_ptr
fixed solver constructor in train_net.cpp
improved numerical stability for AdaGrad
bugfixes for AdaGrad
Added L1 regularization support for the weights
fixed caffe.proto after a mistaken rebase