SIMLIB/C++  3.07
name.cc
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////
2 //! \file name.cc object-name relation
3 //
4 // Copyright (c) 1991-2004 Petr Peringer
5 //
6 // This library is licensed under GNU Library GPL. See the file COPYING.
7 //
8 
9 //
10 // All SimObject instance can have name associated.
11 // Exported functions:
12 //
13 // void SetName(SimObject *o, char *name) -- name of object o
14 // void SetName(SimObject &o, char *name)
15 // void RemoveName(SimObject *o) -- remove name of o
16 // void RemoveName(SimObject &o)
17 // const char *GetName(SimObject *o) -- get name of o
18 // const char *GetName(SimObject &o)
19 //
20 
21 
22 ////////////////////////////////////////////////////////////////////////////
23 // interface
24 //
25 
26 #include "simlib.h"
27 #include "internal.h"
28 
29 ////////////////////////////////////////////////////////////////////////////
30 // implementation
31 //
32 
33 #include <cstdarg> // ...
34 #include <cstdio> // vsprintf()
35 
36 namespace simlib3 {
37 
39 
40 /////////////////////////////////////////////////////////////////////////////
41 /// assign name to object
42 void SetName(SimObject & o, const std::string &name)
43 {
44  o.SetName(name);
45 }
46 
47 /// assign name to object
48 void SetName(SimObject * o, const std::string &name)
49 {
50  o->SetName(name);
51 }
52 
53 /// remove name
55 {
56  o.SetName(0);
57 }
58 
59 /// remove name
61 {
62  o->SetName(0);
63 }
64 
65 /// get name of object
66 std::string GetName(SimObject & o)
67 {
68  return o.Name();
69 }
70 
71 /// get name of object
72 std::string GetName(SimObject * o)
73 {
74  return o->Name();
75 }
76 
77 /// printf-like function to create temporary name
78 /// (the length of temporary names is limited)
79 /// <br> used only for printing
80 std::string SIMLIB_create_tmp_name(const char *fmt, ...)
81 {
82  static char s[256];
83  va_list va;
84  va_start(va, fmt);
85  vsnprintf(s, sizeof(s), fmt, va);
86  va_end(va);
87  return s;
88 }
89 
90 } // namespace
91 
void SetName(SimObject &o, const std::string &name)
assign name to object
Definition: name.cc:42
void SetName(const std::string &name)
assign the name
Definition: object.cc:125
Implementation of class CalendarList interface is static - using global functions in SQS namespace...
Definition: algloop.cc:32
std::string SIMLIB_create_tmp_name(const char *fmt,...)
printf-like function to create temporary name (the length of temporary names is limited) used only ...
Definition: name.cc:80
Base class for almost all SIMLIB classes.
Definition: simlib.h:299
void RemoveName(SimObject &o)
remove name
Definition: name.cc:54
std::string GetName(SimObject &o)
get name of object
Definition: name.cc:66
Internal header file for SIMLIB/C++.
Main SIMLIB/C++ interface.
virtual std::string Name() const
get object name
Definition: object.cc:134
SIMLIB_IMPLEMENTATION
Definition: algloop.cc:34