From: stephan b. <sg...@us...> - 2004-12-30 20:59:37
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12446/include/pclasses/App Added Files: AppDetails.h Log Message: egg. Compiles but is untested. --- NEW FILE: AppDetails.h --- #ifndef App_APPINFO_HPP_INCLUDED #define App_APPINFO_HPP_INCLUDED 1 #include <string> #include <list> #include <pclasses/Unicode/String.h> namespace P { namespace App { using ::P::Unicode::String; /** AppDetails is a container for meta-information about an application, such as its license, author(s), and human-friendly name. Todos: - Add a handle to some App interface type. i.e., getApp() and setApp() (we need the setter so we can properly reconstruct the relationships during deserialization). - Possibly add getLicenses(), returning a list of string. IMO this can be covered by one big string in License. A list would just confuse the usage and make an eventual visual representation more awkward, i think. Maybe not. */ class AppDetails // throw() // i wish that would work { public: typedef std::list<String> DetailList; AppDetails() throw(); // need a default ctor for de-s11n explicit AppDetails( const String & name ) throw(); ~AppDetails() throw(); // note the non-virtualness. DetailList & getAuthors() throw(); const DetailList & getAuthors() const throw(); const String & getLicenseText() const throw(); void setLicenseText( const String & l ) throw(); const String & getName() const throw(); void setName( const String & n ) throw(); const String & getAboutText() const throw(); void setAboutText( const String & n ) throw(); private: struct AppDetailsHolder; // internal type to hold the app data mutable AppDetailsHolder * m_detail; // mutable needed for delayed instantiation AppDetailsHolder * details() const; // performs lazy instantiation of m_detail }; #define APPDETAIL_S11N_EXPERIMENTATION 0 #if 1 == APPDETAIL_S11N_EXPERIMENTATION struct AppDetails_s11n { // serialize template <typename NodeType> bool operator()( NodeType & dest, const AppDetails & src ) const { typedef ::P::s11n::node_traits<NodeType> TR; TR::class_name( dest, "P::App::AppDetails" ); TR::set( dest, "name", src.getName() ); TR::set( dest, "about", src.getAboutText() ); TR::set( dest, "license", src.getLicenseText() ); return ::P::s11n::serialize_subnode<NodeType,AppDetails>( dest, "authors", src.getAuthors() ); } // deserialize template <typename NodeType> bool operator()( const NodeType & src, AppDetails & dest ) const { typedef ::P::s11n::node_traits<NodeType> TR; dest.setName( TR::get( src, "name", dest.getName() ) ); dest.setAboutText( TR::get( src, "about", dest.getAboutText() ) ); dest.setLicenseText( TR::get( src, "license", dest.getLicenseText() ) ); return ::P::s11n::deserialize_subnode<NodeType,AppDetails>( src, "authors", src.getAuthors() ); } }; // AppDetails_s11n #endif // APPDETAIL_S11N_EXPERIMENTATION }} // namespace P::App #endif // App_APPINFO_HPP_INCLUDED |