// Filename: configFlags.I
// Created by:  drose (21Oct04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license.  You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////
//     Function: ConfigFlags::is_cache_valid
//       Access: Protected, Static
//  Description: Returns true if the local object's cache is still
//               valid (based on a comparison of the supplied
//               local_modified value with the global_modified value).
////////////////////////////////////////////////////////////////////
INLINE bool ConfigFlags::
is_cache_valid(PN_int32 local_modified) {
  return local_modified == _global_modified;
}

////////////////////////////////////////////////////////////////////
//     Function: ConfigFlags::mark_cache_valid
//       Access: Protected, Static
//  Description: Updates the indicated local_modified value so that
//               the cache will appear to be valid, until someone next
//               calls invalidate_cache().
////////////////////////////////////////////////////////////////////
INLINE void ConfigFlags::
mark_cache_valid(PN_int32 &local_modified) {
  local_modified = _global_modified;
}

////////////////////////////////////////////////////////////////////
//     Function: ConfigFlags::initial_invalid_cache
//       Access: Protected, Static
//  Description: Returns a value that will be appropriate for
//               initializing a local_modified value.  This value will
//               indicate an invalid cache in the next call to
//               is_cache_valid().
////////////////////////////////////////////////////////////////////
INLINE PN_int32 ConfigFlags::
initial_invalid_cache() {
  return _global_modified - 1;
}

////////////////////////////////////////////////////////////////////
//     Function: ConfigFlags::invalidate_cache
//       Access: Protected, Static
//  Description: Invalidates all of the global ConfigVariable caches
//               in the world at once, by incrementing the
//               global_modified counter.
////////////////////////////////////////////////////////////////////
INLINE void ConfigFlags::
invalidate_cache() {
  AtomicAdjust::inc(_global_modified);
}
