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) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
32 #ifndef ASSET_ASSET_DIAGNOSTICS_H
33 #define ASSET_ASSET_DIAGNOSTICS_H
34 
35 
36 #include "steam/assetmanager.hpp"
37 #include "lib/format-string.hpp"
38 #include "lib/format-cout.hpp"
39 #include "lib/util-foreach.hpp"
40 #include "lib/util.hpp"
41 
42 #include <functional>
43 
44 using util::contains;
45 using util::for_each;
46 using util::_Fmt;
47 using std::placeholders::_1;
48 using std::bind;
49 using std::string;
50 using std::cout;
51 
52 
53 namespace steam {
54 namespace asset {
55 
56  inline void
57  dump (PcAsset const& aa)
58  {
59  if (!aa)
60  cout << "Asset(NULL)\n";
61  else
62  {
63  _Fmt fmt("%s %|50T.| id=%s adr=%p smart-ptr=%p use-count=%u");
64  cout << fmt % aa % aa->getID() % (void*)aa.get() % &aa % (aa.use_count() - 1) << "\n";
65  } }
66 
67 
68  inline void
69  dumpAssetManager ()
70  {
71  list<PcAsset> assets (AssetManager::instance().listContent());
72  cout << "----all-registered-Assets----\n";
73  for (auto const& pA : assets)
74  dump (pA);
75  }
76 
77 
78  template<class CHI, class PAR>
79  inline bool
80  dependencyCheck (lib::P<CHI> child, lib::P<PAR> parent)
81  {
82  return (child == parent)
83  || (0 < child->getParents().size()
84  && (parent == child->getParents()[0])
85  && (contains (parent->getDependant(), child)))
86  ;
87  }
88 
89 
90 
91 
92 }} // namespace steam::asset
93 #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:80
The asset subsystem of the Steam-Layer.
Definition: wrapperptr.hpp:44
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.