add hook restricted only to either plugins or themes?

Errm, you can’t. And more importantly, why would you want to? The whole point of hooks is to open up an API to other developers!

You can use a singleton/static flags and/or private methods (called from a hooked public method) if you want to lock down how your plugin can be manipulated.

static function myfunction_for_themes() {
    if ( ! self::$_themes_run /* private static property */ ) {
         self::_private_method();

         self::$_themes_run = true;
    }
}

A plugin/theme could still unhook the above method, but they wouldn’t be able to fire it more than once, nor can they call self::_private_method().