Lumiera  0.pre.03
»edit your freedom«
asset-diagnostics.hpp
Go to the documentation of this file.
1 /*
2  ASSET-DIAGNOSTICS.hpp - collection of test and debug helpers
3 
4  Copyright (C)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
23 #ifndef ASSET_ASSET_DIAGNOSTICS_H
24 #define ASSET_ASSET_DIAGNOSTICS_H
25 
26 
27 #include "steam/assetmanager.hpp"
28 #include "lib/format-string.hpp"
29 #include "lib/format-cout.hpp"
30 #include "lib/util-foreach.hpp"
31 #include "lib/util.hpp"
32 
33 #include <functional>
34 
35 using util::contains;
36 using util::for_each;
37 using util::_Fmt;
38 using std::placeholders::_1;
39 using std::bind;
40 using std::string;
41 using std::cout;
42 
43 
44 namespace steam {
45 namespace asset {
46 
47  inline void
48  dump (PcAsset const& aa)
49  {
50  if (!aa)
51  cout << "Asset(NULL)\n";
52  else
53  {
54  _Fmt fmt("%s %|50T.| id=%s adr=%p smart-ptr=%p use-count=%u");
55  cout << fmt % aa % aa->getID() % (void*)aa.get() % &aa % (aa.use_count() - 1) << "\n";
56  } }
57 
58 
59  inline void
60  dumpAssetManager ()
61  {
62  list<PcAsset> assets (AssetManager::instance().listContent());
63  cout << "----all-registered-Assets----\n";
64  for (auto const& pA : assets)
65  dump (pA);
66  }
67 
68 
69  template<class CHI, class PAR>
70  inline bool
71  dependencyCheck (lib::P<CHI> child, lib::P<PAR> parent)
72  {
73  return (child == parent)
74  || (0 < child->getParents().size()
75  && (parent == child->getParents()[0])
76  && (contains (parent->getDependant(), child)))
77  ;
78  }
79 
80 
81 
82 
83 }} // namespace steam::asset
84 #endif
Steam-Layer Interface: Asset Lookup and Organisation.
Automatically use custom string conversion in C++ stream output.
Front-end for printf-style string template interpolation.
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
static lib::Depend< AssetManager > instance
get at the system-wide asset manager instance.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
void for_each(CON const &elements, FUN function, P1 &&bind1, ARGS &&...args)
Accept binding for arbitrary function arguments.
Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relati...
Definition: trait.hpp:71
The asset subsystem of the Steam-Layer.
Definition: wrapperptr.hpp:35
Perform operations "for each element" of a collection.
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
Definition: util.hpp:255
std::string dump(std::tuple< TYPES... > const &tuple)
convenience function to dump a given tuple&#39;s contents.