Add pattern.h

add pattern.h and partially complete patterns.cpp