contract PlatformToken is CappedMintableToken {

    mapping (address => bool) trustedContract;

    event TrustedContract(address addr, bool state);

    /**
     * @dev Modifier that check that `msg.sender` is an trusted contract
     */
    modifier onlyTrustedContract() {
        require(trustedContract[msg.sender]);
        _;
    }

    /**
     * @dev The owner can set a contract as a trusted contract
     */
    function setTrustedContract(address addr, bool state) onlyOwner whenNotPaused public {
        trustedContract[addr] = state;
        TrustedContract(addr, state);
    }

    /**
     * @dev Function that trusted contracts can use to perform any buying that users do in the platform
     */
    function buy(address who, uint256 amount) onlyTrustedContract whenNotPaused public {
        require (balances[who] >= amount);
        balances[who] = balances[who].sub(amount);
        totalSupply = totalSupply.sub(amount);
    }

    /**
     * @dev Function to check if a contract is marked as a trusted one
     * @param _contract The address of the contract to query of
     * @return A bool indicanting if the passed contract is considered as a trusted one
     */
    function isATrustedContract(address _contract) public view returns (bool state) {
        return trustedContract[_contract];
    }

}
/**
 * @title Platform Token
 * @dev Contract that allows the Genbby platform to work properly and being scalable
 */
function buy(address who, uint256 amount) onlyTrustedContract whenNotPaused public {
    require (balances[who] >= amount);
    balances[who] = balances[who].sub(amount);
    totalSupply = totalSupply.sub(amount);
}

/**
 * @dev Function that trusted contracts can use to perform any buying that users do in the platform
 */