LibHijackMinimap is a library that provides centralized handling for re-parenting the minimap.
LHM provides functionality to handle multiple hijackers and brokers requests between hijacker and client addons. 

Addons that draw to the minimap (clients) and want to support minimap replacement/reparenting can register to this library with a callback that is executed on minimap replacement. In the callback routine the client has to handle the reparenting of their minimap items.

Addons that replace the minimap (hijackers) and want to notify clients can register to this library and use library calls to notify the hijack and release of the minimap.

Clients can be blacklisted for hijacking by specific hijackers. If more than one hijacker addon replaced the minimap for a client the first hijacker wins. If a hijacker restores the minimap the client will fall back to the next valid hijacker or be restored to the minimap if none.

The blacklisting can be configured through an external addon. Only one addon can be used for configuration. As default LibHijackMinimap-1.0-Options has been designed to the job.

With LibHijackMinimap hijacker addons don't have direct control over which client addons they hijack and therefore don't need to provide a setup for this.

With a single hijacker addon and assuming the user will want to see all client addons on the minimap replacement this behaviour is the default with no need for the options addon.

===============================================================================
== Example                                                                   ==
===============================================================================

==============
== Hijacker ==
==============

local AddonName = "Hijacker"
local Addon = LibStub:GetLibrary("AceAddon-3.0"):NewAddon(AddonName)
local LHM = LibStub:GetLibrary("LibHijackMinimap-1.0")

-- used as private unique id to authenticate hijack requests with LHM
local lhmToken = {}

LHM:RegisterHijacker(AddonName, lhmToken)

function Addon:HijackMinimap(frame)
	if not frame then
		return
	end

	LHM:HijackMinimap(lhmToken, frame)
end

function Addon:ReleaseMinimap()
	LHM:ReleaseMinimap(lhmToken)
end

==============
== Client ==
==============

local AddonName = "Client"
local Addon = LibStub:GetLibrary("AceAddon-3.0"):NewAddon(AddonName)
local LHM = LibStub:GetLibrary("LibHijackMinimap-1.0")

function Addon:ReparentMinimap(frame)
	if not frame then
		return
	end

	-- in case hijacker did not provide optional argument "ROTATE_MINIMAP" in SetCVar("rotateMinimap", value, "ROTATE_MINIMAP") so CVAR_UPDATE did not fire
	local rotateMinimap = GetCVar("rotateMinimap") == "1"

	-- reparent your minimap items
end

LHM:RegisterClient(AddonName, Addon, "ReparentMinimap")

===============================================================================
== Alphabetical API Reference                                                ==
===============================================================================

===
LHM:Blacklist(hijackerName, clientName, enable, optionsToken)

Parameters

hijackerName - Name of hijacker to blacklist the clients for.
clientNames - Name of client to blacklist for hijacker.
enable - Boolean indicating if client should be blacklisted or not.
optionsToken - The private token of the instance doing the setting. Note: There can only be a single instance doing all the settings. (Possibly LibHijackMinimap-1.0-Options)

===
LHM:GetClientSettingsActive()

Returns true if any instance registered to apply settings. (When LibHijackMinimap-1.0-Options aplies the client mappings.)

===
LHM:GetCurrentHijacker(clientName)

Returns name of current hijacker for client with given name.

clientName - Name of client to check.

===
LHM:HijackMinimap(token, frame)

Notify replacement of minimap with different frame for hijacker with given token.

Parameters

token - The private token of the hijacker. Used so third parties cannot act instead of the original hijacker.
frame - The frame used by hijacker as minimap replacement.

===
LHM:IsActive()

Returns true if handling of minimap replacement is activated. 
On start up the handling is active.

===
LHM:IsBlacklisted(hijackerName, clientName)

Returns true id the client is blacklisted for hijacker otherwise false.

hijackerName - Name of the hijacker for the lookup.
clientName - Name of the client for the lookup.

===
LHM:IsClientRegistered(name)

Returns true if client with given name is registered.

Parameters

name - Name of the client to check.

===
LHM:IsHijackerRegistered(name)

Returns true if hijacker with given name is registered.

Parameters

name - Name of the hijacker to check.

===
LHM:IsMinimapReplaced(hijackerName)

Returns true if minimap is replaced by hijacker with given name.

Parameters

hijackerName - Name of hijacker to check.

===
LHM:IterateClients()

Returns iterator that provides all registered clients.

===
LHM:IterateClientsForHijacker(hijackerName)

Returns iterator that provides the client names that are not blacklisted with a hijacker.

Parameters

hijackerName - Name of hijacker for which the iterator should provide the client names.

===
LHM:IterateHijackers()

Returns iterator that provides all registered hijackers.

===
LHM:RegisterClient(name, handle, func)

Registers client for handling of minimap replacements.

Parameters

name - Name of the client.
handle - Handle of the client. If arg is string global variable of that name will be looked up and used.
func - Function handling the minimap replacement for client. If arg is string function of that name will be looked up in handle.

===
LHM:RegisterHijacker(name, token)

Registers hijacker for executing minimap replacements.

Parameters

name - Name of the hijacker.
token - The private token of the hijacker. Used so third parties cannot act instead of the original hijacker.

===
LHM:ReleaseMinimap(token)

Notify restoration of minimap for hijacker with given token.

Parameters

token - The private token of the hijacker. Used so third parties cannot act instead of the original hijacker.

===
LHM:SetActive(active, optionsToken)

Activates or deactivates handling of minimap replacements.
If deactivated all replacements are reverted and hijackers registering replacements are registered but not executed.
If activated all replacements registered for hijackers are forwarded to the respective clients and new replacements are handled again.

Parameters

active - flag indicating if operation should be active or not.
optionsToken - The private token of the instance doing the setting. Note: There can only be a single instance doing all the settings. (Possibly LibHijackMinimap-1.0-Options)

===
LHM:UnregisterClient(handle)

Unregisters client for handling of minimap replacements.

Parameters

handle - Handle the client registered with.

===
LHM:UnregisterHijacker(token)

Unregisters client for handling of minimap replacements.

Parameters

token - The private token of the hijacker registered with.




