Electronic Structures of Antiperovskite Superconductor MgCNi$_3$ and Related Compounds