IWORKStyle.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libetonyek project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef IWORKSTYLE_H_INCLUDED
00011 #define IWORKSTYLE_H_INCLUDED
00012 
00013 #include "IWORKStyle_fwd.h"
00014 
00015 #include <boost/any.hpp>
00016 #include <boost/optional.hpp>
00017 
00018 #include "IWORKPropertyMap.h"
00019 #include "IWORKStylesheet.h"
00020 
00021 namespace libetonyek
00022 {
00023 
00024 class IWORKStyleStack;
00025 
00028 class IWORKStyle
00029 {
00030 public:
00031   IWORKStyle(const IWORKPropertyMap &props, const boost::optional<std::string> &ident, const boost::optional<std::string> &parentIdent);
00032   IWORKStyle(const IWORKPropertyMap &props, const boost::optional<std::string> &ident, const IWORKStylePtr_t &parent);
00033 
00039   bool link(const IWORKStylesheetPtr_t &stylesheet);
00040 
00045   void flatten();
00046 
00049   const IWORKPropertyMap &getPropertyMap() const;
00050 
00055   template<class Property>
00056   bool has() const
00057   {
00058     return m_props.has<Property>(true);
00059   }
00060 
00065   template<class Property>
00066   const typename IWORKPropertyInfo<Property>::ValueType &get() const
00067   {
00068     return m_props.get<Property>(true);
00069   }
00070 
00071   const boost::optional<std::string> &getIdent() const;
00072 
00073 private:
00074   IWORKPropertyMap m_props;
00075 
00076   const boost::optional<std::string> m_ident;
00077   const boost::optional<std::string> m_parentIdent;
00078   IWORKStylePtr_t m_parent;
00079 };
00080 
00081 }
00082 
00083 #endif // IWORKSTYLE_H_INCLUDED
00084 
00085 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */