This file is indexed.

/usr/include/simgear/props/PropertyBasedElement.hxx is in libsimgear-dev 1:2018.1.1+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Base class for elements of property controlled subsystems
//
// Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA

#ifndef SG_PROPERTY_BASED_ELEMENT_HXX_
#define SG_PROPERTY_BASED_ELEMENT_HXX_

#include <simgear/props/props.hxx>
#include <simgear/std/type_traits.hxx>
#include <simgear/structure/SGWeakReferenced.hxx>

namespace simgear
{

  /**
   * Base class for a property controlled element
   */
  class PropertyBasedElement:
    public SGPropertyChangeListener,
    public virtual SGVirtualWeakReferenced
  {
    public:
      PropertyBasedElement(SGPropertyNode* node);
      virtual ~PropertyBasedElement();

      /**
       * Remove the property listener of the element.
       *
       * You will need to call the appropriate methods (childAdded(),
       * childRemoved(), valueChanged()) yourself to ensure the element still
       * receives the needed events.
       */
      void removeListener();

      /**
       * Destroys this element (removes node from property tree)
       */
      void destroy();

      virtual void update(double delta_time_sec) = 0;

      SGConstPropertyNode_ptr getProps() const;
      SGPropertyNode_ptr getProps();

      template<class T>
      void set( const std::string& name,
                const T& val )
      {
        setValue(_node->getNode(name, true), val);
      }

      template<class T>
      T get( const std::string& name,
             const T& def = T() )
      {
        SGPropertyNode const* child = _node->getNode(name);
        if( !child )
          return def;

        return getValue<T>(child);
      }

      // Unshadow what we have just hidden...
      using SGWeakReferenced::get;


      /** @brief Set a HTML5 like data property on this element.
       *
       * Set data-* properties on this element. A camel-case @a name will be
       * converted to a hyphenated name with 'data-' prefixed. Setting a value
       * with this method does not trigger an update of the canvas and is meant
       * to store data related to this element (used eg. inside scripts).
       *
       * @code{cpp}
       * // Set value
       * my_element->setDataProp("mySpecialInt", 3);
       *
       * // Get value (with default value)
       * int val = my_element->getDataProp<int>("mySpecialInt");   // val == 3
       *     val = my_element->getDataProp<int>("notExisting", 5); // val == 5
       *
       * // Check if value exists
       * SGPropertyNode* node =
       *   my_element->getDataProp<SGPropertyNode*>("mySpecialInt");
       * if( node )
       *   val = node->getIntValue(); // node != NULL, val == 3
       *
       * node = my_element->getDataProp<SGPropertyNode*>("notExisting");
       * // node == NULL
       * @endcode
       */
      template<class T>
      void setDataProp( const std::string& name,
                        const T& val )
      {
        const std::string& attr = dataPropToAttrName(name);
        if( !attr.empty() )
          set<T>(attr, val);
        else
          SG_LOG(SG_GENERAL, SG_WARN, "Invalid data-prop name: " << name);
      }

      /** @brief Get a HTML5 like data property on this element.
       *
       * Get value or default value.
       *
       * @see setDataProp
       */
      template<class T>
      std::enable_if_t<!std::is_same<T, SGPropertyNode*>::value, T>
      getDataProp( const std::string& name,
                   const T& def = {} ) const
      {
        SGPropertyNode* node = getDataProp<SGPropertyNode*>(name);
        if( node )
          return getValue<T>(node);

        return def;
      }

      /** @brief Get a HTML5 like data property on this element.
       *
       * Use this variant to check if a property exists.
       *
       * @see setDataProp
       */
      template<class T>
      std::enable_if_t<std::is_same<T, SGPropertyNode*>::value, T>
      getDataProp( const std::string& name,
                   SGPropertyNode* = nullptr ) const
      {
        const std::string& attr = dataPropToAttrName(name);
        if( attr.empty() )
        {
          SG_LOG(SG_GENERAL, SG_WARN, "Invalid data-prop name: " << name);
          return NULL;
        }

        return _node->getNode(attr);
      }

      /** @brief Check whether a HTML5 like data property exists on this
       *         element.
       *
       */
      bool hasDataProp(const std::string& name) const;

      /** @brief Remove a HTML5 like data property (if it exists).
       *
       */
      void removeDataProp(const std::string& name);

      virtual void onDestroy() {};

      static std::string dataPropToAttrName(const std::string& name);
      static std::string attrToDataPropName(const std::string& name);

    protected:

      SGPropertyNode_ptr _node;

  };

  typedef SGSharedPtr<PropertyBasedElement> PropertyBasedElementPtr;
  typedef SGWeakPtr<PropertyBasedElement> PropertyBasedElementWeakPtr;

} // namespace simgear

#endif /* SG_PROPERTY_BASED_ELEMENT_HXX_ */