libmoost
moost Namespace Reference

Creates a unique temporary directory; removed on scope exit. More...

Namespaces

namespace  algorithm
namespace  configurable
namespace  container
namespace  detail
namespace  digest
namespace  hash
namespace  io
 

IO-related routines used commonly everywhere.


namespace  kvds
namespace  kvstore
namespace  logging
namespace  math
namespace  mpl
namespace  mq
namespace  murcl
namespace  nagios
namespace  pdl
namespace  posix_time
namespace  process
namespace  progress
namespace  psql
namespace  serialization
namespace  service
namespace  signal
namespace  string
namespace  testing
namespace  thread
namespace  transaction
namespace  utils
namespace  xml

Classes

class  guarded_ptr
 Wrapper around shared_ptr that guards the referenced object with a mutex. More...
class  safe_shared_ptr
class  scoped_verbose
 handles verbose gracefully. It behaves like ostringstream and prints the verbose at the end of the scope. Example. More...
class  shell
class  null_terminal_format
class  vt_100_terminal_format
class  scoped_format
class  timer
class  multi_timer
class  which_back_inserter_iterator
class  which_inserter_iterator
struct  which

Typedefs

typedef vt_100_terminal_format terminal_format

Enumerations

enum  eColor {
  C_BLACK = 30, C_RED = 31, C_GREEN = 32, C_YELLOW = 33,
  C_BLUE = 34, C_MAGENTA = 35, C_CYAN = 36, C_WHITE = 37,
  BGC_BLACK = 40, BGC_RED = 41, BGC_GREEN = 42, BGC_YELLOW = 43,
  BGC_BLUE = 44, BGC_MAGENTA = 45, BGC_CYAN = 46, BGC_WHITE = 47
}
enum  eMask {
  tf_standard = 1<<0, tf_bold = 1<<1, tf_italic = 1<<2, tf_underline = 1<<3,
  tf_blinking = 1<<4, tf_reverse = 1<<5, tf_black = 1<<6, tf_red = 1<<7,
  tf_green = 1<<8, tf_blue = 1<<9, tf_magenta = 1<<10, tf_cyan = 1<<11,
  tf_white = 1<<12, tf_bgblack = 1<<13, tf_bgred = 1<<14, tf_bggreen = 1<<15,
  tf_bgblue = 1<<16, tf_bgmagenta = 1<<17, tf_bgcyan = 1<<18, tf_bgwhite = 1<<19
}

Functions

template<class Y , class Z >
bool operator== (safe_shared_ptr< Y > const &a, safe_shared_ptr< Z > const &b)

Detailed Description

Creates a unique temporary directory; removed on scope exit.

Volatile signal.

Convert stiing to level object.

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

file_backed_data_source.hpp

A generic automagically reloading file-backed data source. The data type and the loading process must be specified in a DataPolicy class. The DataPolicy should implement data_policy_base<T> where T is the type of the data to be held in the source. The filepath and other options for the source are typically read from an xml file, though they can also be set directly on a file_backed_data_source_config object. In either case you can use a file_backed_data_source_factory to create your source.

The xml configuration format looks like this:

<FileBackedDataSource> <Filepath>/path/to/data/file</Filepath> <MinSecsSinceLastLoad>30</MinSecsSinceLastLoad> <ThrowOnFirstLoadFail>true</ThrowOnFirstLoadFail> <MinProportionOfLastLoad>0.5</MinProportionOfLastLoad> </FileBackedDataSource>

file_backed_data_source logs info and warnings related to data loading with moost::logging. You must therefore initialiase moost::logging in your code in the usual way before using a file_backed_data_source.

Synopsis:

// this policy loads a map<int,int> from file typedef std::map<int, int> int_map_t; class IntMapDataPolicy : public data_policy_base<int_map_t> { public: std::string getName() const { return "int map data"; } boost::shared_ptr<int_map_t> loadFromFile(const std::string& filepath) const { boost::shared_ptr<int_map_t> pData(new int_map_t); // read from filepath into pData ... return pData; } size_t size(shared_ptr<int_map_t> pData) const { return pData->size(); } };

typedef file_backed_data_source<IntMapDataPolicy> source_t;

file_backed_data_source_config conf; conf.filepath = "/path/to/data/file";

IntMapDataPolicy dataPolicy;

file_backed_data_source_factory sourceFactory; boost::shared_ptr<source_t> pSource = sourceFactory.createFromConfig(dataPolicy, conf);

pSource->load(); // ... the data will now reload automagically when the file updates

{ shared_ptr<int_map_t> pData = pSource->get_shared_ptr(); // now you can use pData safely in this scope, even if a reload happens }

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note:

Using this is safer than generating a temp filename and then creating the file as this can lead to a race condition situation. By creating a temporary directory (which the OS guarantees will be unique and not used again for as long as it exists) and writing files to this new location you can be sure you won't collide with another process.

NB. The main purpose of this implementation is to allow code that uses a platform specific k/v store to still compile and run on other platforms for debugging purposes. It is not really aimed at production use (hence is functional but not necessarily efficient -- this is by design!!!

TODO [RWC 2009-11-23]: Needs transaction logging for crash recoverly tolerance : Defrag tool to compact files with holes to save disk space : Make max value size optional (auto-allocate new page stores)

Takes a string and converts it to a level object, throwing an exception if the convertion fails

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. You can implement your own progress display policy if you wish, you just need to base it on the progress policy concept that is modeled by this skeleton policy.

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Serialization of moost (Google) sparse and dense hashmap types

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Serialization of moost (Google) sparse and dense hashset types

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Whilst signal is atomic across threads any changes made to it may not be seen cross-thread because the compiler is at liberty to optimize them out. By making it volatile we force the compiler to not-optimize and; thus, any changes will be seen in all threads.

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/file Demangle symbol names

The gcc compiler doesn't produce very pretty output from type_info (Windows does an ok job) and since we often use the type_info class names when logging this is needed to pretty it up.

http://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html

/file Convert full function names to short function names

This function will convert the full function name (and all its adornments) into something a little less verbose. It will strip off all calling and template arguments and the return type and leave behind just the name of the function and, if it is a class member function, the class to which it belongs. Note the name of the class in the case of a class member function is not shortened, so if it contains a vast number of template parameters it may still be long.

http://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/file A policy driven scope exit framework

A simple (Q&D) version of boost ScopeExit (because 1.35 doesn't have it!) ---> Ironically, we are now using boost 1.42 but this is simpler to use :)

http://www.boost.org/doc/libs/1_41_0/libs/scope_exit/doc/html/scope_exit/ref.html

Copyright © 2008-2013 Last.fm Limited

This file is part of libmoost.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This is NOT a replacement for moost::timer! This is a very simple collection of classes to start, stop and pause a stopwatch so as to get very simple wall-clock metrics. It is not all singing or dancing - it just does what it says on the tin.


Typedef Documentation


Enumeration Type Documentation

Enumerator:
C_BLACK 
C_RED 
C_GREEN 
C_YELLOW 
C_BLUE 
C_MAGENTA 
C_CYAN 
C_WHITE 
BGC_BLACK 
BGC_RED 
BGC_GREEN 
BGC_YELLOW 
BGC_BLUE 
BGC_MAGENTA 
BGC_CYAN 
BGC_WHITE 

Definition at line 39 of file terminal_format.hpp.

Enumerator:
tf_standard 
tf_bold 
tf_italic 
tf_underline 
tf_blinking 
tf_reverse 
tf_black 
tf_red 
tf_green 
tf_blue 
tf_magenta 
tf_cyan 
tf_white 
tf_bgblack 
tf_bgred 
tf_bggreen 
tf_bgblue 
tf_bgmagenta 
tf_bgcyan 
tf_bgwhite 

Definition at line 60 of file terminal_format.hpp.


Function Documentation

template<class Y , class Z >
bool moost::operator== ( safe_shared_ptr< Y > const &  a,
safe_shared_ptr< Z > const &  b 
) [inline]

Definition at line 289 of file safe_shared_ptr.hpp.