00001 #ifndef INCLUDE_ORA_SEQUENCES_H 00002 #define INCLUDE_ORA_SEQUENCES_H 00003 00004 // 00005 #include <map> 00006 #include <string> 00007 00008 namespace ora { 00009 00010 class IDatabaseSchema; 00011 00012 class Sequences { 00013 public: 00014 explicit Sequences( IDatabaseSchema& dbSchema ); 00015 virtual ~Sequences(); 00016 void create( const std::string& sequenceName ); 00017 int getNextId( const std::string& sequenceName, bool sinchronize = false ); 00018 void sinchronize( const std::string& sequenceName ); 00019 void sinchronizeAll(); 00020 void erase( const std::string& sequenceName ); 00021 void clear(); 00022 private: 00023 std::map<std::string, int> m_lastIds; 00024 IDatabaseSchema& m_schema; 00025 }; 00026 00027 class NamedSequence { 00028 public: 00029 NamedSequence( const std::string& sequenceName, IDatabaseSchema& dbSchema ); 00030 virtual ~NamedSequence(); 00031 void create(); 00032 int getNextId( bool sinchronize = false ); 00033 void sinchronize(); 00034 void erase(); 00035 void clear(); 00036 private: 00037 std::string m_name; 00038 Sequences m_sequences; 00039 }; 00040 00041 00042 } 00043 00044 #endif 00045 00046