A Hamiltonian state space approach to anisotropic elasticity and piezoelasticity