Code Search for Developers
 
 
  

STypeGraph.h from osgDesigner at Krugle


Show STypeGraph.h syntax highlighted

#ifndef __STYPEGRAPH_H__
#define __STYPEGRAPH_H__ 1



#include <algorithm>

//#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/property_map.hpp>

#include <boost/signals/trackable.hpp>
#include <osgIntrospectionToolKit/signalslib.hpp>

#include <osgIntrospection/Type>
#include <osgIntrospectionToolKit/IGraph.h>

#include <osgIntrospectionToolKit/Export.h>
#include <osgIntrospectionToolKit/CommonStdType.h>

namespace osgIntrospectionToolKit
{
    

    struct type_name_t 
    { typedef boost::vertex_property_tag kind; };
    
    typedef IGraph< boost::listS, boost::listS, boost::bidirectionalS,
                    boost::property<type_name_t, std::string >,
                    boost::no_property,
                    boost::no_property,
                    boost::listS >                                              TypeNameTreeBase;
                                 
    class TypeNameTree: public TypeNameTreeBase
    {
        public:
        
            typedef TypeNameTreeBase                                            Base;

            // ** boost::adjacency_list used typedef ** /
            typedef Base::graph_base                                            graph_base;
            typedef Base::adjacency_iterator                                    adjacency_iterator;
            typedef Base::inv_adjacency_iterator                                inv_adjacency_iterator;
            typedef Base::out_edge_iterator                                     out_edge_iterator;
            typedef Base::in_edge_iterator                                      in_edge_iterator;
            typedef Base::vertex_iterator                                       vertex_iterator;
            typedef Base::vertex_descriptor                                     vertex_descriptor;
            typedef Base::edge_iterator                                         edge_iterator;
            typedef Base::edge_descriptor                                       edge_descriptor;
            
            typedef Base::adjacency_range                                       adjacency_range;
            typedef Base::inv_adjacency_range                                   inv_adjacency_range;
            typedef Base::out_edge_range                                        out_edge_range;
            typedef Base::in_edge_range                                         in_edge_range;
            typedef Base::vertex_range                                          vertex_range;
            typedef Base::edge_range                                            edge_range;
            
            
            

            TypeNameTree() {}
        
        
            virtual ~TypeNameTree() {}
        
        public:
            std::string                                                     typeName(vertex_descriptor vd) const
            { return (boost::get(type_name_t(), tree(), vd)); }
            void                                                            typeName(vertex_descriptor vd, std::string& typeName)
            { boost::put(type_name_t(), tree(), vd, typeName); }
            void                                                            typeName(vertex_descriptor vd, std::string typeName)
            { boost::put(type_name_t(), tree(), vd, typeName); }
    };
    
    
   
    struct type_t 
    { typedef boost::vertex_property_tag kind; };
    
    
    typedef IGraph< boost::listS, boost::listS, boost::bidirectionalS,
                    boost::property<type_t, const osgIntrospection::Type* >,
                    boost::no_property,
                    boost::no_property,
                    boost::listS >                                              STypeGraphBase;


   /**
     * The STypeGraph is a graph representation of the derivation between class.
     * Each vertex of the graph contain a osgIntrospection::Type 
     */
    
    class OSGINTROSPECTIONTOOLKIT_EXPORT STypeGraph: public STypeGraphBase, public boost::signalslib::trackable
    {
        public:
        
            typedef STypeGraphBase                                              Base;

            // ** boost::adjacency_list used typedef ** /
            typedef Base::graph_base                                            graph_base;
            typedef Base::adjacency_iterator                                    adjacency_iterator;
            typedef Base::inv_adjacency_iterator                                inv_adjacency_iterator;
            typedef Base::out_edge_iterator                                     out_edge_iterator;
            typedef Base::in_edge_iterator                                      in_edge_iterator;
            typedef Base::vertex_iterator                                       vertex_iterator;
            typedef Base::vertex_descriptor                                     vertex_descriptor;
            typedef Base::edge_iterator                                         edge_iterator;
            typedef Base::edge_descriptor                                       edge_descriptor;
            
            typedef Base::adjacency_range                                       adjacency_range;
            typedef Base::inv_adjacency_range                                   inv_adjacency_range;
            typedef Base::out_edge_range                                        out_edge_range;
            typedef Base::in_edge_range                                         in_edge_range;
            typedef Base::vertex_range                                          vertex_range;
            typedef Base::edge_range                                            edge_range;
        
            typedef std::vector<vertex_descriptor>                              Path;
            typedef std::vector<vertex_descriptor>                              RootList;
            typedef std::vector<std::string>                                    StringList;
            
            typedef boost::signal<void (void)>                                  ResetSignal;


        private:
            STypeGraph();
        
        protected:
            virtual ~STypeGraph();


        public:
            
            static STypeGraph*                                              instance();
            void                                                            reload();
            void                                                            clearTree()
            { _beginResetSignal(); clear(); _endResetSignal(); }
            
            const osgIntrospection::Type*                                   type(vertex_descriptor vd) const
            { return (boost::get(type_t(), tree(), vd)); }
            void                                                            type(vertex_descriptor vd, const osgIntrospection::Type* type)
            { boost::put(type_t(), tree(), vd, type); }
            
            
                        
            vertex_iterator                                                 find(const osgIntrospection::Type* type) const;
            vertex_descriptor                                               find(std::string typeName) const;
            
            
//            std::string                                                   getTypeName(vertex_descriptor vd) const;
//            std::string                                                   getTypeQualifiedName(vertex_descriptor vd) const;
//
//            const osgIntrospection::Type*                                 getIntrospectionType(vertex_descriptor vd) const;
            
            void                                                            getBaseTypeList(vertex_descriptor vd, osgIntrospection::TypeList& tl) const;
            void                                                            getDerivedTypeList(vertex_descriptor vd, osgIntrospection::TypeList& tl) const;


            static const osgIntrospection::Type*                            getType(std::string typeStr);
            static const osgIntrospection::PropertyInfo*                    getPropertyInType(std::string typeStr, std::string propertyStr);
            static std::size_t                                              extractTypeNameList(const osgIntrospection::TypeList& tl, NameList& nl);
            static bool                                                     createInstance(std::string typeName, osgIntrospection::Value& newValue);
            static bool                                                     isSameOrDerivedClass(const osgIntrospection::Type& t1, const osgIntrospection::Type& t2);
            
            
            void                                                            getDerivedTypeNameTree(std::string typeName, TypeNameTree& tnt) const;
            void                                                            getDerivedTypeNameTree(const osgIntrospection::Type& type, TypeNameTree& tnt) const;
            
            ResetSignal&                                                    beginResetSignal()
            { return (_beginResetSignal); }
            ResetSignal&                                                    endResetSignal()
            { return (_endResetSignal); }
            
        private:             
            void                                                            _clearTree()
            { clear(); type(root(), NULL); }
            
            void                                                            _getDerivedTypeNameTree(vertex_descriptor vd, TypeNameTree& tnt) const;
            void                                                            _getDerivedTypeNameTree_recursive(vertex_descriptor vd, TypeNameTree& tnt, TypeNameTree::vertex_descriptor tntvd) const;
    
            void                                                            initVertex(vertex_iterator vi);
            void                                                            sortPropertyInfo(vertex_iterator vi);
            void                                                            makeParentChildrenRelation(vertex_iterator vi);
            
            ResetSignal                                                     _beginResetSignal;
            ResetSignal                                                     _endResetSignal;
    };
}
#endif // ** __STYPEGRAPH_H__ ** //




See more files for this project here

osgDesigner

osgDesigner is a graphical tool used to modify an OpenSceneGraph (OSG) scene using the osgIntrospection framework. OpenSceneGraph developpers will be able to extend osgDesigner at need using (editor | render | osgIntrospection wrapper) plugin system.

Project homepage: http://sourceforge.net/projects/osgdesigner
Programming language(s): C++,Shell Script
License: other

  CArrayItemLink.h
  CIndexedItemLink.h
  CPropertyExtractor.h
  CReflectedInstance.h
  CReflectedPointer.h
  CReflectedRefPointer.h
  CReflectedValueLinkExtractor.h
  CValueTree.h
  CValueTreeFunctor.h
  CValueTreeModifier.h
  CommonStdType.h
  ControlList.h
  ExceptionUtility.h
  Export.h
  IGraph.h
  IReflectedValue.h
  IReflectedValueLink.h
  SMemoryManager.h
  STypeGraph.h
  SWrapperManager.h
  signalslib.hpp