libzypp  10.5.0
InstanceId.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_INSTANCEID_H
00013 #define ZYPP_INSTANCEID_H
00014 
00015 #include <string>
00016 
00017 #include "zypp/PoolItem.h"
00018 
00020 namespace zypp
00021 { 
00022 
00024   //
00025   //    CLASS NAME : InstanceId
00026   //
00046   class InstanceId
00047   {
00048     public:
00050       InstanceId()
00051       {}
00052 
00054       InstanceId( const std::string & namespace_r )
00055       : _namespace( namespace_r )
00056       {}
00057 
00058     public:
00060       std::string getIdFor( sat::Solvable slv_r ) const;
00062       std::string getIdFor( const PoolItem & pi_r ) const
00063       { return getIdFor( pi_r.satSolvable() ); }
00064 
00066       sat::Solvable findSolvable( const std::string str_r ) const
00067       { return findPoolItem( str_r ).satSolvable(); }
00069       PoolItem findPoolItem( const std::string str_r ) const;
00070 
00071     public:
00073       std::string operator()( sat::Solvable slv_r ) const
00074       { return getIdFor( slv_r ); }
00075 
00077       std::string operator()( const PoolItem & pi_r ) const
00078       { return getIdFor( pi_r ); }
00079 
00081       PoolItem operator()( const std::string str_r ) const
00082       { return findPoolItem( str_r ); }
00083 
00086       bool isSystemId( const std::string str_r ) const;
00087 
00088     public:
00090       const std::string & getNamespace() const
00091       { return _namespace; }
00092 
00094       void setNamespace( const std::string & namespace_r )
00095       { _namespace = namespace_r; }
00096 
00098       void unsetNamespace()
00099       { _namespace.clear(); }
00100 
00101    private:
00102       std::string _namespace;
00103   };
00105 
00107 } // namespace zypp
00109 #endif // ZYPP_INSTANCEID_H