libBsdSockets
C++ Wrapper classes to the BSD Socket API
LocalAddress.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2013, Komodo Does Inc
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 
8 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10 Neither the name of the Komodo Does Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 
13 */
14 
15 #ifndef LOCAL_ADDRESS_H
16 #define LOCAL_ADDRESS_H
17 
18 #ifndef ADDRESS_H
19 #include "Address.h"
20 #endif // ADDRESS_H
21 
22 namespace BsdSockets {
23 
24  /*
25  * Forward Declarations
26  */
27  class LowLevelAddress;
28  class LocalAddressPimpl;
29 
30  /** \class LocalAddress
31  *
32  * \brief Local Socket Address (formerly Unix Domain Socket) Address representing
33  * a named pipe's name.
34  */
35  class LocalAddress : public Address {
36  public:
37  typedef std::shared_ptr<LocalAddress> Ptr;
38 
39  /** Virtual destructor to support derived classes */
40  virtual ~LocalAddress();
41 
42  /** Create from thePath string
43  *
44  * @param thePath path to create from, cannot be empty, must be shorter
45  * than the unspecified maximum length for this system.
46  *
47  * @return LocalAddress created
48  */
49  static LocalAddress::Ptr create(const std::string& thePath);
50 
51  private:
52  /** Create from thePath string
53  *
54  * @param thePath path to create from, cannot be empty, must be shorter
55  * than the unspecified maximum length for this system.
56  * @param a blank address is allowed only from accept()
57  */
58  LocalAddress(const std::string& thePath, bool allowBlank = false);
59 
60  private:
61  LocalAddress() = delete;
62  LocalAddress(const LocalAddress& rhs) = delete;
63  LocalAddress(LocalAddress&& rhs) = delete;
64  LocalAddress& operator=(const LocalAddress& rhs) = delete;
65  LocalAddress& operator=(LocalAddress&& rhs) = delete;
66 
67  public:
68  /** @return the path of this LocalAddress */
69  const std::string& getPath() const;
70 
71  public:
72  virtual std::shared_ptr<LowLevelAddress> makeTempLowLevelAddress() const;
73  virtual Address::Ptr create(std::shared_ptr<LowLevelAddress> lowLevelAddress) const;
74  virtual LowLevelAddress& getLowLevelAddress() const;
75 
76  private:
77  /** The path of this LocalAddress */
78  const std::string path;
79 
80  /** The private implementation of this LocalAddress */
81  std::shared_ptr<LocalAddressPimpl> pimpl;
82  };
83 
84 } // namespace BsdSockets
85 
86 #endif // LOCAL_ADDRESS_H
Base class for all addresses.
Definition: Address.h:36
std::shared_ptr< Address > Ptr
Definition: Address.h:38
Local Socket Address (formerly Unix Domain Socket) Address representing a named pipe's name.
Definition: LocalAddress.h:35
const std::string & getPath() const
virtual std::shared_ptr< LowLevelAddress > makeTempLowLevelAddress() const
std::shared_ptr< LocalAddress > Ptr
Definition: LocalAddress.h:37
static LocalAddress::Ptr create(const std::string &thePath)
virtual LowLevelAddress & getLowLevelAddress() const
Interface for the low-level address implementation.
Namespace of the BsdSockets library.
Definition: Address.cpp:20