// // DemoAndLicensing.h // // Created by Andrew Salamon on 12/6/07. // Copyright 2007 Machine Perception Laboratory, University of California San Diego. All rights reserved. // #ifndef __DEMOANDLICENSING_H__ #define __DEMOANDLICENSING_H__ #include #include #include #include namespace bg = boost::gregorian; namespace CERT { class DemoAndLicensing { public: static DemoAndLicensing *sharedDemo(); DemoAndLicensing(); virtual ~DemoAndLicensing(); bool isDemo(); ///< Returns yes if we have a startDate or can read one from a file. bool hasDemoEnded(); bool startDemo(); ///< Write the current date to a file to start counting the demo period. Returns false if we can't write the file. virtual void notifyUserDemoEnded(); virtual void notifyUserDemoNotAllowed(); virtual void notifyUserDemoLeft(); std::string getFilename(); void setFilename( const std::string &value ); std::vector getAllowedPaths(); void setAllowedPaths( const std::vector &value ); unsigned int getDemoLength(); ///< In days. void setDemoLength( unsigned int days ); bg::date demoEndDate(); bg::date demoStartDate(); bool getStarted() { return started; } std::string getPathUsed() { return pathUsed; } protected: void setStartFromTime( time_t startTime ); bool validateStartDate( time_t startTime ); virtual bool readDemoStartDate(); virtual bool writeDemoStartDate(); virtual bool writeDemoStartDate( time_t startTime ); int obfuscate(int num); int deobfuscate(int num); private: std::string filename; std::vector allowedPaths; bg::days demoLength; bool started; bg::date startDate; std::string pathUsed; // Which path was last used to read and/or write from/to. }; } // end namespace CERT #endif // __DEMOANDLICENSING_H__