You have to write a logic for that. Usefully total number of tokens are fixed. But if you want to change dynamically then you can. Its just method which returns the value. It's more like exchange will accept as a ico or not.
Find below code snippet
contract ABCComapny{
bool private isICOEnabled = false;
uint256 private TOTAL_NUMBER_TOKENS = 10000000000;
uint256 private SOLD_TOKENS = 10000000000;
function getTotalTokens() public returns(uint256){
if(isICOEnabled){
return TOTAL_NUMBER_TOKENS - SOLD_TOKENS;
}
returns TOTAL_NUMBER_TOKENS;
}
}
When before ICO. You need to check deposit() if isICOEnabled is false then update SOLD_TOKENS.
When your planing to start ico then update isICOEnabled true. But be careful. Run the test cases. Before deployed in mainnet.