Lolly 1.4.28
Loading...
Searching...
No Matches
Classes | Macros | Functions
resource.hpp File Reference
#include "hashmap.hpp"
#include "string.hpp"
Include dependency graph for resource.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rep< T >
 base class of resources More...
 
class  resource_ptr< R >
 

Macros

#define RESOURCE(PTR)
 
#define make(T, s, im)   ((T::instances->contains (s)) ? T (s) : T (im))
 

Functions

template<class R >
bool is_nil (const resource_ptr< R > &res)
 
template<class R >
tm_ostreamoperator<< (tm_ostream &out, const resource_ptr< R > &t)
 
template<class T >
tm_ostreamoperator<< (tm_ostream &out, const resource_ptr< T > &t)
 

Detailed Description

Utils to define a class that holding its instances globally. Instances is called "Resources", and can be looked up by a string. Weak referrence is provided to access member of resources.

Author
Joris van der Hoeven
Date
1999
Author
jingkaimori
Date
2024

Definition in file resource.hpp.

Macro Definition Documentation

◆ RESOURCE

#define RESOURCE ( PTR)
Value:
struct PTR##_rep; \
struct PTR : public resource_ptr<PTR##_rep> { \
inline PTR (PTR##_rep* rep2= NULL) { rep= rep2; } \
inline PTR (string s) { rep= (PTR##_rep*) instances[s]; } \
inline ~PTR () {} \
}
The list class represents a linked list.
Definition list.hpp:48
list(T item)
Construct a new list object with a single item.
Definition list.hpp:137
base class of resources
Definition resource.hpp:23

Definition at line 45 of file resource.hpp.

45#define RESOURCE(PTR) \
46 struct PTR##_rep; \
47 struct PTR : public resource_ptr<PTR##_rep> { \
48 inline PTR (PTR##_rep* rep2= NULL) { rep= rep2; } \
49 inline PTR (string s) { rep= (PTR##_rep*) instances[s]; } \
50 inline ~PTR () {} \
51 }

◆ make

#define make ( T,
s,
im )   ((T::instances->contains (s)) ? T (s) : T (im))

Definition at line 62 of file resource.hpp.

Function Documentation

◆ is_nil()

template<class R >
bool is_nil ( const resource_ptr< R > & res)
inline

Definition at line 55 of file resource.hpp.

55 {
56 return res.rep == NULL;
57}

◆ operator<<() [1/2]

template<class R >
tm_ostream & operator<< ( tm_ostream & out,
const resource_ptr< R > & t )

◆ operator<<() [2/2]

template<class T >
tm_ostream & operator<< ( tm_ostream & out,
const resource_ptr< T > & t )

Definition at line 65 of file resource.hpp.

66 {
67 return out << t->res_name;
68}
blackbox t[13]