contract CappedMintableToken is PausableToken {

    uint256 public hard_cap;
    // List of agents that are allowed to create new tokens
    mapping (address => bool) mintAgents;

    event MintingAgentChanged(address addr, bool state);
    event Mint(address indexed to, uint256 amount);

    /*
     * @dev Modifier to check if `msg.sender` is an agent allowed to create new tokens
     */
    modifier onlyMintAgent() {
        require(mintAgents[msg.sender]);
        _;
    }

    /**
     * @dev Owner can allow a crowdsale contract to mint new tokens
     */
    function setMintAgent(address addr, bool state) onlyOwner whenNotPaused  public {
        mintAgents[addr] = state;
        MintingAgentChanged(addr, state);
    }

    /**
     * @dev Function to mint tokens
     * @param _to The address that will receive the minted tokens.
     * @param _amount The amount of tokens to mint.
     * @return A boolean that indicates if the operation was successful.
     */
    function mint(address _to, uint256 _amount) onlyMintAgent whenNotPaused public returns (bool) {
        require (totalSupply.add(_amount) <= hard_cap);
        totalSupply = totalSupply.add(_amount);
        balances[_to] = balances[_to].add(_amount);
        Mint(_to, _amount);
        Transfer(address(0), _to, _amount);
        return true;
    }

    /**
     * @dev Gets if an specified address is allowed to mint tokens
     * @param _user The address to query if is allowed to mint tokens
     * @return An bool representing if the address passed is allowed to mint tokens 
     */
    function isMintAgent(address _user) public view returns (bool state) {
        return mintAgents[_user];
    }

}
/**
 * @title Capped Mintable token
 * @dev Simple ERC20 Token example, with mintable token creation
 * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
 */
function setMintAgent(address addr, bool state) onlyOwner whenNotPaused  public {
    mintAgents[addr] = state;
    MintingAgentChanged(addr, state);
}

/**
 * @dev Owner can allow a crowdsale contract to mint new tokens
 */