Text this: All-optical switching in bacteriorhodopsin based on M state dynamics and its application to photonic logic gates