Spinning Topp Logo BlackTopp Studios
inc
scriptargument.h
Go to the documentation of this file.
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _scriptargument_h
41 #define _scriptargument_h
42 
43 /// @file
44 /// @brief This file has the interfaces for Script Arguments and the associated dependency chain
45 
46 #include "datatypes.h"
47 #include "countedptr.h"
48 
49 namespace Mezzanine
50 {
51  namespace Scripting
52  {
53  ///////////////////////////////////////////////////////////////////////////////
54  /// @brief The interface for a script argument
55  /// @details These are all the members that all script for all languages must
56  /// implement. This mandatory functionlity insures that once portion of C++ code
57  /// has access to a script argument it can always access the data contained.
58  /// @n @n
59  /// These are created to provide data to scripts. This is intended to primarily
60  /// to act as an abstraction layer between game data and data inside scripts,
61  /// but currently just transports primitives into and out of scripts without
62  /// needing to care about any underlying types. This limits what operations
63  /// can be done with, because it is intended to provide an abstraction that
64  /// can be used to implement specific algorithms for languages that require
65  /// them.
66  /// @n @n
67  /// For example Lua requires calling different functions for passing Strings
68  /// Numbers, Nils and other types, while Ruby does not require this. These
69  /// classes will always present Data to C++ class the same way, but will take
70  /// whatever steps required for the scripting language and optionally the
71  /// types they represent.
72  ///////////////////////////////////////
74  {
75  public:
76  /// @brief Overidable Deconstructor
77  virtual ~iScriptArgument()
78  {}
79 
80  /// @brief Get the Argument as a String
81  /// @return The argument value lexographically converted as a @ref String
82  virtual String GetString() const = 0;
83 
84  /// @brief Get the Argument as a Whole
85  /// @return The argument value lexographically converted as a @ref Whole
86  virtual Whole GetWhole() const = 0;
87 
88  /// @brief Get the Argument as a Integer
89  /// @return The argument value lexographically converted as an @ref Integer
90  virtual Integer GetInteger() const = 0;
91 
92  /// @brief Get the Argument as a Real
93  /// @return The argument value lexographically converted as an @ref Real
94  virtual Real GetReal() const = 0;
95 
96  /// @brief Get the Argument as a Boole
97  /// @return The argument value lexographically converted as an @ref Boole
98  virtual Boole GetBoole() const = 0;
99 
100  /// @brief Is this value representing a Null/Nil value.
101  /// @return True if ths argument is null, false if it is anything other Type. This may of may not for language specific semantics.
102  virtual Boole IsNull() const = 0;
103 
104  /// @brief Get data about the underlying specific to the scripting system using the argument.
105  /// @return An Integer containing scripting langauge specific data.
106  virtual Integer GetTypeData() const = 0;
107 
108  /// @brief Get a pointer to the most Derived type of this class
109  /// @return A pointer of the most derived pointing to this.
111  { return this; }
112  }; // iScriptArgument
113 
114  /// @brief A listing of the Base types an iScriptArgument could represent.
116  {
117  GenericUnknown = 0, ///< This is not readily available when instantiating ScriptArgumentGeneric<T> where T is unknown
118  GenericInteger = 1, ///< Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an Integer
119  GenericWhole = 2, ///< Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an Whole
120  GenericString = 3, ///< Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an String
121  GenericReal = 4, ///< Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an Real
122  GenericBool = 5, ///< Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an Bool
123  GenericNull = 6, ///< Returned from GetTypeData() const when a ScriptArgumentGeneric is intended as NullPtr, SQL Null, Lua Nil, Ruby nil, etc...
124  GenericMax = 6 ///< This is always equal to the maximum value in this enumeration so that other constant values can be based on this. For example Lua uses this +1 for its NilValue
125  };
126 
127  /// @brief A generic implementation of a ScriptArgument that is suitable for primitive types in most situations.
128  /// @details Scripting languages the do not benefit from having different implementations per type should
129  /// implement their argument subclass derived from this. This will attempt to provide basic type conversion
130  /// for Datum to C++ types lexigraphically. Any that is innapropriate or suboptimal should be overidden
131  template <class T>
133  {
134  protected:
135  /// @brief The actual data.
136  /// @warning To prevent slicing don't store the parent class in a container.
137  /// Dpractically guarantees that derived class will have different sizes
138  /// and overflow container boundaries. If you must store shared pointers in
139  /// constainers
140  T Datum;
141 
142  public:
143  /// @brief To make working with this easier.
144  typedef T Type;
145 
146  /// @brief Create an initialized Argument
147  /// @param InitialValue The value to initialize the Argument with.
148  /// @note Intentionally not explicit, this allow for passing convertable types directly to functions.
149  ScriptArgumentGeneric(T InitialValue) :
150  Datum(InitialValue)
151  {}
152 
153  /// @brief Overloadable Deconstructor
155  {}
156 
157  /// @brief Get the Argument as a String, slow default implementation.
158  /// @return The argument value lexographically converted as a @ref String
159  virtual String GetString() const
160  { return ToString(Datum); }
161 
162  /// @brief Get the Argument as a Whole, slow default implementation.
163  /// @return The argument value lexographically converted as a @ref Whole
164  virtual Whole GetWhole() const
165  { return ToWhole(Datum); }
166 
167  /// @brief Get the Argument as a Integer, slow default implementation.
168  /// @return The argument value lexographically converted as an @ref Integer
169  virtual Integer GetInteger() const
170  { return ToInteger(Datum); }
171 
172  /// @brief Get the Argument as a Real, slow default implementation.
173  /// @return The argument value lexographically converted as an @ref Real
174  virtual Real GetReal() const
175  { return ToReal(Datum); }
176 
177  /// @brief Get the Argument as a Boole
178  /// @return The argument value lexographically converted as an @ref Boole
179  virtual Boole GetBoole() const
180  { return ToBool(Datum); }
181 
182  /// @brief Is this value representing a Null/Nil value.
183  /// @return This will return true if the string representation of this is empty and the Integer representation equals 0, this could and should be overridden on derived scripting arguments
184  virtual Boole IsNull() const
185  { return GetString()=="" && GetInteger()==0; }
186 
187  /// @brief Provide an overload point to change assignment that operators will use.
188  /// @param NewValue The new value for this.
189  virtual void SetValue(T NewValue)
190  { Datum=NewValue; }
191 
192  /// @brief Get the raw primitive to value.
193  /// @return The internal value that meaningful operation can be performed on.
194  virtual T GetValue() const
195  { return Datum; }
196 
197  /// @brief Get data about this having an unknown type
198  /// @return This will return an Integer containing GenericUnknown. If needed proper specialization of this can be made for any class, see the ScriptArgumentGeneric<Mezzanine::Scripting::Lua::Lua51Nil>
199  virtual Integer GetTypeData() const
200  { return GenericUnknown; }
201 
202  /// @brief Get a pointer to the most Derived type of this class
203  /// @return A pointer of the most derived pointing to this.
205  { return this; }
206  }; //ScriptArgumentGeneric<T>
207 
208  /// @brief A Integer implementation of a ScriptArgument that is suitable for primitive types in most situations
209  /// @details Scripting Languages that require algorithms specific to Integers should add required functionality
210  /// to a type derived from this.
211  template <>
213  {
214  protected:
215  /// @brief The Integer actual data.
217 
218  public:
219  /// @brief To make working with this easier.
220  typedef Integer Type;
221 
222  /// @brief Create an initialized Argument
223  /// @param InitialValue The value to initialize the Argument Integer value with.
224  /// @note Intentionally not explicit, this allow for passing convertable types directly to functions.
226  Datum(InitialValue)
227  {}
228 
229  /// @brief Overloadable Deconstructor
231  {}
232 
233  /// @brief Get the Integer as a String.
234  /// @return The Integer value lexographically converted as a @ref String
235  virtual String GetString() const
236  { return ToString(Datum); }
237 
238  /// @brief Get the Integer as a Whole.
239  /// @return The Integer value lexographically converted as a @ref Whole
240  virtual Whole GetWhole() const
241  { return Whole(Datum); }
242 
243  /// @brief Get the Integer as a Integer.
244  /// @return The Integer value lexographically converted as an @ref Integer
245  virtual Integer GetInteger() const
246  { return Datum; }
247 
248  /// @brief Get the Integer as a Real.
249  /// @return The Integer value lexographically converted as an @ref Real
250  virtual Real GetReal() const
251  { return Real(Datum); }
252 
253  /// @brief Get the Integer as a Boole
254  /// @return The argument value lexographically converted as an @ref Boole
255  virtual Boole GetBoole() const
256  { return Boole(Datum); }
257 
258  /// @brief Is this value representing a Null/Nil value.
259  /// @return In most languages 0 is a valid value for Integers, so any value in this is assumed to not be NULL. This should be overridden if different behavior is required.
260  virtual Boole IsNull() const
261  { return false; }
262 
263  /// @brief Provide an overload point to change assignment that operators will use.
264  /// @param NewValue The new value for this.
265  virtual void SetValue(Integer NewValue)
266  { Datum=NewValue; }
267 
268  /// @brief Get the raw primitive to value.
269  /// @return The internal value that meaningful operations can be performed on.
270  virtual Integer GetValue() const
271  { return Datum; }
272 
273  /// @brief Get data about this being and Integer
274  /// @return This will return an Integer containing GenericInteger.
275  virtual Integer GetTypeData() const
276  { return GenericInteger; }
277 
278  /// @brief Get a pointer to the most Derived type of this class
279  /// @return A pointer of the most derived pointing to this.
281  { return this; }
282  }; //ScriptArgumentGeneric<Integer>
283 
284  /// @brief A Whole number implementation of a ScriptArgument that is suitable for primitive types in most situations
285  /// @details Scripting Languages that require algorithms specific to Whole number should add required functionality
286  /// to a type derived from this.
287  template <>
289  {
290  protected:
291  /// @brief The Whole actual data.
293 
294  public:
295  /// @brief To make working with this easier.
296  typedef Whole Type;
297 
298  /// @brief Create an initialized Argument
299  /// @param InitialValue The value to initialize the Argument Whole value with.
300  /// @note Intentionally not explicit, this allow for passing convertable types directly to functions.
301  ScriptArgumentGeneric(Whole InitialValue) :
302  Datum(InitialValue)
303  {}
304 
305  /// @brief Overloadable Deconstructor
307  {}
308 
309  /// @brief Get the Whole as a String
310  /// @return The Whole value lexographically converted as a @ref String
311  virtual String GetString() const
312  { return ToString(Datum); }
313 
314  /// @brief Get the Whole number.
315  /// @return The Whole value lexographically converted as a @ref Whole
316  virtual Whole GetWhole() const
317  { return Datum; }
318 
319  /// @brief Get the Whole as a Integer.
320  /// @return The Whole value lexographically converted as an @ref Integer
321  virtual Integer GetInteger() const
322  { return Integer(Datum); }
323 
324  /// @brief Get the Whole as a Real.
325  /// @return The Whole value lexographically converted as an @ref Real
326  virtual Real GetReal() const
327  { return Real(Datum); }
328 
329  /// @brief Get the Whole Number as a Boole
330  /// @return The argument value lexographically converted as an @ref Boole
331  virtual Boole GetBoole() const
332  { return Boole(Datum); }
333 
334  /// @brief Is this value representing a Null/Nil value.
335  /// @return In most languages 0 is a valid value for Whole Numbers, so any value in this is assumedto not be NULL. This should be overridden if different behavior is required.
336  virtual Boole IsNull() const
337  { return false; }
338 
339  /// @brief Provide an overload point to change assignment that operators will use.
340  /// @param NewValue The new value for this.
341  virtual void SetValue(Whole NewValue)
342  { Datum=NewValue; }
343 
344  /// @brief Get the raw primitive to value.
345  /// @return The internal value that meaningful operation can be performed on.
346  virtual Whole GetValue() const
347  { return Datum; }
348 
349  /// @brief Get data about this being a Whol
350  /// @return This will return an Integer containing GenericWhole.
351  virtual Integer GetTypeData() const
352  { return GenericWhole; }
353 
354  /// @brief Get a pointer to the most Derived type of this class
355  /// @return A pointer of the most derived pointing to this.
357  { return this; }
358  }; //ScriptArgumentGeneric<Whole>
359 
360  /// @brief A String implementation of a ScriptArgument that is suitable for primitive types in most situations
361  /// @details Scripting Languages that require algorithms specific to strings should add required functionality
362  /// to a type derived from this.
363  template <>
365  {
366  protected:
367  /// @brief The String data.
369 
370  public:
371  /// @brief To make working with this easier.
372  typedef String Type;
373 
374  /// @brief Create an initialized Argument
375  /// @param InitialValue The value to initialize the Argument String value with.
376  /// @note Intentionally not explicit, this allow for passing convertable types directly to functions.
378  Datum(InitialValue)
379  {}
380 
381  /// @brief Overloadable Deconstructor
383  {}
384 
385  /// @brief Get the String
386  /// @return The String
387  virtual String GetString() const
388  { return Datum; }
389 
390  /// @brief Get the String as a Whole.
391  /// @return The String value lexographically converted as a @ref Whole
392  virtual Whole GetWhole() const
393  { return ConvertTo<Whole>(Datum); }
394 
395  /// @brief Get the String as a Integer.
396  /// @return The String value lexographically converted as an @ref Integer
397  virtual Integer GetInteger() const
398  { return ConvertTo<Integer>(Datum); }
399 
400  /// @brief Get the String as a Real.
401  /// @return The String value lexographically converted as an @ref Real
402  virtual Real GetReal() const
403  { return ConvertTo<Real>(Datum); }
404 
405  /// @brief Get the String as a Boole
406  /// @return The argument value lexographically converted as an @ref Boole
407  virtual Boole GetBoole() const
408  { return ToBool(Datum); }
409 
410  /// @brief Is this value representing a Null/Nil value.
411  /// @return In most languages "" is a valid value for Strings, so any value in this is assumed to not be NULL. This should be overridden if different behavior is required.
412  virtual Boole IsNull() const
413  { return false; }
414 
415  /// @brief Provide an overload point to change assignment that operators will use.
416  /// @param NewValue The new value for this.
417  virtual void SetValue(String NewValue)
418  { Datum=NewValue; }
419 
420  /// @brief Get the raw primitive to value.
421  /// @return The internal value that meaningful operation can be performed on.
422  virtual String GetValue() const
423  { return Datum; }
424 
425  /// @brief Get data about this being a String
426  /// @return This will return an Integer containing GenericString.
427  virtual Integer GetTypeData() const
428  { return GenericString; }
429 
430  /// @brief Get a pointer to the most Derived type of this class
431  /// @return A pointer of the most derived pointing to this.
433  { return this; }
434  }; //ScriptArgumentGeneric<String>
435 
436  /// @brief A Real number implementation of a ScriptArgument that is suitable for primitive types in most situations
437  /// @details Scripting Languages that require algorithms specific to Real Numbers should add required functionality
438  /// to a type derived from this.
439  template <>
441  {
442  protected:
443  /// @brief The Real actual data.
445 
446  public:
447  /// @brief To make working with this easier.
448  typedef Real Type;
449 
450  /// @brief Create an initialized Argument
451  /// @param InitialValue The value to initialize the Argument Integer value with.
452  /// @note Intentionally not explicit, this allow for passing convertable types directly to functions.
453  ScriptArgumentGeneric(Real InitialValue) :
454  Datum(InitialValue)
455  {}
456 
457  /// @brief Overloadable Deconstructor
459  {}
460 
461  /// @brief Get the Real as a String.
462  /// @return The Real value lexographically converted as a @ref String
463  virtual String GetString() const
464  { return ToString(Datum); }
465 
466  /// @brief Get the Real as a Whole.
467  /// @return The Real value lexographically converted as a @ref Whole
468  virtual Whole GetWhole() const
469  { return Whole(Datum); }
470 
471  /// @brief Get the Real as a Integer.
472  /// @return The Real value lexographically converted as an @ref Integer
473  virtual Integer GetInteger() const
474  { return Integer(Datum); }
475 
476  /// @brief Get the Real.
477  /// @return The Real.
478  virtual Real GetReal() const
479  { return Datum; }
480 
481  /// @brief Get the Real as a Boole
482  /// @return The Real value lexographically converted as an @ref Boole
483  virtual Boole GetBoole() const
484  { return Boole(Datum); }
485 
486  /// @brief Is this value representing a Null/Nil value.
487  /// @return In most languages 0.0 is a valid value for Real Numbers, so any value in this is assumed to not be NULL. This should be overridden if different behavior is required.
488  virtual Boole IsNull() const
489  { return false; }
490 
491  /// @brief Provide an overload point to change assignment that operators will use.
492  /// @param NewValue The new value for this.
493  virtual void SetValue(Real NewValue)
494  { Datum=NewValue; }
495 
496  /// @brief Get the raw primitive to value.
497  /// @return The internal value that meaningful operations can be performed on.
498  virtual Real GetValue() const
499  { return Datum; }
500 
501  /// @brief Get data about this being a Real number.
502  /// @return This will return an Integer containing GenericReal.
503  virtual Integer GetTypeData() const
504  { return GenericReal; }
505 
506  /// @brief Get a pointer to the most Derived type of this class
507  /// @return A pointer of the most derived pointing to this.
509  { return this; }
510  }; //ScriptArgumentGeneric<Real>
511 
512  /// @brief A Bool implementation of a ScriptArgument that is suitable for primitive types in most situations
513  /// @details Scripting Languages that require algorithms specific to boolean values should add required functionality
514  /// to a type derived from this.
515  template <>
517  {
518  protected:
519  /// @brief The Bool actual data.
521 
522  public:
523  /// @brief To make working with this easier.
524  typedef Boole Type;
525 
526  /// @brief Create an initialized Argument
527  /// @param InitialValue The value to initialize the Argument Integer value with.
528  /// @note Intentionally not explicit, this allow for passing convertable types directly to functions.
529  ScriptArgumentGeneric(Boole InitialValue) :
530  Datum(InitialValue)
531  {}
532 
533  /// @brief Overloadable Deconstructor
535  {}
536 
537  /// @brief Get the Bool as a String.
538  /// @return The Bool value lexographically converted as a @ref String
539  virtual String GetString() const
540  { return ToString(Datum); }
541 
542  /// @brief Get the Bool as a Whole.
543  /// @return The Bool value lexographically converted as a @ref Whole
544  virtual Whole GetWhole() const
545  { return Whole(Datum); }
546 
547  /// @brief Get the Bool as a Integer.
548  /// @return The Bool value lexographically converted as an @ref Integer
549  virtual Integer GetInteger() const
550  { return Integer(Datum); }
551 
552  /// @brief Get the Bool as a Integer.
553  /// @return The Bool value lexographically converted as an @ref Integer
554  virtual Real GetReal() const
555  { return Real(Datum); }
556 
557  /// @brief Get the Bool.
558  /// @return The Bool.
559  virtual Boole GetBoole() const
560  { return Datum; }
561 
562  /// @brief Is this value representing a Null/Nil value.
563  /// @return In most languages false is a valid value for Bools, so any value in this is assumed to not be NULL. This should be overridden if different behavior is required.
564  virtual Boole IsNull() const
565  { return false; }
566 
567  /// @brief Provide an overload point to change assignment that operators will use.
568  /// @param NewValue The new value for this.
569  virtual void SetValue(Boole NewValue)
570  { Datum=NewValue; }
571 
572  /// @brief Get the raw primitive to value.
573  /// @return The internal value that meaningful operations can be performed on.
574  virtual Boole GetValue() const
575  { return Datum; }
576 
577  /// @brief Get data about this being a Bool
578  /// @return This will return an Integer containing GenericBool.
579  virtual Integer GetTypeData() const
580  { return GenericBool; }
581 
582  /// @brief Get a pointer to the most Derived type of this class
583  /// @return A pointer of the most derived pointing to this.
585  { return this; }
586  }; //ScriptArgumentGeneric<Bool>
587 
588  /// @brief A very simple type used to indicate to script argument templates that the argument represents
589  class NullArgument {};
590 
591  /// @brief A Null implementation of a ScriptArgument that is suitable for primitive types in most situations
592  /// @details This will likely need to be overidden to get the string varation correct.
593  template <>
595  {
596  protected:
597  /// @brief The Bool actual data.
599 
600  public:
601  /// @brief To make working with this easier.
603 
604  /// @brief Create an initialized Argument
605  /// @param InitialValue The value to initialize the Argument Integer value with.
606  /// @note Intentionally not explicit, this allow for passing convertable types directly to functions.
608  Datum(InitialValue)
609  {}
610 
611  /// @brief Overloadable Deconstructor
613  {}
614 
615  /// @brief Get Null as a String.
616  /// @return The Bool value lexographically converted as a @ref String
617  virtual String GetString() const
618  { return "Null"; }
619 
620  /// @brief Get Null as a Whole.
621  /// @return The Bool value lexographically converted as a @ref Whole
622  virtual Whole GetWhole() const
623  { return 0; }
624 
625  /// @brief Get Null as a Integer.
626  /// @return The Bool value lexographically converted as an @ref Integer
627  virtual Integer GetInteger() const
628  { return 0; }
629 
630  /// @brief Get Null as a Real.
631  /// @return The Bool value lexographically converted as an @ref Integer
632  virtual Real GetReal() const
633  { return 0.0; }
634 
635  /// @brief Get as a Bool.
636  /// @return False.
637  virtual Boole GetBoole() const
638  { return false; }
639 
640  /// @brief Is this value representing a Null/Nil value.
641  /// @return In most languages false is a valid value for Bools, so any value in this is assumed to not be NULL. This should be overridden if different behavior is required.
642  virtual Boole IsNull() const
643  { return true; }
644 
645  /// @brief Provide an overload point to change assignment that operators will use.
646  /// @param NewValue The new value for this.
647  virtual void SetValue(NullArgument NewValue)
648  { Datum=NewValue; }
649 
650  /// @brief Get the raw primitive to value.
651  /// @return The internal value that meaningful operations can be performed on.
652  virtual NullArgument GetValue() const
653  { return Datum; }
654 
655  /// @brief Get data about this being a Bool
656  /// @return This will return an Integer containing GenericBool.
657  virtual Integer GetTypeData() const
658  { return GenericNull; }
659 
660  /// @brief Get a pointer to the most Derived type of this class
661  /// @return A pointer of the most derived pointing to this.
663  { return this; }
664  }; //ScriptArgumentGeneric<Bool>
665 
666  }//Scripting
667 
668  /// @brief Marks iScriptArgument for internal reference counting if a CountedPtr checks
669  template <>
670  class ReferenceCountTraits <Scripting::iScriptArgument>
671  {
672  public:
673  /// @brief The type that maintains the Reference count for iScriptArgument with be iScriptArgument itself
675 
676  /// @brief Given a pointer to the raw object this will return a pointer to an initialized reference count
677  /// @param Target A pointer to a Scripting::iScriptArgument that will simply be returned
678  /// @return This returns whatever was passed into target because it already is a valid Reference Counter
679  static RefCountType* ConstructionPointer(RefCountType* Target)
680  { return Target; }
681 
682  /// @brief This uses dynamic casting when resolving casts inside the CountedPtr
683  enum { IsCastable = CastDynamic };
684  };
685 
686  /// @brief Marks ScriptArgumentGeneric<Integer> for internal reference counting if a CountedPtr checks
687  template <>
688  class ReferenceCountTraits <Scripting::ScriptArgumentGeneric<Integer> >
689  {
690  public:
691  /// @brief The type that maintains the Reference count for ScriptArgumentGeneric<Integer> with be ScriptArgumentGeneric<Integer> itself
693 
694  /// @brief Given a pointer to the raw object this will return a pointer to an initialized reference count
695  /// @param Target A pointer to a Scripting::ScriptArgumentGeneric<Integer> that will simply be returned
696  /// @return This returns whatever was passed into target because it already is a valid Reference Counter
697  static RefCountType* ConstructionPointer(RefCountType* Target)
698  { return Target; }
699 
700  /// @brief This uses dynamic casting when resolving casts inside the CountedPtr
701  enum { IsCastable = CastDynamic };
702  };
703 
704  /// @brief Marks ScriptArgumentGeneric<Whole> for internal reference counting if a CountedPtr checks
705  template <>
706  class ReferenceCountTraits <Scripting::ScriptArgumentGeneric<Whole> >
707  {
708  public:
709  /// @brief The type that maintains the Reference count for ScriptArgumentGeneric<Whole> with be ScriptArgumentGeneric<Whole> itself
711 
712  /// @brief Given a pointer to the raw object this will return a pointer to an initialized reference count
713  /// @param Target A pointer to a Scripting::ScriptArgumentGeneric<Whole> that will simply be returned
714  /// @return This returns whatever was passed into target because it already is a valid Reference Counter
715  static RefCountType* ConstructionPointer(RefCountType* Target)
716  { return Target; }
717 
718  /// @brief This uses dynamic casting when resolving casts inside the CountedPtr
719  enum { IsCastable = CastDynamic };
720  };
721 
722  /// @brief Marks ScriptArgumentGeneric<String> for internal reference counting if a CountedPtr checks
723  template <>
724  class ReferenceCountTraits <Scripting::ScriptArgumentGeneric<String> >
725  {
726  public:
727  /// @brief The type that maintains the Reference count for ScriptArgumentGeneric<String> with be ScriptArgumentGeneric<String> itself
729 
730  /// @brief Given a pointer to the raw object this will return a pointer to an initialized reference count
731  /// @param Target A pointer to a Scripting::ScriptArgumentGeneric<String> that will simply be returned
732  /// @return This returns whatever was passed into target because it already is a valid Reference Counter
733  static RefCountType* ConstructionPointer(RefCountType* Target)
734  { return Target; }
735 
736  /// @brief This uses dynamic casting when resolving casts inside the CountedPtr
737  enum { IsCastable = CastDynamic };
738  };
739 
740  /// @brief Marks ScriptArgumentGeneric<Real> for internal reference counting if a CountedPtr checks
741  template <>
742  class ReferenceCountTraits <Scripting::ScriptArgumentGeneric<Real> >
743  {
744  public:
745  /// @brief The type that maintains the Reference count for ScriptArgumentGeneric<Real> with be ScriptArgumentGeneric<Real> itself
747 
748  /// @brief Given a pointer to the raw object this will return a pointer to an initialized reference count
749  /// @param Target A pointer to a Scripting::ScriptArgumentGeneric<Real> that will simply be returned
750  /// @return This returns whatever was passed into target because it already is a valid Reference Counter
751  static RefCountType* ConstructionPointer(RefCountType* Target)
752  { return Target; }
753 
754  /// @brief This uses dynamic casting when resolving casts inside the CountedPtr
755  enum { IsCastable = CastDynamic };
756  };
757 
758  /// @brief Marks ScriptArgumentGeneric<Real> for internal reference counting if a CountedPtr checks
759  template <>
760  class ReferenceCountTraits <Scripting::ScriptArgumentGeneric<Boole> >
761  {
762  public:
763  /// @brief The type that maintains the Reference count for ScriptArgumentGeneric<Bool> with be ScriptArgumentGeneric<Bool> itself
765 
766  /// @brief Given a pointer to the raw object this will return a pointer to an initialized reference count
767  /// @param Target A pointer to a Scripting::ScriptArgumentGeneric<Bool> that will simply be returned
768  /// @return This returns whatever was passed into target because it already is a valid Reference Counter
769  static RefCountType* ConstructionPointer(RefCountType* Target)
770  { return Target; }
771 
772  /// @brief This uses dynamic casting when resolving casts inside the CountedPtr
773  enum { IsCastable = CastDynamic };
774  };
775 
776  /// @brief Marks ScriptArgumentGeneric<Real> for internal reference counting if a CountedPtr checks
777  template <>
778  class ReferenceCountTraits <Scripting::ScriptArgumentGeneric<Scripting::NullArgument> >
779  {
780  public:
781  /// @brief The type that maintains the Reference count for ScriptArgumentGeneric<Scripting::NullArgument> with be ScriptArgumentGeneric<Scripting::NullArgument> itself
783 
784  /// @brief Given a pointer to the raw object this will return a pointer to an initialized reference count
785  /// @param Target A pointer to a Scripting::ScriptArgumentGeneric<Scripting::NullArgument> that will simply be returned
786  /// @return This returns whatever was passed into target because it already is a valid Reference Counter
787  static RefCountType* ConstructionPointer(RefCountType* Target)
788  { return Target; }
789 
790  /// @brief This uses dynamic casting when resolving casts inside the CountedPtr
791  enum { IsCastable = CastDynamic };
792  };
793 
794 
795 }//Mezzanine
796 
797 
798 
799 #endif // \_scriptargument_h
A Real number implementation of a ScriptArgument that is suitable for primitive types in most situati...
virtual Integer GetTypeData() const
Get data about this being a Bool.
virtual ScriptArgumentGeneric< Boole > * GetMostDerived()
Get a pointer to the most Derived type of this class.
virtual ScriptArgumentGeneric< Real > * GetMostDerived()
Get a pointer to the most Derived type of this class.
Scripting::ScriptArgumentGeneric< Whole > RefCountType
The type that maintains the Reference count for ScriptArgumentGeneric with be ScriptArgumentGe...
Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an Integer...
virtual Boole GetBoole() const
Get the Integer as a Boole.
String Type
To make working with this easier.
Scripting::ScriptArgumentGeneric< Scripting::NullArgument > RefCountType
The type that maintains the Reference count for ScriptArgumentGeneric with b...
ScriptArgument
A listing of the Base types an iScriptArgument could represent.
virtual String GetString() const
Get the Integer as a String.
virtual String GetValue() const
Get the raw primitive to value.
virtual Boole GetBoole() const
Get the String as a Boole.
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
A Integer implementation of a ScriptArgument that is suitable for primitive types in most situations...
virtual Whole GetValue() const
Get the raw primitive to value.
virtual String GetString() const
Get the Real as a String.
virtual ~ScriptArgumentGeneric()
Overloadable Deconstructor.
A sample class that implements a minimal intrusive reference counting scheme.
Definition: countedptr.h:147
Boole ToBool(const T &Datum)
Converts whatever to a Boole as long as the proper streaming operators are available for it...
Definition: datatypes.h:286
virtual Whole GetWhole() const
Get the Argument as a Whole, slow default implementation.
This is not readily available when instantiating ScriptArgumentGeneric where T is unknown...
String ToString(const T &Datum)
Converts whatever to a String as long as a streaming operator is available for it.
Definition: datatypes.h:242
virtual Real GetReal() const
Get Null as a Real.
virtual Real GetReal() const
Get the Whole as a Real.
Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an Bool...
static RefCountType * ConstructionPointer(RefCountType *Target)
Given a pointer to the raw object this will return a pointer to an initialized reference count...
static RefCountType * ConstructionPointer(RefCountType *Target)
Given a pointer to the raw object this will return a pointer to an initialized reference count...
virtual ScriptArgumentGeneric< Integer > * GetMostDerived()
Get a pointer to the most Derived type of this class.
virtual Whole GetWhole() const
Get the Bool as a Whole.
virtual Boole IsNull() const
Is this value representing a Null/Nil value.
All the definitions for datatypes as well as some basic conversion functions are defined here...
virtual ScriptArgumentGeneric< Whole > * GetMostDerived()
Get a pointer to the most Derived type of this class.
virtual Boole GetBoole() const
Get the Real as a Boole.
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
virtual String GetString() const
Get the String.
virtual iScriptArgument * GetMostDerived()
Get a pointer to the most Derived type of this class.
Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an Real...
virtual Real GetReal() const
Get the Real.
Returned from GetTypeData() const when a ScriptArgumentGeneric is intended as NullPtr, SQL Null, Lua Nil, Ruby nil, etc...
ScriptArgumentGeneric(T InitialValue)
Create an initialized Argument.
ScriptArgumentGeneric(NullArgument InitialValue=NullArgument())
Create an initialized Argument.
ScriptArgumentGeneric(Boole InitialValue)
Create an initialized Argument.
virtual ScriptArgumentGeneric< String > * GetMostDerived()
Get a pointer to the most Derived type of this class.
virtual Integer GetValue() const
Get the raw primitive to value.
static RefCountType * ConstructionPointer(RefCountType *Target)
Given a pointer to the raw object this will return a pointer to an initialized reference count...
ScriptArgumentGeneric(Real InitialValue)
Create an initialized Argument.
virtual ~ScriptArgumentGeneric()
Overloadable Deconstructor.
Boole Type
To make working with this easier.
virtual Real GetReal() const
Get the Bool as a Integer.
virtual Boole IsNull() const
Is this value representing a Null/Nil value.
A dynamic cast from the pointer as provided with no attempt to calls functions on the pointer target...
Definition: countedptr.h:64
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
A Whole number implementation of a ScriptArgument that is suitable for primitive types in most situat...
virtual T GetValue() const
Get the raw primitive to value.
virtual void SetValue(T NewValue)
Provide an overload point to change assignment that operators will use.
virtual Integer GetInteger() const
Get Null as a Integer.
virtual ~ScriptArgumentGeneric()
Overloadable Deconstructor.
Integer Type
To make working with this easier.
virtual void SetValue(String NewValue)
Provide an overload point to change assignment that operators will use.
This is used to deduce at compile if a specific class has built-in reference counting or needs an ext...
Definition: countedptr.h:87
virtual Integer GetInteger() const
Get the Real as a Integer.
virtual Real GetReal() const
Get the Argument as a Real, slow default implementation.
virtual Boole IsNull() const
Is this value representing a Null/Nil value.
virtual Integer GetTypeData() const
Get data about this having an unknown type.
Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an String...
virtual Integer GetInteger() const
Get the Bool as a Integer.
This is always equal to the maximum value in this enumeration so that other constant values can be ba...
Scripting::ScriptArgumentGeneric< Real > RefCountType
The type that maintains the Reference count for ScriptArgumentGeneric with be ScriptArgumentGen...
virtual Integer GetTypeData() const
Get data about this being a Whol.
virtual Boole GetValue() const
Get the raw primitive to value.
virtual ~ScriptArgumentGeneric()
Overloadable Deconstructor.
virtual ~ScriptArgumentGeneric()
Overloadable Deconstructor.
Returned from GetTypeData() const when a ScriptArgumentGeneric is specialized as an Whole...
A String implementation of a ScriptArgument that is suitable for primitive types in most situations...
This file describes and implements a reference counted pointer that is NOT threadsafe.
virtual Real GetReal() const
Get the String as a Real.
virtual String GetString() const
Get the Bool as a String.
ScriptArgumentGeneric(Integer InitialValue)
Create an initialized Argument.
virtual Boole GetBoole() const
Get the Whole Number as a Boole.
virtual NullArgument GetValue() const
Get the raw primitive to value.
virtual ScriptArgumentGeneric< T > * GetMostDerived()
Get a pointer to the most Derived type of this class.
virtual ~ScriptArgumentGeneric()
Overloadable Deconstructor.
virtual ~ScriptArgumentGeneric()
Overloadable Deconstructor.
virtual Boole GetBoole() const
Get the Argument as a Boole.
virtual String GetString() const
Get the Whole as a String.
static RefCountType * ConstructionPointer(RefCountType *Target)
Given a pointer to the raw object this will return a pointer to an initialized reference count...
virtual Real GetReal() const
Get the Integer as a Real.
virtual Boole IsNull() const
Is this value representing a Null/Nil value.
Real ToReal(const T &Datum)
Converts whatever to a Real as long as the proper streaming operators are available for it...
Definition: datatypes.h:280
virtual Whole GetWhole() const
Get Null as a Whole.
A Bool implementation of a ScriptArgument that is suitable for primitive types in most situations...
virtual void SetValue(NullArgument NewValue)
Provide an overload point to change assignment that operators will use.
virtual Whole GetWhole() const
Get the String as a Whole.
A very simple type used to indicate to script argument templates that the argument represents...
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
Real Type
To make working with this easier.
virtual Integer GetTypeData() const
Get data about this being a Bool.
virtual ~iScriptArgument()
Overidable Deconstructor.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
virtual Boole IsNull() const
Is this value representing a Null/Nil value.
virtual Boole IsNull() const
Is this value representing a Null/Nil value.
Whole Type
To make working with this easier.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
Scripting::ScriptArgumentGeneric< Integer > RefCountType
The type that maintains the Reference count for ScriptArgumentGeneric with be ScriptArgument...
virtual Integer GetInteger() const
Get the String as a Integer.
ScriptArgumentGeneric(Whole InitialValue)
Create an initialized Argument.
T Type
To make working with this easier.
virtual Integer GetTypeData() const
Get data about this being and Integer.
Scripting::ScriptArgumentGeneric< Boole > RefCountType
The type that maintains the Reference count for ScriptArgumentGeneric with be ScriptArgumentGen...
virtual Integer GetInteger() const
Get the Integer as a Integer.
virtual Real GetValue() const
Get the raw primitive to value.
A generic implementation of a ScriptArgument that is suitable for primitive types in most situations...
virtual void SetValue(Boole NewValue)
Provide an overload point to change assignment that operators will use.
A Null implementation of a ScriptArgument that is suitable for primitive types in most situations...
virtual Whole GetWhole() const
Get the Whole number.
virtual Integer GetInteger() const
Get the Argument as a Integer, slow default implementation.
virtual Integer GetTypeData() const
Get data about this being a Real number.
virtual Whole GetWhole() const
Get the Integer as a Whole.
virtual Integer GetInteger() const
Get the Whole as a Integer.
static RefCountType * ConstructionPointer(RefCountType *Target)
Given a pointer to the raw object this will return a pointer to an initialized reference count...
virtual void SetValue(Integer NewValue)
Provide an overload point to change assignment that operators will use.
virtual void SetValue(Whole NewValue)
Provide an overload point to change assignment that operators will use.
virtual ScriptArgumentGeneric< NullArgument > * GetMostDerived()
Get a pointer to the most Derived type of this class.
static RefCountType * ConstructionPointer(RefCountType *Target)
Given a pointer to the raw object this will return a pointer to an initialized reference count...
Scripting::iScriptArgument RefCountType
The type that maintains the Reference count for iScriptArgument with be iScriptArgument itself...
ScriptArgumentGeneric(String InitialValue)
Create an initialized Argument.
virtual Boole IsNull() const
Is this value representing a Null/Nil value.
The interface for a script argument.
Scripting::ScriptArgumentGeneric< String > RefCountType
The type that maintains the Reference count for ScriptArgumentGeneric with be ScriptArgumentG...
virtual Integer GetTypeData() const
Get data about this being a String.
virtual String GetString() const
Get the Argument as a String, slow default implementation.
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
virtual Boole GetBoole() const
Get the Bool.
NullArgument Type
To make working with this easier.
static RefCountType * ConstructionPointer(RefCountType *Target)
Given a pointer to the raw object this will return a pointer to an initialized reference count...
virtual void SetValue(Real NewValue)
Provide an overload point to change assignment that operators will use.
virtual Whole GetWhole() const
Get the Real as a Whole.
Integer ToInteger(const T &Datum)
Converts whatever to an Integer as long as the proper streaming operators are available for it...
Definition: datatypes.h:258
Whole ToWhole(const T &Datum)
Converts whatever to a Whole as long as the proper streaming operators are available for it...
Definition: datatypes.h:252
virtual String GetString() const
Get Null as a String.